lib/koine/attributes.rb in koine-attributes-0.1.1 vs lib/koine/attributes.rb in koine-attributes-0.1.2

- old
+ new

@@ -4,10 +4,12 @@ # provides the following API # # @example using attributes # class Person +# include Koine::Attributes +# # attributes do # attribute :name, :string # attribute :birthday, :date # # # or @@ -32,10 +34,12 @@ # end # # @example Constructor for attributes # # class Person +# include Koine::Attributes +# # attributes initializer: true do # attribute :name, :string # attribute :birthday, :date # end # end @@ -46,10 +50,12 @@ # person = Person.new(name: 'John Doe', birthday: '2001-01-31', foo: :bar) # # @example Constructor for attributes withouth strict mode # # class Person +# include Koine::Attributes +# # attributes initializer: { strict: false } do # attribute :name, :string # attribute :birthday, :date # end # end @@ -58,10 +64,12 @@ # person = Person.new(name: 'John Doe', birthday: '2001-01-31', foo: :bar) # # @example Override constructor # # class Person +# include Koine::Attributes +# # attr_reader :foo # # attributes initializer: true do # attribute :name, :string # attribute :birthday, :date @@ -74,9 +82,22 @@ # end # end # # person = Person.new(name: 'John Doe', birthday: '2001-01-31', foo: :bar) # person.foo # => :bar +# +# @example +# class Location +# include Koine::Attributes +# +# attributes initializer: { freeze: true } do +# attribute :lat, :float +# attribute :lon, :float +# end +# end +# +# location = Location.new(lat: 1, lon: 2) +# new_location = location.with_lon(3) # module Koine module Attributes module Adapter autoload :Boolean, 'koine/attributes/adapter/boolean'