Class: EacRest::Entity
- Inherits:
-
Object
- Object
- EacRest::Entity
- Defined in:
- lib/eac_rest/entity.rb
Class Method Summary collapse
Instance Method Summary collapse
- #child_entity(entity_class, data_or_id, options = {}) ⇒ EacRest::Entity
- #data ⇒ Hash
- #data_from_id ⇒ Hash
- #data_or_id_data? ⇒ Boolean
- #id ⇒ Object
- #id_from_data ⇒ Object
- #parent_entity ⇒ EacRest::Entity?
Class Method Details
.from_array_data(api, array_data, *args) ⇒ Object
16 17 18 |
# File 'lib/eac_rest/entity.rb', line 16 def from_array_data(api, array_data, *args) array_data.map { |item_data| new(api, item_data, *args) } end |
Instance Method Details
#child_entity(entity_class, data_or_id, options = {}) ⇒ EacRest::Entity
24 25 26 |
# File 'lib/eac_rest/entity.rb', line 24 def child_entity(entity_class, data_or_id, = {}) api.entity(entity_class, data_or_id, .merge(OPTION_PARENT => self)) end |
#data ⇒ Hash
29 30 31 32 33 34 35 |
# File 'lib/eac_rest/entity.rb', line 29 def data if internal_data.blank? self.internal_data = data_or_id_data? ? data_or_id : data_from_id end internal_data end |
#data_from_id ⇒ Hash
43 44 45 |
# File 'lib/eac_rest/entity.rb', line 43 def data_from_id raise_abstract_method __method__ end |
#data_or_id_data? ⇒ Boolean
38 39 40 |
# File 'lib/eac_rest/entity.rb', line 38 def data_or_id_data? data_or_id.is_a?(::Hash) end |
#id ⇒ Object
48 49 50 |
# File 'lib/eac_rest/entity.rb', line 48 def id data_or_id_data? ? id_from_data : data_or_id end |
#id_from_data ⇒ Object
53 54 55 |
# File 'lib/eac_rest/entity.rb', line 53 def id_from_data raise_abstract_method __method__ end |
#parent_entity ⇒ EacRest::Entity?
58 59 60 |
# File 'lib/eac_rest/entity.rb', line 58 def parent_entity [OPTION_PARENT] end |