Custom attribute writer method checking allowed values (enum).
 @param [Object] audio_format Object to be assigned
180190
def audio_format=(audio_format)
      validator = EnumAttributeValidator.new('String', ["pcm_s24le", "pcm_s16le"])
      unless validator.valid?(audio_format)
        fail ArgumentError, "invalid value for 'audio_format', must be one of #{validator.allowable_values}."
      end
      @audio_format = audio_format
    end
1033452
def h264_tune=(h264_tune)
      validator = EnumAttributeValidator.new('String', ["film", "animation", "grain", "psnr", "ssim", "fastdecode", "zerolatency"])
      unless validator.valid?(h264_tune)
        fail ArgumentError, "invalid value for 'h264_tune', must be one of #{validator.allowable_values}."
      end
      @h264_tune = h264_tune
    end
1299558
def aspect_mode=(aspect_mode)
      validator = EnumAttributeValidator.new('String', ["preserve", "constrain", "letterbox", "pad", "fill (crop)", "stretch", "center"])
      unless validator.valid?(aspect_mode)
        fail ArgumentError, "invalid value for 'aspect_mode', must be one of #{validator.allowable_values}."
      end
      @aspect_mode = aspect_mode
    end
514385
def sanitize_allow(value, args=''):
    '''
    
    '''
    if isinstance(value, basestring):
        allowed_tags = []
        allowed_attributes = []
        allowed_styles = []
        
        args = args.strip().split(';')
        if len(args) > 0:
            allowed_tags = [tag.strip() for tag in args[0].split(',')]
        if len(args) > 1:
            allowed_attributes = [attr.strip() for attr in args[1].split(',')]
            
        value = bleach.clean(value, tags=allowed_tags,
                             attributes=allowed_attributes, strip=True)
    return value
892167
def format_filter_value(value)
      return value if value.is_a?(Array) || value.is_a?(Hash)
      return nil if value.blank?

      value = value.to_s
      case value
        when 'true', 'TRUE' then true
        when 'false', 'FALSE' then false
        else
          value
      end
    end
1066144
def valid?
      sort_validator = EnumAttributeValidator.new('String', ["COUNT", "INDEX"])
      return false unless sort_validator.valid?(@sort)
      method_validator = EnumAttributeValidator.new('String', ["ENUM", "FC"])
      return false unless method_validator.valid?(@method)
      return true
    end
1075466
def style=(style)
      validator = EnumAttributeValidator.new('String', ["Default", "Solid", "ShortDash", "ShortDot", "ShortDashDot", "ShortDashDotDot", "Dot", "Dash", "LongDash", "DashDot", "LongDashDot", "LongDashDotDot"])
      if style.to_i == 0
        unless validator.valid?(style)
          raise ArgumentError, "invalid value for 'style', must be one of #{validator.allowable_values}."
        end
        @style = style
      else
        @style = validator.allowable_values[style.to_i]
      end
    end
532688
def _setup_validation(self, sender, **kwargs):
        
        att_name = self.get_attname()
        private_att_name = '_enum_%s' % att_name
        enum = self.enum

        def set_enum(self, new_value):
            if hasattr(self, private_att_name):
                # Fetch previous value from private enum attribute.
                old_value = getattr(self, private_att_name)
            else:
                # First setattr no previous value on instance.
                old_value = new_value
            # Update private enum attribute with new value
            setattr(self, private_att_name, new_value)
            self.__dict__[att_name] = new_value
            # Run validation for new value.
            validators.validate_valid_transition(enum, old_value, new_value)

        def get_enum(self):
            return getattr(self, private_att_name)

        def delete_enum(self):
            self.__dict__[att_name] = None
            return setattr(self, private_att_name, None)

        if not sender._meta.abstract:
            setattr(sender, att_name, property(get_enum, set_enum, delete_enum))
714209
def write_attr(attr_name, value, to_call = nil)
      self[attr_name] = value && to_call ? value.__send__(to_call) : value
    end
87446
def create_string(value)
      if (values = current_attributes[:values]) &&
        (values = values.sort_by {|e| e.to_s})
          value = auto_alias_value(values, value)
          validate_enum_values(values, value)
      end
      value
    end
1107760
def valid?
      return false if @sync.nil?
      sync_validator = EnumAttributeValidator.new('String', ["true", "false"])
      return false unless sync_validator.valid?(@sync)
      return true
    end
1197519
def eac3_bitstream_mode=(eac3_bitstream_mode)
      validator = EnumAttributeValidator.new('String', ["m0", "m1", "m2", "m3", "m4", "m5", "m6", "m7"])
      unless validator.valid?(eac3_bitstream_mode)
        fail ArgumentError, "invalid value for 'eac3_bitstream_mode', must be one of #{validator.allowable_values}."
      end
      @eac3_bitstream_mode = eac3_bitstream_mode
    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
7924
def valid?
      return false if @status.nil?
      status_validator = EnumAttributeValidator.new('String', ['error'])
      return false unless status_validator.valid?(@status)
      return false if @errors.nil?
      true
    end
1020889
def attr_writer(*methods)
      methods.each do |method|
        define_method("#{method}=") do |value|
          instance_variable_set(:"@#{method}", value)
        end
      end
    end
43468
def eac3_room_type=(eac3_room_type)
      validator = EnumAttributeValidator.new('String', ["m0", "m1", "m2"])
      unless validator.valid?(eac3_room_type)
        fail ArgumentError, "invalid value for 'eac3_room_type', must be one of #{validator.allowable_values}."
      end
      @eac3_room_type = eac3_room_type
    end
424102
def h264_level=(h264_level)
      validator = EnumAttributeValidator.new('String', ["1.0", "1b", "1.1", "1.2", "1.3", "2.0", "2.1", "2.2", "3.0", "3.1", "3.2", "4.0", "4.1", "4.2", "5.0", "5.1"])
      unless validator.valid?(h264_level)
        fail ArgumentError, "invalid value for 'h264_level', must be one of #{validator.allowable_values}."
      end
      @h264_level = h264_level
    end