Sha256: 83b257c49f9944db6d3d1e573ce095ea13f41753448f8ca7a45c3c9d99695185

Contents?: true

Size: 894 Bytes

Versions: 21

Compression:

Stored size: 894 Bytes

Contents

module Model
  module MongoDb
    module Product
      module Keywords
        extend ActiveSupport::Concern 
        
        included do
          field :with_keywords, type: Boolean
          field :min_number_of_keywords, type: Integer
          field :max_number_of_keywords, type: Integer
          
          attr_accessible :with_keywords, :min_number_of_keywords, :max_number_of_keywords
          
          validate :keyword_settings_present
        
          private
          
          def keyword_settings_present
            return unless self.with_keywords.present?
            
            [:min_number_of_keywords, :max_number_of_keywords].each do |attribute|
              if self.send(attribute).blank?
                errors[attribute] << I18n.t('activerecord.errors.messages.blank')
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
voluntary-0.7.1 lib/model/mongo_db/product/keywords.rb
voluntary-0.7.0 lib/model/mongo_db/product/keywords.rb
voluntary-0.6.0 lib/model/mongo_db/product/keywords.rb
voluntary-0.5.2 lib/model/mongo_db/product/keywords.rb
voluntary-0.5.1 lib/model/mongo_db/product/keywords.rb
voluntary-0.5.0 lib/model/mongo_db/product/keywords.rb
voluntary-0.4.0 lib/model/mongo_db/product/keywords.rb
voluntary-0.3.0 lib/model/mongo_db/product/keywords.rb
voluntary-0.2.4 lib/model/mongo_db/product/keywords.rb
voluntary-0.2.3 lib/model/mongo_db/product/keywords.rb
voluntary-0.2.2 lib/model/mongo_db/product/keywords.rb
voluntary-0.2.1 lib/model/mongo_db/product/keywords.rb
voluntary-0.2.0 lib/model/mongo_db/product/keywords.rb
voluntary-0.1.0 lib/model/mongo_db/product/keywords.rb
voluntary-0.1.0.rc4 lib/model/mongo_db/product/keywords.rb
voluntary-0.1.0.rc3 lib/model/mongo_db/product/keywords.rb
voluntary-0.1.0.rc2 lib/model/mongo_db/product/keywords.rb
voluntary-0.1.0.rc1 lib/model/mongo_db/product/keywords.rb
voluntary-0.0.3 lib/model/mongo_db/product/keywords.rb
voluntary-0.0.2 lib/model/mongo_db/product/keywords.rb