Class: Coupler::Models::Transformation
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- Coupler::Models::Transformation
show all
- Includes:
- CommonModel
- Defined in:
- lib/coupler/models/transformation.rb
Instance Method Summary
collapse
#before_save, #before_update, included, #save!, #touch!
Instance Method Details
#deletable? ⇒ Boolean
38
39
40
41
|
# File 'lib/coupler/models/transformation.rb', line 38
def deletable?
position == self.class.max(:position) &&
(result_field.nil? || !result_field.is_generated || result_field.scenarios_dataset.count == 0)
end
|
#field_changes ⇒ Object
21
22
23
|
# File 'lib/coupler/models/transformation.rb', line 21
def field_changes
transformer.field_changes(source_field)
end
|
#original_result_field_attributes ⇒ Object
NOTE: The fact that the aliased name doesn’t have an = at the end is important. Ruby methods with names that have = at the end always return the RHS value, regardless of what the method actually returns. The only way to grab the associated object that gets created from the nested attributes methods is by fetching the return value.
31
|
# File 'lib/coupler/models/transformation.rb', line 31
alias :original_result_field_attributes :result_field_attributes=
|
#result_field_attributes=(h) ⇒ Object
32
33
34
35
36
|
# File 'lib/coupler/models/transformation.rb', line 32
def result_field_attributes=(h)
@staged_result_field = self.original_result_field_attributes(h.merge({
:is_generated => true
}))
end
|
14
15
16
17
18
19
|
# File 'lib/coupler/models/transformation.rb', line 14
def transform(data)
transformer.transform(data, {
:in => source_field.name.to_sym,
:out => result_field.name.to_sym
})
end
|