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 +4 -4
- data/Changelog.md +4 -0
- data/README.md +1 -1
- data/active_model_attributes.gemspec +4 -2
- data/lib/active_model_attributes.rb +7 -1
- data/lib/active_model_attributes/version.rb +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58ff567cb69a22482382f7b6de791424915de614ff22e11240c4bab9abd983e4
|
4
|
+
data.tar.gz: 1cfbe61957ba6ed73c0808e392a6d587431bf9a77caf564f7b98426037e14671
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 074cd5b95d2f51ed99533b3b734eedad8bff857ec0e44ddf857823f2f76b28f6d32f4cc0705264af14bdaf3805d6e1fb096b416161425487383c906d55b42aea
|
7
|
+
data.tar.gz: b3ace3930f67a5653dce2b3614518a7b2e0770d7b913dd91a68d4506e84e45fa944777a2b82d0291c0a665665926f3edc840fcd3aa406baa9e510ac03eba8841
|
data/Changelog.md
CHANGED
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
Define
|
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.
|
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
|
-
|
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)
|
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.
|
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:
|
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:
|
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:
|
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
|
-
|
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
|