Class: FunctionField

Inherits:
Field
  • Object
show all
Defined in:
lib/yodel/models/core/fields/function_field.rb

Constant Summary

Constants inherited from Field

Field::TYPES

Instance Attribute Summary

Attributes inherited from Field

#name, #options

Instance Method Summary collapse

Methods inherited from Field

#display?, field_from_type, from_options, #include_in_search_keywords?, #index?, #inherited?, #initialize, #method_missing, #numeric?, #required?, #searchable?, #to_json, #to_str, #unique?

Constructor Details

This class inherits a constructor from Field

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Field

Instance Method Details

#default_input_typeObject



6
7
8
# File 'lib/yodel/models/core/fields/function_field.rb', line 6

def default_input_type
  nil
end

#from_json(value, record) ⇒ Object



23
24
25
# File 'lib/yodel/models/core/fields/function_field.rb', line 23

def from_json(value, record)
  nil
end

#strip_nil?Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/yodel/models/core/fields/function_field.rb', line 2

def strip_nil?
  true
end

#typecast(value, record) ⇒ Object



14
15
16
17
# File 'lib/yodel/models/core/fields/function_field.rb', line 14

def typecast(value, record)
  compiled_fn = Function.new(@options['fn'])
  compiled_fn.execute(record)
end

#untypecast(value, record) ⇒ Object



19
20
21
# File 'lib/yodel/models/core/fields/function_field.rb', line 19

def untypecast(value, record)
  nil
end

#validate(record, errors) ⇒ Object



10
11
12
# File 'lib/yodel/models/core/fields/function_field.rb', line 10

def validate(record, errors)
  # noop
end