Sha256: 8a7f286795ccfba8903a41f6aed2e3934e6b70ac8417524c728c5bfe027d92c7

Contents?: true

Size: 897 Bytes

Versions: 3

Compression:

Stored size: 897 Bytes

Contents

module AbAdmin
  module Models
    module Structure
      extend ActiveSupport::Concern

      included do
        include AbAdmin::Concerns::Headerable
        include AbAdmin::Concerns::NestedSet

        enumerated_attribute :structure_type, :id_attribute => :kind
        enumerated_attribute :position_type, :id_attribute => :position

        validates_presence_of :title
        validates_numericality_of :position, :only_integer => true

        has_one :static_page, :dependent => :destroy
        has_many :visible_children, :class_name => name, :foreign_key => 'parent_id', :conditions => {:is_visible => true}

        scope :visible, where(:is_visible => true)
        scope :with_kind, proc {|structure_type| where(:kind => structure_type.id) }
        scope :with_position, proc {|position_type| where(:position => position_type.id).order('lft DESC') }
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ab_admin-0.1.2 lib/ab_admin/models/structure.rb
ab_admin-0.1.1 lib/ab_admin/models/structure.rb
ab_admin-0.1.0 lib/ab_admin/models/structure.rb