rule_box 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93a607676433feab4de64825c8765e739e1e1a417e93d4fbedb9548ea8aea3b8
4
- data.tar.gz: 508c284e6ecf27dcdea4e6bf5c312347f91d3ef6fad02d248e7a2a7e95358691
3
+ metadata.gz: f01478318a1639d5a1c20a7fd3f6e29cd5b3f65277017a40d272a0ea19ed426c
4
+ data.tar.gz: 7a443d2bb69cf7f80595e8be51459b3abe1590a0303b6582e055074ee345644e
5
5
  SHA512:
6
- metadata.gz: 85ae54a48bc97c4cc052cf1b4fde1ffd62162e7445f2a1380968a845057505db8fc6602d660c2b9d53170c03eab5487170091d753dea9513b90be5ccc9f3a19e
7
- data.tar.gz: ef89ef6c0086f7b3162586a6fdc0f36b250d7823033e85f608495223b07d67852ecc3f8c7c77b6aa137a0c3290d8f8b71d84f2c2e7bc7fc1580d4d80fae69a25
6
+ metadata.gz: 7617bf7c3a6622ea03a7a3b2ad6b713691e90109ce41d1da40b2abe9308f89da9e0b31f744a49b8f1349d9196c579728b4768f9af374846e76db750cf42e201f
7
+ data.tar.gz: bf2dfe44c1ec7bcf2fc37227b2e4d5ae528cb457adbd770e7cd43413e09ccb0b67322e6f854a54a4f95ed16d9f89986bc37e5ed196f5417ece4a6e2326ee4fef
@@ -7,12 +7,10 @@ module RuleBox
7
7
  class Error < StandardError; end
8
8
 
9
9
  class << self
10
-
11
10
  def show_mapped_classes
12
11
  RuleBox::Mapper.mapped.to_a
13
12
  end
14
13
  end
15
-
16
14
  end
17
15
 
18
16
  require 'rule_box/facade'
@@ -42,6 +42,19 @@ class RuleBox::Facade
42
42
  execute(:delete, model, args)
43
43
  end
44
44
 
45
+ def _current_class
46
+ @_current_class ||=
47
+ if model.nil?
48
+ nil
49
+ elsif model.is_a?(Class) || model.is_a?(Module)
50
+ model
51
+ elsif model.is_a?(Symbol) || model.is_a?(String)
52
+ Object.const_get RuleBox::Util.camelize(model.to_s)
53
+ else
54
+ Object.const_get model.class.name
55
+ end
56
+ end
57
+
45
58
  def attributes
46
59
  attrs = {}
47
60
  %i[model status data bucket executed errors steps _current_method].each do |key|
@@ -77,7 +90,7 @@ class RuleBox::Facade
77
90
  def respond_to_missing?(method, _include_private = false)
78
91
  return false if @executed || method.to_s.end_with?('=')
79
92
 
80
- true
93
+ super
81
94
  end
82
95
 
83
96
  def execute(method, model, **args)
@@ -93,7 +106,7 @@ class RuleBox::Facade
93
106
  def pre_process(method, model)
94
107
  @model = model
95
108
  @_current_method = method
96
- class_name = check_class_model
109
+ class_name = _current_class
97
110
  @errors = []
98
111
  @steps = []
99
112
 
@@ -135,14 +148,12 @@ class RuleBox::Facade
135
148
  steps << new_value
136
149
  end
137
150
 
138
- def check_class_model
139
- if model.is_a?(Class) || model.is_a?(Module)
140
- model
141
- elsif model.is_a?(Symbol) || model.is_a?(String)
142
- Object.const_get RuleBox::Util.camelize(model.to_s)
143
- else
144
- Object.const_get model.class.name
145
- end
151
+ def marshal_dump
152
+ instance_variables.map { |name| [name, instance_variable_get(name)] }.to_h
153
+ end
154
+
155
+ def marshal_load(variables)
156
+ variables.each { |key, value| instance_variable_set(key, value) }
146
157
  end
147
158
 
148
159
  def keys
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RuleBox
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = 'RuleBox'
12
12
  spec.description = 'This gem is focused in giving a strong and concrete way to manage your business rules, mixing the best of both worlds in Facade and Strategy, bringing you a simplified way to apply these Design Patterns into your project.'
13
- spec.homepage = 'https://github.com/ralphsbaesso'
13
+ spec.homepage = 'https://github.com/ralphsbaesso/rule_box'
14
14
  spec.license = 'MIT'
15
15
  spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
16
16
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rule_box
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ralph Baesso
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-10-08 00:00:00.000000000 Z
12
+ date: 2020-12-10 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: This gem is focused in giving a strong and concrete way to manage your
15
15
  business rules, mixing the best of both worlds in Facade and Strategy, bringing
@@ -43,11 +43,11 @@ files:
43
43
  - lib/rule_box/util.rb
44
44
  - lib/rule_box/version.rb
45
45
  - rule_box.gemspec
46
- homepage: https://github.com/ralphsbaesso
46
+ homepage: https://github.com/ralphsbaesso/rule_box
47
47
  licenses:
48
48
  - MIT
49
49
  metadata:
50
- homepage_uri: https://github.com/ralphsbaesso
50
+ homepage_uri: https://github.com/ralphsbaesso/rule_box
51
51
  source_code_uri: https://github.com/ralphsbaesso/rule_box
52
52
  post_install_message:
53
53
  rdoc_options: []