serialize_attributes 0.5.0 → 0.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: f4fa19f41c2a597b312db2432d1df9a2efad508c91feebd885caab60f68304ac
4
- data.tar.gz: a84b9c79d3bc59c8a416d8c2c3f2f08f46bdf3a25d8de465c8fb61593ce181aa
3
+ metadata.gz: 60ef1282c29e5ec4ae46242eed3dac95e756ddd5e6c57c95befc19a695bb9a6e
4
+ data.tar.gz: 9aa223ae50c2c60344844109bb4772a225796c7d70a0e7b355014bf765b402d9
5
5
  SHA512:
6
- metadata.gz: c5f6f45154a0b8f28b8712f81714c4d4eccccb9a58b7a54a0d2fe24499c101656d6416d80cf34eac0632de6444b8fe0b57503cbec6a5a2f8ffdea21badd7428c
7
- data.tar.gz: 336dfe149b07fb43a171d417a79d33f1fc67eec5d6399cb73a803f38f0fc2afa72cafd1da859c489ad1c92551291337599dfb55827678f46c6717845288fc273
6
+ metadata.gz: 867430cdb67e77c32ef2860fced5b004e80d3ac15300da02010addeff5d8100c0d20c84b0f8a80458041ad93896ccd0b86c8250dc3aad198e874eac9842f2bef
7
+ data.tar.gz: 5cebc02f04aa76e0d1dca6ecc9b63f645e595710d902d08a207eaf9d13fe11c6c5b6e51f9e52c3990340ada60d24bc1bd6bfdd189dd3137ce0652e8f88850964
data/README.md CHANGED
@@ -63,6 +63,16 @@ record
63
63
  #=> #<MyModel id: 1, settings: { user_name: "Nick", subscribed: true }>
64
64
  ```
65
65
 
66
+ Additionally you can use predicated methods the same way you do with an ActiveRecord's attribute.
67
+ Indeed behind the curtain we use `ActiveRecord::AttributeMethods::Query`.
68
+
69
+ ```ruby
70
+ record.subscribed?
71
+ #=> false
72
+ record.user_name?
73
+ #=> true
74
+ ```
75
+
66
76
  ### Getting all of the stored attributes
67
77
 
68
78
  Default values are not automatically persisted to the database, so there is a helper
@@ -71,7 +71,7 @@ module SerializeAttributes
71
71
  def deserialize(name, value)
72
72
  attribute = @attributes[name.to_sym]
73
73
  if attribute.nil?
74
- raise "The attribute #{name} is not define in serialize_attribute method in the #{@model_class} class."
74
+ raise "The attribute #{name} is not defined in serialize_attribute method in the #{@model_class} class."
75
75
  end
76
76
 
77
77
  attribute.deserialize(value)
@@ -142,6 +142,12 @@ module SerializeAttributes
142
142
  end # end
143
143
  end # end
144
144
  #
145
+ unless #{array} # unless array
146
+ def #{name}? # def user_name?
147
+ query_attribute("#{name}") # query_attribute(:user_name)
148
+ end # end
149
+ end # end
150
+ #
145
151
  def #{name}=(value) # def user_name=(value)
146
152
  cast_value = self.class # cast_value = self.class
147
153
  .serialized_attributes_store(:#{@column_name}) # .serialized_attributes_store(:settings)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SerializeAttributes
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serialize_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zaikio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-25 00:00:00.000000000 Z
11
+ date: 2022-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel