Sha256: 01ca5ad28c845dfde0945e7727fb73f7ba5d31aa6441c87585ac96ebd690a615

Contents?: true

Size: 578 Bytes

Versions: 2

Compression:

Stored size: 578 Bytes

Contents

require 'aquarium'

class ControllerPoint

  include Aquarium::DSL
end

class CuteA
  attr_accessor :cp

  def initialize
    puts "A initialized"
  end
end

class CuteB < CuteA
  attr_accessor :acp
  def initialize 
    puts "B initialized"
    @acp = CuteA.new
  end
end

include Aquarium::Aspects

@cp = ControllerPoint.new
Aspect.new :before, :invocations_of => :initialize, :for_types => /Cute.*$/, 
:restricting_methods_to => :private_methods do |jp, ob, args|
  puts "jp: #{jp.class} ob: #{ob.cp}"
  ob.cp = @cp
end


ca = CuteA.new
cb = CuteB.new

puts ca.cp
puts cb.cp

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubyneat-0.3.5.alpha.3 foo/foo_aquarium_example.rb
rubyneat-0.3.5.alpha.2 foo/foo_aquarium_example.rb