Module: AirbnbApi::Resource::ClassMethods
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#many ⇒ Object
readonly
Returns the value of attribute many.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #build(attributes) ⇒ Object
- #has_attributes(attributes) ⇒ Object
- #has_many(attribute, klass) ⇒ Object
- #has_root(boolean) ⇒ Object
- #root_element ⇒ Object
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
28 29 30 |
# File 'lib/airbnb_api/resource.rb', line 28 def attributes @attributes end |
#many ⇒ Object (readonly)
Returns the value of attribute many.
28 29 30 |
# File 'lib/airbnb_api/resource.rb', line 28 def many @many end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
28 29 30 |
# File 'lib/airbnb_api/resource.rb', line 28 def root @root end |
Instance Method Details
#build(attributes) ⇒ Object
49 50 51 |
# File 'lib/airbnb_api/resource.rb', line 49 def build(attributes) new(attributes) end |
#has_attributes(attributes) ⇒ Object
30 31 32 |
# File 'lib/airbnb_api/resource.rb', line 30 def has_attributes(attributes) attr_accessor(*@attributes = attributes) end |
#has_many(attribute, klass) ⇒ Object
34 35 36 37 38 |
# File 'lib/airbnb_api/resource.rb', line 34 def has_many(attribute, klass) @many ||= {} @many[attribute.to_sym] = klass attr_accessor(attribute.to_sym) end |
#has_root(boolean) ⇒ Object
40 41 42 |
# File 'lib/airbnb_api/resource.rb', line 40 def has_root(boolean) @root = boolean end |
#root_element ⇒ Object
44 45 46 47 |
# File 'lib/airbnb_api/resource.rb', line 44 def root_element @root = @root.nil? ? true : @root @root ? name.to_s.gsub(/([^\^])([A-Z])/,'\1_\2').downcase.to_sym : nil end |