Module: AirbnbApi::Resource::ClassMethods

Included in:
Listing, Message, Thread, Token
Defined in:
lib/airbnb_api/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



28
29
30
# File 'lib/airbnb_api/resource.rb', line 28

def attributes
  @attributes
end

#manyObject (readonly)

Returns the value of attribute many.



28
29
30
# File 'lib/airbnb_api/resource.rb', line 28

def many
  @many
end

#rootObject (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_elementObject



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