Module: ITGlue::Asset::Relatable
- Included in:
- Base
- Defined in:
- lib/itglue/asset/base/relatable.rb
Instance Method Summary collapse
Instance Method Details
#children(*child_types) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/itglue/asset/base/relatable.rb', line 14 def children(*child_types) child_types.each do |child_type| define_method child_type do | = {}| "ITGlue::#{child_type.to_s.classify}".constantize.get_nested(self, ) end end end |
#parent(parent_type, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/itglue/asset/base/relatable.rb', line 4 def parent(parent_type, = {}) @parent_type = parent_type.to_s.pluralize unless [:no_association] define_method parent_type do parent_id = self.send("#{parent_type}_id") "ITGlue::#{parent_type.to_s.classify}".constantize.find(parent_id) end end end |