Module: CustomFields::Types::Color::Target::ClassMethods

Defined in:
lib/custom_fields/types/color.rb

Instance Method Summary collapse

Instance Method Details

#apply_color_custom_field(klass, rule) ⇒ Object

Add a color field

Parameters:

  • klass (Class)

    The class to modify

  • rule (Hash)

    It contains the name of the field and if it is required or not



17
18
19
# File 'lib/custom_fields/types/color.rb', line 17

def apply_color_custom_field(klass, rule)
  apply_custom_field(klass, rule)
end

#color_attribute_get(instance, name) ⇒ Hash

Build a hash storing the raw value for a color custom field of an instance.

Parameters:

  • instance (Object)

    An instance of the class enhanced by the custom_fields

  • name (String)

    The name of the color custom field

Returns:

  • (Hash)

    field name => raw value



29
30
31
# File 'lib/custom_fields/types/color.rb', line 29

def color_attribute_get(instance, name)
  default_attribute_get(instance, name)
end

#color_attribute_set(instance, name, attributes) ⇒ Object

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

Parameters:

  • instance (Object)

    An instance of the class enhanced by the custom_fields

  • name (String)

    The name of the color custom field

  • attributes (Hash)

    The attributes used to fetch the values



40
41
42
# File 'lib/custom_fields/types/color.rb', line 40

def color_attribute_set(instance, name, attributes)
  default_attribute_set(instance, name, attributes)
end