Class: Fabrication::Transform

Inherits:
Object
  • Object
show all
Defined in:
lib/fabrication/transform.rb

Class Method Summary collapse

Class Method Details

.apply_to(schematic, attributes_hash) ⇒ Object



4
5
6
7
# File 'lib/fabrication/transform.rb', line 4

def apply_to(schematic, attributes_hash)
  Fabrication.manager.load_definitions if Fabrication.manager.empty?
  attributes_hash.inject({}) { |h, (k, v)| h.update(k => apply_transform(schematic, k, v)) }
end

.clear_allObject



9
10
11
12
# File 'lib/fabrication/transform.rb', line 9

def clear_all
  @transforms = nil
  @overrides = nil
end

.define(attribute, transform) ⇒ Object



14
15
16
# File 'lib/fabrication/transform.rb', line 14

def define(attribute, transform)
  transforms[attribute] = transform
end

.only_for(schematic, attribute, transform) ⇒ Object



18
19
20
# File 'lib/fabrication/transform.rb', line 18

def only_for(schematic, attribute, transform)
  overrides[schematic] = (overrides[schematic] || {}).merge!(attribute => transform)
end