Class: Spreedly::Subscriptions::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/spreedly/subscriptions.rb,
lib/spreedly/subscriptions/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

#initialize(params = {}) ⇒ Resource

Returns a new instance of Resource.



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

def initialize(data)
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



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

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

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

Class Method Details

.attributesObject



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

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

.attributes=(value) ⇒ Object



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

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

Instance Method Details

#idObject



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

def id
  @data["id"]
end