Method: CustomFields::TargetHelpers#custom_fields_methods

Defined in:
lib/custom_fields/target_helpers.rb

#custom_fields_methods(&filter) ⇒ List

Return the list of the getters dynamically based on the custom_fields recipe in order to get the formatted values of the custom fields. If a block is passed, then the list will be filtered accordingly with the following logic. If the block is evaluated as true, then the method will be kept in the list, otherwise it will be removed.

Examples:

# keep all the methods except for the field named 'foo'
project.custom_fields_methods do |rule|
  rule['name] != 'foo'
end

Returns:

  • (List)

    a list of method names (string)



20
21
22
23
24
25
26
27
28
29
# File 'lib/custom_fields/target_helpers.rb', line 20

def custom_fields_methods(&filter)
  self.custom_fields_recipe['rules'].map do |rule|
    method = self.custom_fields_getters_for rule['name'], rule['type']
    if block_given?
      filter.call(rule) ? method : nil
    else
      method
    end
  end.compact.flatten
end