Module: Adva::Categorizable

Extended by:
Categorizable
Included in:
Categorizable
Defined in:
lib/adva/active_record/categorizable.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#categorizableObject



3
4
5
6
7
8
9
10
# File 'lib/adva/active_record/categorizable.rb', line 3

def categorizable
  unless categorizable?
    Category.categorizable(name.underscore.pluralize.to_sym)
    has_many :categories, :through => :categorizations, :as => :categorizable
    accepts_nested_attributes_for :categorizations, :allow_destroy => true
    extend ClassMethods
  end
end

#categorizable?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/adva/active_record/categorizable.rb', line 12

def categorizable?
  singleton_class.included_modules.include?(ClassMethods)
end