active_model_attributes 1.5.0 → 1.6.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
  SHA256:
3
- metadata.gz: cfb04d34795093fbccd50bd3b4af509210edb22b041689c30b9c08d3371495f2
4
- data.tar.gz: 7880d7fb17d90a86b1dc5b05575b0952e38188b397ca2ce491ffdf0f3d805981
3
+ metadata.gz: 58ff567cb69a22482382f7b6de791424915de614ff22e11240c4bab9abd983e4
4
+ data.tar.gz: 1cfbe61957ba6ed73c0808e392a6d587431bf9a77caf564f7b98426037e14671
5
5
  SHA512:
6
- metadata.gz: aad4717e6160598be72ebc9217ca0b76e2c0ec6f13c0e843c266c9951ecbb102a2fdd3fde1eacf2a26a5659345c5f31abd0c154df6d5ff5e8a39ee4d65a18175
7
- data.tar.gz: ba5bb7cc3cef03434c7f500daa979ca47652daa21d36999a9b2d816b4ff419e5e7cda2429531ba14aef08a3496340a5e63217601a4152b02ab9845f9fc589206
6
+ metadata.gz: 074cd5b95d2f51ed99533b3b734eedad8bff857ec0e44ddf857823f2f76b28f6d32f4cc0705264af14bdaf3805d6e1fb096b416161425487383c906d55b42aea
7
+ data.tar.gz: b3ace3930f67a5653dce2b3614518a7b2e0770d7b913dd91a68d4506e84e45fa944777a2b82d0291c0a665665926f3edc840fcd3aa406baa9e510ac03eba8841
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.6.0
6
+
7
+ - [FEATURE] Add `attribute_types` method to match behaviour that Rails 6 ActiveModel::Attributes provides by @shevaun
8
+
5
9
  ## 1.5.0
6
10
 
7
11
  - [ENHANCEMENT] Initialize field with default value upon read by @jughead
data/README.md CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- Define you ActiveModel model class, include `ActiveModel::Model` and `ActiveModelAttributes` modules and define attributes and their types using `attribute` class method:
23
+ Define your ActiveModel model class, include `ActiveModel::Model` and `ActiveModelAttributes` modules and define attributes and their types using `attribute` class method:
24
24
 
25
25
  ``` rb
26
26
  class MyAwesomeModel
@@ -21,11 +21,13 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.14"
24
+ spec.add_development_dependency "bundler", "~> 2.1.2"
25
25
  spec.add_development_dependency "rake", "~> 12.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
27
  spec.add_development_dependency "pry"
28
- spec.add_development_dependency "pry-byebug"
28
+ if RUBY_VERSION >= "2.4"
29
+ spec.add_development_dependency "pry-byebug"
30
+ end
29
31
  spec.add_development_dependency "coveralls"
30
32
 
31
33
  spec.add_dependency "activemodel", ">= 5.0"
@@ -8,8 +8,9 @@ module ActiveModelAttributes
8
8
  delegate :type_for_attribute, :has_attribute?, to: :class
9
9
 
10
10
  included do
11
- class_attribute :attributes_registry, instance_accessor: false
11
+ class_attribute :attributes_registry, :attribute_types, instance_accessor: false
12
12
  self.attributes_registry = {}
13
+ self.attribute_types = Hash.new(ActiveModel::Type.default_value)
13
14
  end
14
15
 
15
16
  module ClassMethods
@@ -22,6 +23,11 @@ module ActiveModelAttributes
22
23
 
23
24
  define_attribute_reader(name, options)
24
25
  define_attribute_writer(name, cast_type, options)
26
+
27
+ if cast_type.is_a?(Symbol)
28
+ cast_type = ActiveModel::Type.lookup(cast_type, **options.except(:default))
29
+ end
30
+ self.attribute_types = attribute_types.merge(name.to_s => cast_type)
25
31
  end
26
32
 
27
33
  def define_attribute_reader(name, options)
@@ -1,3 +1,3 @@
1
1
  module ActiveModelAttributes
2
- VERSION = "1.5.0"
2
+ VERSION = "1.6.0"
3
3
  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: 1.5.0
4
+ version: 1.6.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: 2019-06-07 00:00:00.000000000 Z
11
+ date: 2020-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.14'
19
+ version: 2.1.2
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.14'
26
+ version: 2.1.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -162,8 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
164
  requirements: []
165
- rubyforge_project:
166
- rubygems_version: 2.7.6
165
+ rubygems_version: 3.1.2
167
166
  signing_key:
168
167
  specification_version: 4
169
168
  summary: ActiveModel extension with support for ActiveRecord-like Attributes API