Class: AliasField
- Inherits:
-
Field
show all
- Defined in:
- lib/yodel/models/core/fields/alias_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
9
10
11
|
# File 'lib/yodel/models/core/fields/alias_field.rb', line 9
def default_input_type
nil
end
|
#from_json(value, record) ⇒ Object
27
28
29
|
# File 'lib/yodel/models/core/fields/alias_field.rb', line 27
def from_json(value, record)
nil
end
|
#strip_nil? ⇒ Boolean
FIXME: assignments don’t work; alias = val won’t be saved FIXME: changes to the original value aren’t observed; original = val_1, alias => val_1; original = val_2; alias => val_1
5
6
7
|
# File 'lib/yodel/models/core/fields/alias_field.rb', line 5
def strip_nil?
true
end
|
#typecast(value, record) ⇒ Object
17
18
19
20
21
|
# File 'lib/yodel/models/core/fields/alias_field.rb', line 17
def typecast(value, record)
field_name = @options['of'].to_s
raise InvalidField, "Alias fields must have a from property" if field_name.blank?
record.get(field_name)
end
|
#untypecast(value, record) ⇒ Object
23
24
25
|
# File 'lib/yodel/models/core/fields/alias_field.rb', line 23
def untypecast(value, record)
nil
end
|
#validate(record, errors) ⇒ Object
13
14
15
|
# File 'lib/yodel/models/core/fields/alias_field.rb', line 13
def validate(record, errors)
end
|