Sha256: 124a648057822e9d776b71cea64d309ce29ebb47d18fd7f638b8fa5a9eb61793

Contents?: true

Size: 358 Bytes

Versions: 7

Compression:

Stored size: 358 Bytes

Contents

require 'after_do'

class MyClass
  attr_accessor :value
end

MyClass.extend AfterDo
MyClass.after :value= do |*, obj| puts 'after: ' + obj.value.to_s end
MyClass.before :value= do |*, obj| puts 'before: ' + obj.value.to_s end

m = MyClass.new
m.value = 'Hello'
m.value = 'new value'

# Output is:
# before:
# after: Hello
# before: Hello
# after: new value

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
after_do-0.4.0 samples/before.rb
after_do-0.3.1 samples/before.rb
after_do-0.3.0 samples/before.rb
after_do-0.2.3 samples/before.rb
after_do-0.2.2 samples/before.rb
after_do-0.2.1 samples/before.rb
after_do-0.2.0 samples/before.rb