Class: Frulo::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/frulo.rb

Direct Known Subclasses

Plan, Subscriber

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Resource

Returns a new instance of Resource.



31
32
33
# File 'lib/frulo.rb', line 31

def initialize(data)
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/frulo.rb', line 39

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 Method Details

#idObject



35
36
37
# File 'lib/frulo.rb', line 35

def id
  @data["id"]
end