Module: TinySweeper::ClassMethods
- Defined in:
- lib/tiny_sweeper.rb
Instance Method Summary collapse
Instance Method Details
#sweep(field_name, &sweeper) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/tiny_sweeper.rb', line 3 def sweep(field_name, &sweeper) stop_if_we_have_seen_this_before!(field_name) overrides_module.module_eval do define_method("#{field_name}=") do |value| if value super(sweeper.call(value)) else super(value) end end end end |
#sweep_up!(instance) ⇒ Object
17 18 19 20 21 |
# File 'lib/tiny_sweeper.rb', line 17 def sweep_up!(instance) @swept_fields.each do |field| instance.send("#{field}=", instance.send(field)) end end |