Sha256: ca843ab491e310b0be22535b50d5d288187ce89fe312057e0bd172741e5faa8a

Contents?: true

Size: 406 Bytes

Versions: 5

Compression:

Stored size: 406 Bytes

Contents

class FunctionField < Field
  def strip_nil?
    true
  end
  
  def default_input_type
    nil
  end

  def validate(record, errors)
    # noop
  end

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

  def untypecast(value, record)
    nil
  end

  def from_json(value, record)
    nil
  end
end

Field::TYPES['function'] = FunctionField

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yodel-0.0.7 lib/yodel/models/core/fields/function_field.rb
yodel-0.0.4 lib/yodel/models/core/fields/function_field.rb
yodel-0.0.3 lib/yodel/models/core/fields/function_field.rb
yodel-0.0.2 lib/yodel/models/core/fields/function_field.rb
yodel-0.0.1 lib/yodel/models/core/fields/function_field.rb