README.md in koine-attributes-0.1.1 vs README.md in koine-attributes-0.1.2
- old
+ new
@@ -8,11 +8,11 @@
[![Coverage Status](https://coveralls.io/repos/github/mjacobus/koine-attributes/badge.svg?branch=master)](https://coveralls.io/github/mjacobus/koine-attributes?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mjacobus/koine-attributes/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mjacobus/koine-attributes/?branch=master)
[![Code Climate](https://codeclimate.com/github/mjacobus/koine-attributes/badges/gpa.svg)](https://codeclimate.com/github/mjacobus/koine-attributes)
[![Issue Count](https://codeclimate.com/github/mjacobus/koine-attributes/badges/issue_count.svg)](https://codeclimate.com/github/mjacobus/koine-attributes)
-[![Gem Version](https://badge.fury.io/rb/koine-attributes.svg)](https://badge.fury.io/rb/koine-command_bus)
+[![Gem Version](https://badge.fury.io/rb/koine-attributes.svg)](https://badge.fury.io/rb/koine-attributes)
[![Dependency Status](https://gemnasium.com/badges/github.com/mjacobus/koine-attributes.svg)](https://gemnasium.com/github.com/mjacobus/koine-attributes)
## Installation
Add this line to your application's Gemfile:
@@ -31,10 +31,12 @@
## Usage
```ruby
class Person
+ include Koine::Attributes
+
attributes do
attribute :name, :string
attribute :birthday, :date
# or
@@ -63,10 +65,12 @@
Also, a constructor can be created by the API
```ruby
class Person
+ include Koine::Attributes
+
attributes initializer: true do
attribute :name, :string
attribute :birthday, :date
end
end
@@ -79,10 +83,12 @@
You can disable strict mode
```ruby
class Person
+ include Koine::Attributes
+
attributes initializer: { strict: false } do
attribute :name, :string
attribute :birthday, :date
end
end
@@ -133,9 +139,25 @@
product.price = { currency: 'USD', value: 100 }
# or
product.price = "100 USD"
+```
+
+### Value objects
+
+```ruby
+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)
```
### Standard types
```ruby