Class: Moblues::Reader::Entity
- Inherits:
-
Object
- Object
- Moblues::Reader::Entity
- Defined in:
- lib/moblues/reader/entity.rb
Instance Method Summary collapse
- #entity(xml) ⇒ Object
-
#initialize(params = defaults) ⇒ Entity
constructor
A new instance of Entity.
Constructor Details
#initialize(params = defaults) ⇒ Entity
Returns a new instance of Entity.
9 10 11 12 |
# File 'lib/moblues/reader/entity.rb', line 9 def initialize(params = defaults) @attribute_reader = params[:attribute_reader] @relationship_reader = params[:relationship_reader] end |
Instance Method Details
#entity(xml) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/moblues/reader/entity.rb', line 14 def entity(xml) attributes = xml.elements.to_a('attribute').map { |xml_attr| attribute_reader.attribute(xml_attr) } relationships = xml.elements.to_a('relationship').map { |xml_rel| relationship_reader.relationship(xml_rel) } DataModel::Entity.new(name: xml.attributes['name'], parent_entity: xml.attributes['parentEntity'], attributes: attributes, relationships: relationships) end |