Module: DocumentBuilder::Model::ClassMethods
- Defined in:
- lib/document_builder/model.rb
Instance Method Summary collapse
- #add_attribute(name, attribute) ⇒ Object
- #attributes ⇒ Object
- #call(document) ⇒ Object
- #collection(name, selector: nil, type: nil) ⇒ Object
- #property(name, selector: nil, type: nil) ⇒ Object
- #root(selector) ⇒ Object
- #tag(name, selector: nil, type: nil) ⇒ Object
Instance Method Details
#add_attribute(name, attribute) ⇒ Object
8 9 10 |
# File 'lib/document_builder/model.rb', line 8 def add_attribute(name, attribute) attributes[name.to_sym] = attribute end |
#attributes ⇒ Object
4 5 6 |
# File 'lib/document_builder/model.rb', line 4 def attributes @attributes ||= {} end |
#call(document) ⇒ Object
28 29 30 |
# File 'lib/document_builder/model.rb', line 28 def call(document) self.new(document) end |
#collection(name, selector: nil, type: nil) ⇒ Object
20 21 22 |
# File 'lib/document_builder/model.rb', line 20 def collection(name, selector: nil, type: nil) add_attribute name, Collection.new(name, selector: selector, type: type) end |
#property(name, selector: nil, type: nil) ⇒ Object
12 13 14 |
# File 'lib/document_builder/model.rb', line 12 def property(name, selector: nil, type: nil) add_attribute name, Property.new(name, selector: selector, type: type) end |
#root(selector) ⇒ Object
24 25 26 |
# File 'lib/document_builder/model.rb', line 24 def root(selector) @root = selector end |
#tag(name, selector: nil, type: nil) ⇒ Object
16 17 18 |
# File 'lib/document_builder/model.rb', line 16 def tag(name, selector: nil, type: nil) add_attribute name, Tag.new(name, selector: selector, type: type) end |