Class: Spreedly::Resource

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

Overview

:nodoc: all

Direct Known Subclasses

Subscriber, SubscriptionPlan

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Resource

Returns 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

#method_missing(method, *args) ⇒ Object



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

Class Method Details

.attributesObject



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

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

.attributes=(value) ⇒ Object



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

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

Instance Method Details

#idObject



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

def id
  @data["id"]
end