Sha256: cc0f7ae9f0f275d4948185ced35d668b618118401e941ccb43d8ddaa4df93a1c
Contents?: true
Size: 989 Bytes
Versions: 32
Compression:
Stored size: 989 Bytes
Contents
module PushType module Nestable extend ActiveSupport::Concern def child_nodes self.class.child_nodes end def custom_child_order? self.class.child_order.present? end def sortable? !custom_child_order? end def descendable? !child_nodes.empty? end def children return super() unless custom_child_order? super.reorder(self.class.child_order) end module ClassMethods attr_reader :child_order def child_nodes types = @child_nodes || PushType.config.root_nodes PushType.subclasses_from_list(:node, types) end def has_child_nodes(*args) if args.last.is_a? Hash opts = args.pop @child_order = case opts[:order] when :blog then ['published_at DESC', 'created_at DESC'] else opts[:order] end else @child_order = nil end @child_nodes = args end end end end
Version data entries
32 entries across 32 versions & 1 rubygems