Module: CustomFields::Types::Text::Target::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#apply_text_custom_field(klass, rule) ⇒ Object

Adds a text field (simply a string field)

Parameters:

  • klass (Class)

    The class to modify

  • rule (Hash)

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



23
24
25
# File 'lib/custom_fields/types/text.rb', line 23

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

#text_attribute_get(instance, name) ⇒ Hash

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

Parameters:

  • instance (Object)

    An instance of the class enhanced by the custom_fields

  • name (String)

    The name of the string custom field

Returns:

  • (Hash)

    field name => raw value



35
36
37
# File 'lib/custom_fields/types/text.rb', line 35

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

#text_attribute_set(instance, name, attributes) ⇒ Object

Set the value for the instance and the text 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 text custom field

  • attributes (Hash)

    The attributes used to fetch the values



46
47
48
# File 'lib/custom_fields/types/text.rb', line 46

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