Sha256: a4c627ab0cf7cc82227bb1baea4a969d1f70a59843c54c4c5d4d43103e1149d6

Contents?: true

Size: 759 Bytes

Versions: 28

Compression:

Stored size: 759 Bytes

Contents

module Cms
  module Behaviors
    module Categorizing
      def self.included(model_class)
        model_class.extend(MacroMethods)
      end
      module MacroMethods      
        def belongs_to_category?
          !!@belongs_to_category
        end
        def belongs_to_category
          @belongs_to_category = true
          extend ClassMethods
          include InstanceMethods
          
          belongs_to :category, :class_name => 'Cms::Category'
          
          scope :in_category, lambda{|cat| {:conditions => ["category_id = ?", cat.id]}}
          
        end
      end
      module ClassMethods
      end
      module InstanceMethods
        def category_name
          category && category.name
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
browsercms-artirix-4.0.4 lib/cms/behaviors/categorizing.rb
browsercms-artirix-4.0.3.3 lib/cms/behaviors/categorizing.rb
browsercms-artirix-4.0.3.2 lib/cms/behaviors/categorizing.rb
browsercms-artirix-4.0.3.1 lib/cms/behaviors/categorizing.rb
browsercms-artirix-4.0.3 lib/cms/behaviors/categorizing.rb
browsercms-artirix-4.0.2 lib/cms/behaviors/categorizing.rb
browsercms-artirix-4.0.1.1 lib/cms/behaviors/categorizing.rb
browsercms-artirix-4.0.0.rc1.art4 lib/cms/behaviors/categorizing.rb
browsercms-4.0.0.rc1 lib/cms/behaviors/categorizing.rb
browsercms-4.0.0.beta lib/cms/behaviors/categorizing.rb
browsercms-4.0.0.alpha lib/cms/behaviors/categorizing.rb
browsercms-3.5.7 lib/cms/behaviors/categorizing.rb
browsercms-3.5.6 lib/cms/behaviors/categorizing.rb
browsercms-3.5.5 lib/cms/behaviors/categorizing.rb
browsercms-3.5.4 lib/cms/behaviors/categorizing.rb
browsercms-3.5.3 lib/cms/behaviors/categorizing.rb
browsercms-3.5.2 lib/cms/behaviors/categorizing.rb
browsercms-3.5.1 lib/cms/behaviors/categorizing.rb
browsercms-3.5.0 lib/cms/behaviors/categorizing.rb
browsercms-3.5.0.rc3 lib/cms/behaviors/categorizing.rb