Module: Estate::Logic::PlainRubyObject::Setup

Defined in:
lib/estate/logic/plain_ruby_object/setup.rb

Class Method Summary collapse

Class Method Details

.call(base) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/estate/logic/plain_ruby_object/setup.rb', line 12

def call(base)
  base.prepend(Module.new do
    extend Estate::Logic::CommonLogic

    define_method("#{config_for(base)[:column_name]}=") do |new_value|
      extend Estate::Logic::CommonLogic
      extend Estate::Logic::PlainRubyObject::SpecificLogic

      validate_state_changes(self, state, new_value)

      super(new_value)
    end
  end)
end