README.md in moosex-0.0.2 vs README.md in moosex-0.0.3

- old
+ new

@@ -1,8 +1,8 @@ # MooseX -A postmodern object system for Ruby +A postmodern object system for Ruby [![Build Status](https://travis-ci.org/peczenyj/MooseX.png)](https://travis-ci.org/peczenyj/MooseX) ```ruby require 'moosex' class Point @@ -30,11 +30,11 @@ include MooseX has :bar, { :is => :rwp, # read-write-private (private setter) :isa => Integer, - :required => true # you should require in the constructor + :required => true, # you should require in the constructor } end class Baz include MooseX @@ -42,13 +42,31 @@ has :bam, { :is => :ro, :isa => lambda {|x| # you should add your own validator raise 'x should be less than 100' if x > 100 }, - :required => true + :required => true, + :predicate => true, # add has_bam? method, ask if the attribute is unset + :clearer => true, # add reset_bam! method, unset the attribute } end + + class Lol + include MooseX + + has [:a, :b], { # define attributes a and b + :is => :ro, # with same set of properties + :default => 0, + } + + has :c => { # alternative syntax to be + :is => :ro, # more similar to Moo/Moose + :default => 1, + :predicate => :can_haz_c?, # custom predicate + :clearer => "desintegrate_c", # force coerce to symbol + } + 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)