Class: Spreedly::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/spreedly.rb,
lib/spreedly/mock.rb

Overview

:nodoc: all

Direct Known Subclasses

Invoice, Subscriber, SubscriptionPlan

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Resource) initialize(params = {})

A new instance of Resource



66
67
68
# File 'lib/spreedly.rb', line 66

def initialize(data)
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method, *args)



74
75
76
77
78
79
80
81
82
# File 'lib/spreedly.rb', line 74

def method_missing(method, *args, &block)
  if method.to_s =~ /\?$/
    send(method.to_s[0..-2])
  elsif @data.include?(method.to_s)
    @data[method.to_s]
  else
    super
  end
end

Instance Attribute Details

- (Object) attributes (readonly)

Returns the value of attribute attributes



25
26
27
# File 'lib/spreedly/mock.rb', line 25

def attributes
  @attributes
end

Class Method Details

+ (Object) attributes



17
18
19
# File 'lib/spreedly/mock.rb', line 17

def self.attributes
  @attributes ||= {}
end

+ (Object) attributes=(value)



21
22
23
# File 'lib/spreedly/mock.rb', line 21

def self.attributes=(value)
  @attributes = value
end

Instance Method Details

- (Object) id



70
71
72
# File 'lib/spreedly.rb', line 70

def id
  @data["id"]
end