require 'traits'
#
# pre and post hooks can be passed a proc or the name of a method, the arity is
# detected and the proc/method sent either the value, or the name/value pair
#

class C
  HOOK_A = lambda{|value| puts "HOOK_A : #{ value }"}
  HOOK_B = lambda{|name, value| puts "HOOK_B : #{ name } = #{ value }"}

  def hook_a value
    puts "hook_a : #{ value }"
  end
  def hook_b name, value
    puts "hook_b : #{ name } = #{ value }"
  end

  trait 'x', 'pre' => HOOK_A, 'post' => 'hook_b'
  trait 'y', 'pre' => HOOK_B, 'post' => 'hook_a'
end

c = C::new
c.x = 42
c.y = 'forty-two'
