firm 1.1.0 → 1.1.1

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: f36086871785c4f7a5db75ed9e4b9272a4285c80c76335c7e09bd4eccdb2c939
4
- data.tar.gz: 9936ecd659270cedddfd0d0d18fac176783b97aa7f9c52739fbe45abf1a107d8
3
+ metadata.gz: 9bde55f78b14c4b8c8cac20c709c2826391616cf5d30972bcdeff2613d9389f5
4
+ data.tar.gz: f4e7a9b3269ea524699693968c88d75372f6bf51dbe54c7e61b3bee349da3b71
5
5
  SHA512:
6
- metadata.gz: d4800195157b45b817aa2a700113c126b466b9ec53c342fb6e4473ae4bf6d9b463fe05b839ef65f1aa12db1d4e0a128d7026b10b6eacf5bb5e31c4891de1349b
7
- data.tar.gz: 6893d0692e160627a8a2e1f5ed32de5181dde889778874d05955469e12074c90d7a3f377321dea7b25dd2178e3a97eddf55986f5ea65d6fe4e64f0130e9f0c4b
6
+ metadata.gz: 3768d2dda3e137c33b54ecfe27eda8f052c9eb8e21809e9e8f82eb434f9ce381fdf5cd430d9d118aacb75a6047c4db2bd175d2e9937be3fccc6b587f8cc0b683
7
+ data.tar.gz: 329dff1413b582f472b099181769c16afc91aeaa9fe6b827b1cb753be68df14d6dbda11e5d60f3da77e97feb22833b7b78db0a231b09a605c5f78d79845f16e0
@@ -11,6 +11,7 @@ module FIRM
11
11
 
12
12
  class Exception < RuntimeError; end
13
13
 
14
+ # This class encapsulates a serializable property definition.
14
15
  class Property
15
16
  def initialize(klass, prop, proc=nil, force: false, handler: nil, optional: false, &block)
16
17
  ::Kernel.raise ArgumentError, "Invalid property id [#{prop}]" unless ::String === prop || ::Symbol === prop
@@ -70,6 +71,11 @@ module FIRM
70
71
 
71
72
  attr_reader :id
72
73
 
74
+ # Serializes the defined property for the given object and inserts the serialized data
75
+ # into the given data object unless included in the given excludes list.
76
+ # @param [Object] obj
77
+ # @param [Object] data hash-like object
78
+ # @param [Array<Symbol>] excludes
73
79
  def serialize(obj, data, excludes)
74
80
  unless excludes.include?(@id)
75
81
  val = getter.call(obj)
@@ -86,6 +92,17 @@ module FIRM
86
92
  end
87
93
  end
88
94
 
95
+ # Returns the (unserialized) property value for the given object.
96
+ # @param [Object] obj
97
+ def get(obj)
98
+ getter.call(obj)
99
+ end
100
+
101
+ # Restores the defined property for the given object using the deserialized data
102
+ # extracted from the given data object.
103
+ # @param [Object] obj
104
+ # @param [Object] data hash-like object
105
+ # @return [void]
89
106
  def deserialize(obj, data)
90
107
  if data.has_key?(@id)
91
108
  setter.call(obj, data[@id])
data/lib/firm/version.rb CHANGED
@@ -4,6 +4,6 @@
4
4
  module FIRM
5
5
 
6
6
  # FIRM version
7
- VERSION = "1.1.0"
7
+ VERSION = "1.1.1"
8
8
 
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Corino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-05 00:00:00.000000000 Z
11
+ date: 2024-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake