Class: BigDoor::ResourceWithParent
- Defined in:
- lib/big_door/resource_with_parent.rb
Overview
This module provides Resource class with Parent
Direct Known Subclasses
Instance Method Summary collapse
-
#end_point ⇒ Object
Calculates Resource object API end point from its class name using parent_end_point and parent_id_attr (possibly overriden in child classes).
-
#parent_end_point ⇒ Object
Gives default base parent_end_point for object.
-
#parent_id_attr ⇒ Object
Gives default parent_id attribute name for object.
Methods inherited from Resource
all, #delete, end_point, end_point_from_classname, #get_id, #initialize, #instance_to_payload, #load, #response_to_instance, #save
Constructor Details
This class inherits a constructor from BigDoor::Resource
Instance Method Details
#end_point ⇒ Object
Calculates Resource object API end point from its class name using parent_end_point and parent_id_attr (possibly overriden in child classes)
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/big_door/resource_with_parent.rb', line 12 def end_point $log.debug("parent_end_point = #{parent_end_point}") $log.debug("parent_id_attr = #{parent_id_attr}") $log.debug("parent_id_attr value = #{self.instance_eval("self.#{parent_id_attr}")}") # FIXME if parent_id_attr empty # FIXME if no self.#{parent_id_attr} ep = sprintf "%s/%s/%s", parent_end_point, self.instance_eval("self.#{parent_id_attr}"), Resource.end_point_from_classname( self.class.name ) ep end |
#parent_end_point ⇒ Object
Gives default base parent_end_point for object. Can be overriden in inherited classes.
30 31 32 33 |
# File 'lib/big_door/resource_with_parent.rb', line 30 def parent_end_point resource_name = Resource.end_point_from_classname( self.class.name ) "#{resource_name}_collection" end |
#parent_id_attr ⇒ Object
Gives default parent_id attribute name for object. Can be overriden in inherited classes.
39 40 41 |
# File 'lib/big_door/resource_with_parent.rb', line 39 def parent_id_attr "#{parent_end_point}_id" end |