module CustomFields::Types::Boolean::Target::ClassMethods

Public Instance Methods

apply_boolean_custom_field(klass, rule) click to toggle source

Adds a boolean field. It can not be required.

@param [ Class ] klass The class to modify @param [ Hash ] rule It contains the name of the field.

# File lib/custom_fields/types/boolean.rb, line 17
def apply_boolean_custom_field(klass, rule)
  klass.field rule['name'], type: 'Boolean', localize: rule['localized'] || false,
                            default: rule['default'].nil? ? false : rule['default']
end
boolean_attribute_get(instance, name) click to toggle source

Build a hash storing the boolean value (true / false) for a boolean custom field of an instance.

@param [ Object ] instance An instance of the class enhanced by the custom_fields @param [ String ] name The name of the boolean custom field

@return [ Hash ] field name => true / false

# File lib/custom_fields/types/boolean.rb, line 30
def boolean_attribute_get(instance, name)
  default_attribute_get(instance, name)
end
boolean_attribute_set(instance, name, attributes) click to toggle source

Set the value for the instance and the boolean field specified by the 2 params.

@param [ Object ] instance An instance of the class enhanced by the custom_fields @param [ String ] name The name of the boolean custom field @param [ Hash ] attributes The attributes used to fetch the values

# File lib/custom_fields/types/boolean.rb, line 41
def boolean_attribute_set(instance, name, attributes)
  default_attribute_set(instance, name, attributes)
end