store_model 0.8.2 → 0.9.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: '08b39695323b89c1d405590f4947ca989e00c74a4eab76c00acb593f21d46a83'
4
- data.tar.gz: dedd6070fdce1873ec69f582877aa3219ffb925c1aa7d4a249c80d8524017aa4
3
+ metadata.gz: e85a27e1f3a20217b3f6134d8f2679d556ce445c74b47ff223a3abec247219b9
4
+ data.tar.gz: e4c5baceadbbd1049ff8c0616e31d41302178ed74929ee512e1625a8d983c870
5
5
  SHA512:
6
- metadata.gz: 783d91fbea217d2a72e7495ce068b7dba1ea90a6828fde79ce2af9278acac0fdde85cd9a57b928bb2197f55f08229bdb23b69584f27ca1c3e9787c8abe061a93
7
- data.tar.gz: 459659e56410f04f32e5196e2a93799b6022c3aa10d240dc44abf69d0b7da016c705c0baba5fd89822ee8d0aa35469e9dbae41b2ec9bc1909d0f231149c64586
6
+ metadata.gz: 8e900e6ffeaffb83c1bc87b66b810d5e652871908c46542f1d3edbd7791761721d8a69bef57b9e187ce700c480dbd7c59d0dc9cda6a01092d64fcba27c4eb277
7
+ data.tar.gz: 8744a4125da41b45bb0bb510296924758b5b07345e173cf4193a5ca0b3759f62aa2dfc54b4d9233d757d7c92e8ce0a0fed2c139f95c51ab91935bfc8e440001e
data/README.md CHANGED
@@ -44,7 +44,7 @@ This approach works fine when you don't have a lot of keys with logic around the
44
44
 
45
45
  For instance, try to find a way to validate `:model` value to be required. Despite of the fact, that you'll have to write this validation by hand, it violates single-repsponsibility principle: why parent model (`Product`) should know about the logic related to a child (`Configuration`)?
46
46
 
47
- > 📖 Read more about the motivation in the [Wrapping JSON-based ActiveRecord attributes with classes](https://dev.to/evilmartians/wrapping-json-based-activerecord-attributes-with-classes-4apf) post
47
+ > 📖 Read more about the motivation in the [Wrapping JSON-based ActiveRecord attributes with classes](https://evilmartians.com/chronicles/wrapping-json-based-active-record-attributes-with-classes) post
48
48
 
49
49
  ## Getting started
50
50
 
@@ -70,13 +70,37 @@ module StoreModel
70
70
 
71
71
  # Checks if the attribute with a given name is defined
72
72
  #
73
+ # @example
74
+ # class Person
75
+ # include StoreModel::Model
76
+ # attribute :name, :string
77
+ # alias_attribute :new_name, :name
78
+ # end
79
+ #
80
+ # Person.has_attribute?('name') # => true
81
+ # Person.has_attribute?('new_name') # => true
82
+ # Person.has_attribute?(:age) # => true
83
+ # Person.has_attribute?(:nothing) # => false
84
+ #
73
85
  # @param attr_name [String] name of the attribute
74
86
  #
75
87
  # @return [Boolean]
76
88
  # rubocop:disable Naming/PredicateName
77
89
  def has_attribute?(attr_name)
78
- attribute_types.key?(attr_name.to_s)
90
+ attr_name = attr_name.to_s
91
+ attr_name = self.class.attribute_aliases[attr_name] || attr_name
92
+ attribute_types.key?(attr_name)
93
+ end
94
+
95
+ # Legacy implementation of #has_attribute?
96
+ #
97
+ # @param attr_name [String] name of the attribute
98
+ #
99
+ # @return [Boolean]
100
+ def _has_attribute?(attr_name)
101
+ attribute_types.key?(attr_name)
79
102
  end
103
+
80
104
  # rubocop:enable Naming/PredicateName
81
105
 
82
106
  # Contains a hash of attributes which are not defined but exist in the
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StoreModel # :nodoc:
4
- VERSION = "0.8.2"
4
+ VERSION = "0.9.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: store_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-10 00:00:00.000000000 Z
11
+ date: 2021-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord