Module: Monarchy::ActsAsResource::InstanceMethods
- Defined in:
- lib/monarchy/acts_as_resource.rb
Overview
rubocop:enable MethodLength
Instance Method Summary collapse
Instance Method Details
#children ⇒ Object
60 61 62 |
# File 'lib/monarchy/acts_as_resource.rb', line 60 def children @children ||= children_resources end |
#children=(array) ⇒ Object
64 65 66 67 68 |
# File 'lib/monarchy/acts_as_resource.rb', line 64 def children=(array) hierarchy.update(children: hierarchies_for(array)) if hierarchy @children = array end |
#parent ⇒ Object
48 49 50 |
# File 'lib/monarchy/acts_as_resource.rb', line 48 def parent @parent = hierarchy.try(:parent).try(:resource) || @parent end |
#parent=(resource) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/monarchy/acts_as_resource.rb', line 52 def parent=(resource) if hierarchy hierarchy.update(parent: resource.try(:hierarchy)) else @parent = resource end end |