active_model_attributes 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d343aa6037f2b68e028b565f125166ed52da7a0
4
- data.tar.gz: 6ba50645e315b6ea90c9e79d6a80dec54f1f0732
3
+ metadata.gz: 3801142572b024c4d211d44e922bd3cc629cc5e9
4
+ data.tar.gz: 87716866f64b6e74c39a3389dbf01afc99542698
5
5
  SHA512:
6
- metadata.gz: 07c010aa7b7c2049460e3cdce9362d3e977effd266976fd4bc0cd08069ebd0b8639feb1b3d9079dcd4a6078bff4eb4389895634f10c4d9e87aa16511414ed079
7
- data.tar.gz: 660e2fcc7935ca4bc3876777680b32609d20e5171c9a59a8f2067b9f2ed2bdc41007eaca73e8ca71be0015990403375770b7d1b2ca0cf96772dd0d035d9d7588
6
+ metadata.gz: cc6310f6b495d46392b84c4e6780857d55fc1b66eaadbbdbeb6f6d92768a9e9b16ee396d0b378fb42c1521c888be971cfabd1eeeed3d3545c20e1e49e2f51d13
7
+ data.tar.gz: c875019c0cb39c14d7fb704f4a156bea8f26ad081612514d64b78a3909f6fc264c6e6d36cd73d0b790371a1812b715e71eebd8216febdc35c3a9fa646a90bcef
data/Changelog.md ADDED
@@ -0,0 +1,21 @@
1
+ # ActiveModelAttributes Changelog
2
+
3
+ ## master
4
+
5
+ ## 1.0.0
6
+
7
+ Update notes:
8
+
9
+ - Breaking change: the attribute's setter now calls #cast method on type instead of #deserialize. If you have defined any custom type, just rename the method from #deserialize to #cast
10
+
11
+ Changes:
12
+ - [ENHANCEMENT] Use #cast method from types instead of #deserialize by @Azdaroth
13
+
14
+ ## 0.1.0
15
+
16
+ Update notes:
17
+
18
+ - None
19
+
20
+ Changes:
21
+ - [FEATURE] Basic implementation by @Azdaroth
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # ActiveModelAttributes [![Build Status](https://travis-ci.org/Azdaroth/active_model_attributes.svg?branch=master)](https://travis-ci.org/Azdaroth/active_model_attributes) [![Coverage Status](https://coveralls.io/repos/github/Azdaroth/active_model_attributes/badge.svg)](https://coveralls.io/github/Azdaroth/active_model_attributes)
1
+ # ActiveModelAttributes [![Build Status](https://travis-ci.org/Azdaroth/active_model_attributes.svg?branch=master)](https://travis-ci.org/Azdaroth/active_model_attributes) [![Gem Version](https://badge.fury.io/rb/active_model_attributes.svg)](https://rubygems.org/gems/active_model_attributes) [![Coverage Status](https://coveralls.io/repos/github/Azdaroth/active_model_attributes/badge.svg)](https://coveralls.io/github/Azdaroth/active_model_attributes)
2
2
 
3
- Rails 5.0 comes with a great addition of ActiveRecord Attributes API. However, that's only for ActiveRecord, you can't really use it in you ActiveModel models. Fortunately, with this gem it's possible.
3
+ Rails 5.0 comes with a great addition of ActiveRecord Attributes API. However, that's only for ActiveRecord, you can't really use it in your ActiveModel models. Fortunately, with this gem it's possible.
4
4
 
5
5
  ## Installation
6
6
 
@@ -77,11 +77,11 @@ Here's a list of supported types:
77
77
  * text
78
78
  * time
79
79
 
80
- You can also add your custom types. Just create a class inheriting from `ActiveModel::Type::Value` or already existing type, e.g. `ActiveModel::Type::Integer`, define `deserialize` method and register the new type:
80
+ You can also add your custom types. Just create a class inheriting from `ActiveModel::Type::Value` or already existing type, e.g. `ActiveModel::Type::Integer`, define `cast` method and register the new type:
81
81
 
82
82
  ``` rb
83
83
  class SomeCustomMoneyType < ActiveModel::Type::Integer
84
- def deserialize(value)
84
+ def cast(value)
85
85
  return super if value.kind_of?(Numeric)
86
86
  return super if !value.to_s.include?('$')
87
87
 
@@ -117,7 +117,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
117
117
 
118
118
  ## Contributing
119
119
 
120
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/active_model_attributes.
120
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Azdaroth/active_model_attributes.
121
121
 
122
122
 
123
123
  ## License
@@ -1,3 +1,3 @@
1
1
  module ActiveModelAttributes
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -32,7 +32,7 @@ module ActiveModelAttributes
32
32
 
33
33
  def define_attribute_writer(name, cast_type, options)
34
34
  define_method "#{name}=" do |val|
35
- deserialized_value = ActiveModel::Type.lookup(cast_type).deserialize(val)
35
+ deserialized_value = ActiveModel::Type.lookup(cast_type).cast(val)
36
36
  instance_variable_set("@#{name}", deserialized_value)
37
37
  end
38
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_model_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karol Galanciak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-01 00:00:00.000000000 Z
11
+ date: 2016-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -133,6 +133,7 @@ files:
133
133
  - ".gitignore"
134
134
  - ".rspec"
135
135
  - ".travis.yml"
136
+ - Changelog.md
136
137
  - Gemfile
137
138
  - LICENSE.txt
138
139
  - README.md