Class: Zoid::Resource

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

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Resource

Returns a new instance of Resource.



3
4
5
# File 'lib/zoid/resource.rb', line 3

def initialize(hash)
  @attributes = hash
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/zoid/resource.rb', line 11

def method_missing(method, *args)
  if @attributes.has_key?(method.to_s)
    @attributes[method.to_s]
  else
    super
  end
end

Instance Method Details

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/zoid/resource.rb', line 7

def respond_to_missing?(method, include_private = false)
  @attributes.has_key?[method.to_s]
end