Class: Drip::Resource

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_data = {}) ⇒ Resource

Returns a new instance of Resource.



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

def initialize(raw_data = {})
  @raw_attributes = raw_data.dup.freeze
  @attributes = process(@raw_attributes)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



24
25
26
# File 'lib/drip/resource.rb', line 24

def method_missing(method_name, *args, &block)
  attributes.keys.include?(method_name.to_s) ? attributes[method_name.to_s] : super
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/drip/resource.rb', line 5

def attributes
  @attributes
end

#raw_attributesObject (readonly)

Returns the value of attribute raw_attributes.



5
6
7
# File 'lib/drip/resource.rb', line 5

def raw_attributes
  @raw_attributes
end

Class Method Details

.resource_nameObject



12
13
14
# File 'lib/drip/resource.rb', line 12

def self.resource_name
  "resource"
end

Instance Method Details

#respond_to?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/drip/resource.rb', line 20

def respond_to?(method_name, include_private = false)
  attributes.keys.include?(method_name.to_s) || super
end

#singular?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/drip/resource.rb', line 16

def singular?
  true
end