README.md in moosex-0.0.4 vs README.md in moosex-0.0.5

- old
+ new

@@ -38,11 +38,11 @@ class Baz include MooseX has :bam, { - :is => :ro, + :is => :ro, # read-only, you should specify in new only :isa => lambda {|x| # you should add your own validator raise 'x should be less than 100' if x > 100 }, :required => true, :predicate => true, # add has_bam? method, ask if the attribute is unset @@ -65,15 +65,34 @@ :predicate => :can_haz_c?, # custom predicate :clearer => "desintegrate_c", # force coerce to symbol } end + class Target + def method_x + 1024 + end + end + + class Proxy + include MooseX + + has :target, { + :is => :ro, + :default => lambda { Target.new() }, + :handles => { + :my_method_x => :method_x,# create my_method_x in Proxy + }, # this will delegate to @target.method_x + } + end + # now you have a generic constructor p1 = Point.new # x and y will be 0 p2 = Point.new( :x => 5 ) # y will be 0 p3 = Point.new( :x => 5, :y => 4) foo = Foo.new( :bar => 123 ) # without bar will raise exception baz = Baz.new( :bam => 99 ) # if bam > 100 will raise exception + Proxy.new.my_method_x # will call method_x in target, return 1024 ``` ## Installation Add this line to your application's Gemfile: