Algebrick - bump to version 0.1.2
Call #type_def
directly
Algebraic::DSL
module does not have to be extended into your module to access #type_def
any more.
It can be now called directly with passing the base module to define the new types.
Algebrick.type_def self do
boolean === TrueClass | FalseClass
end
Wrong field
When wrong field is accessed it will now raise an ArgummentError
instead of silently returning nil
Algebrick.type_def(self) do
tree === empty | tree(value: Integer, left: tree, right: tree)
end
Tree[1, Empty, Empty][:middle] rescue $!
# => #<ArgumentError: uknown field :middle>
Access fields by method
Call #add_all_field_method_accessors
on a product type to get access to fields by methods.
Tree.add_all_field_method_accessors
Tree[1, Empty, Empty].left # => Empty
There are also methods add_field_method_accessor
and add_field_method_accessors
to add accessor/s selectively.