Custom attribute writer method checking allowed values (enum).
 @param [Object] grade Object to be assigned
357556
def grade=(grade)
      validator = EnumAttributeValidator.new('String', ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "PreKindergarten", "Kindergarten", "PostGraduate", "Other"])
      unless validator.valid?(grade)
        fail ArgumentError, "invalid value for 'grade', must be one of #{validator.allowable_values}."
      end
      @grade = grade
    end
86330
def order=(order)
      validator = EnumAttributeValidator.new('String', ["DESC", "ASC"])
      unless validator.valid?(order)
        fail ArgumentError, "invalid value for 'order', must be one of #{validator.allowable_values}."
      end
      @order = order
    end
738585
def margin_measure_type=(margin_measure_type)
      validator = EnumAttributeValidator.new('String', ["Pixels", "Percents", "Millimeters"])
      if margin_measure_type.to_i == 0
        unless validator.valid?(margin_measure_type)
          raise ArgumentError, "invalid value for 'margin_measure_type', must be one of #{validator.allowable_values}."
        end
        @margin_measure_type = margin_measure_type
      else
        @margin_measure_type = validator.allowable_values[margin_measure_type.to_i]
      end
    end
99706
def inventory_alert_type=(inventory_alert_type)
      validator = EnumAttributeValidator.new('String', ["NONE", "LOW_QUANTITY"])
      unless validator.valid?(inventory_alert_type)
        fail ArgumentError, "invalid value for 'inventory_alert_type', must be one of #{validator.allowable_values}."
      end
      @inventory_alert_type = inventory_alert_type
    end
661817
def write_attribute(name, value, options = {})
      if translated?(name)
        options = {:locale => nil}.merge(options)
        access = name.to_s
        unless attributes[access] == value || attribute_changed?(access)
          attribute_will_change! access
        end
        @translated_attributes[access] = value
        the_locale = options[:locale] || Mongoid::Globalize.locale
        self.translations.reject!{ |t| t.new_record? && t.locale != the_locale } if self.class.fallbacks_for_empty_translations
        globalize.write(the_locale, name, value)
      else
        super(name, value)
      end
    end
31612
def type=(type)
      allowed_values = ["lti1"]
      if type && !allowed_values.include?(type)
        fail ArgumentError, "invalid value for 'type', must be one of #{allowed_values}."
      end
      @type = type
    end
662444
def validate(cls, value):
        
        if value not in cls._valid_settings:
            raise ValueError(
                "%s not a member of %s enumeration" % (value, cls.__name__)
            )
1320270
def eac3_lo_ro_surround_mix_level=(eac3_lo_ro_surround_mix_level)
      validator = EnumAttributeValidator.new('String', ["c3", "c4", "c5", "c6", "c7"])
      unless validator.valid?(eac3_lo_ro_surround_mix_level)
        fail ArgumentError, "invalid value for 'eac3_lo_ro_surround_mix_level', must be one of #{validator.allowable_values}."
      end
      @eac3_lo_ro_surround_mix_level = eac3_lo_ro_surround_mix_level
    end
496869
def valid_attribute?(attribute)
    case attr_type_for(attribute)
    when :bool
      validate_class_for(attribute, [TrueClass, FalseClass])
    when :datetime, :datetimecombo
      validate_class_for(attribute, [DateTime])
    when :int
      validate_class_for(attribute, [Fixnum, Float])
    else 
      if @attributes[attribute].blank?
        add_error(attribute, "cannot be blank")
      end
    end
  end
877296
def object_type=(object_type)
      validator = EnumAttributeValidator.new('String', ["ITEM", "DISCOUNT", "CATEGORY", "PLACEHOLDER"])
      unless validator.valid?(object_type)
        fail ArgumentError, "invalid value for 'object_type', must be one of #{validator.allowable_values}."
      end
      @object_type = object_type
    end
858400
def pricing_type=(pricing_type)
      validator = EnumAttributeValidator.new('String', ["FIXED_PRICING", "VARIABLE_PRICING"])
      unless validator.valid?(pricing_type)
        fail ArgumentError, "invalid value for 'pricing_type', must be one of #{validator.allowable_values}."
      end
      @pricing_type = pricing_type
    end
384552
def avcintra_class=(avcintra_class)
      validator = EnumAttributeValidator.new('String', ["50", "100"])
      unless validator.valid?(avcintra_class)
        fail ArgumentError, "invalid value for 'avcintra_class', must be one of #{validator.allowable_values}."
      end
      @avcintra_class = avcintra_class
    end
204760
def gender=(gender)
      validator = EnumAttributeValidator.new('String', ["M", "F", ""])
      unless validator.valid?(gender)
        fail ArgumentError, "invalid value for 'gender', must be one of #{validator.allowable_values}."
      end
      @gender = gender
    end
20261
def bind_inum(column, enum_class, options = {})
      options = { prefix: column }.merge(options)
      options[:prefix] = options[:prefix] ? "#{options[:prefix]}_" : ''

      self.class_eval do
        define_method(column) do
          enum_class.parse(read_attribute(column))
        end

        define_method("#{column}=") do |value|
          enum_class.parse(value).tap do |enum|
            if enum
              write_attribute(column, enum.to_i)
            else
              write_attribute(column, nil)
            end
          end
        end

        enum_class.each do |enum|
          define_method("#{options[:prefix]}#{enum.to_s.underscore}?") do
            enum.eql?(read_attribute(column))
          end
        end
      end
    end
24128
def label(rec, attr, enum = nil)
      if !enum
        enum = rec.class.const_get(attr.to_s.camelize)
        raise(NameError, "wrong constant name #{attr}") if !enum
      end
      if !@enum_map[enum]
        @enum_map[enum] = {}
      end
      value = rec.attributes[attr.to_s]
      if label = @enum_map[enum][value]
        @hit += 1
        label
      else
        member = enum.constants.detect{|m|
                    enum.const_get(m) == value
                 }
        @enum_map[enum][value] = 
            if member
              @out += 1
              rec.class.human_const_name(enum, member)
            else
              @out_of_enum += 1
              '??'
            end
      end
    end
7316
def valid?
      return false if @payment_id.nil?
      return false if @type.nil?
      type_validator = EnumAttributeValidator.new('String', ["FULL", "PARTIAL"])
      return false unless type_validator.valid?(@type)
      return false if @reason.nil?
      return true
    end
435030
def scope=(scope)
      validator = EnumAttributeValidator.new('String', ["OTHER_TAX_SCOPE", "LINE_ITEM", "ORDER"])
      unless validator.valid?(scope)
        fail ArgumentError, "invalid value for 'scope', must be one of #{validator.allowable_values}."
      end
      @scope = scope
    end