action_logic 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: c17b002948787563a10bc653bf44ee73f88e989d
4
- data.tar.gz: cf88c4dfb9009e45b222acd03b7ec3f8eef9cc89
3
+ metadata.gz: 46629f7e8b78b79da65d73f694f03ffd3598a836
4
+ data.tar.gz: e7cd5893f3661781d40ed6050a10067e31d4df3e
5
5
  SHA512:
6
- metadata.gz: 47dfecfa70d4193a4c69b418f747db4bd98e17178fa5c22e3a42ee37db724c8e9d9c8bb82e66360ba4d1f02ab2ecfff0c2b2c13a53d38bd9482e8a9dda502508
7
- data.tar.gz: d834c1c3f475660f8cb03342aae902c85b8d3c5c8675bf4574d8df0b50aa71b4a929828bb8ca5fd21739c75b46d3c7412a78816e781f13dc2ecd52f2c15bf288
6
+ metadata.gz: a81e6790403bb1611887adc70072541414c8df853cbfae06474eeb6bcb4d481ba17fb29c8b79be8352e155dd554b455f164ad472cfdabdd84b7431ccac35f9a2
7
+ data.tar.gz: 561ca45352089282b7a036013799664efc7787fd80f1b38adb7df8d522ee1ae8a72b6ed7c22d49ffa3a6a24490f3575adb422bd15c72a85478c92b17ed249586
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- action_logic (0.0.6)
4
+ action_logic (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -483,20 +483,20 @@ to expirement and play with the flexibility provided to you by `ActionContext` i
483
483
  ```ruby
484
484
  class RailsControllerExample < ApplicationController
485
485
  def create
486
- case create_use_case.status
487
- when :disposition_1 then ActionUseCaseSuccess1.execute(create_use_case)
488
- when :disposition_2 then ActionUseCaseSuccess2.execute(create_use_case)
489
- when :disposition_9 then ActionUseCaseFailure.execute(create_use_case)
490
- else
491
- ActionUseCaseDefault.execute(create_use_case)
492
- end
493
- end
494
-
495
- private
496
-
497
- def create_use_case
498
- @create_use_case ||= ActionUseCaseExample.execute(params)
499
- end
486
+ case create_use_case.status
487
+ when :disposition_1 then ActionUseCaseSuccess1.execute(create_use_case)
488
+ when :disposition_2 then ActionUseCaseSuccess2.execute(create_use_case)
489
+ when :disposition_9 then ActionUseCaseFailure.execute(create_use_case)
490
+ else
491
+ ActionUseCaseDefault.execute(create_use_case)
492
+ end
493
+ end
494
+
495
+ private
496
+
497
+ def create_use_case
498
+ @create_use_case ||= ActionUseCaseExample.execute(params)
499
+ end
500
500
  end
501
501
  ```
502
502
 
@@ -68,8 +68,8 @@ module ActionLogic
68
68
  type_errors = validations.reduce([]) do |collection, (expected_attribute, expected_validation)|
69
69
  next unless expected_validation[:type]
70
70
 
71
- if type_to_sym(context.to_h[expected_attribute]) != expected_validation[:type]
72
- collection << "Attribute: #{expected_attribute} with value: #{context.to_h[expected_attribute]} was expected to be of type #{expected_validation[:type]} but is #{type_to_sym(context.to_h[expected_attribute])}"
71
+ if context.to_h[expected_attribute].class != expected_validation[:type]
72
+ collection << "Attribute: #{expected_attribute} with value: #{context.to_h[expected_attribute]} was expected to be of type #{expected_validation[:type]} but is #{context.to_h[expected_attribute].class}"
73
73
  end
74
74
  collection
75
75
  end
@@ -96,16 +96,5 @@ module ActionLogic
96
96
 
97
97
  raise ActionLogic::PresenceError.new(presence_errors) if presence_errors.any?
98
98
  end
99
-
100
- def type_to_sym(value)
101
- case value.class.name.downcase.to_sym
102
- when :fixnum then :integer
103
- when :falseclass then :boolean
104
- when :trueclass then :boolean
105
- when :nilclass then :nil
106
- else
107
- value.class.name.downcase.to_sym
108
- end
109
- end
110
99
  end
111
100
  end
@@ -1,3 +1,3 @@
1
1
  module ActionLogic
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -1,14 +1,14 @@
1
1
  require 'fixtures/custom_types'
2
2
 
3
3
  class Constants
4
- ALL_VALIDATIONS = { :integer_test => { :type => :integer, :presence => true },
5
- :float_test => { :type => :float, :presence => true },
6
- :string_test => { :type => :string, :presence => true },
7
- :bool_test => { :type => :boolean, :presence => true },
8
- :hash_test => { :type => :hash, :presence => true },
9
- :array_test => { :type => :array, :presence => true },
10
- :symbol_test => { :type => :symbol, :presence => true },
11
- :nil_test => { :type => :nil } }
4
+ ALL_VALIDATIONS = { :integer_test => { :type => Fixnum, :presence => true },
5
+ :float_test => { :type => Float, :presence => true },
6
+ :string_test => { :type => String, :presence => true },
7
+ :bool_test => { :type => TrueClass, :presence => true },
8
+ :hash_test => { :type => Hash, :presence => true },
9
+ :array_test => { :type => Array, :presence => true },
10
+ :symbol_test => { :type => Symbol, :presence => true },
11
+ :nil_test => { :type => NilClass } }
12
12
 
13
13
  INVALID_ATTRIBUTES = { :integer_test => nil,
14
14
  :float_test => nil,
@@ -28,11 +28,11 @@ class Constants
28
28
  :symbol_test => :symbol,
29
29
  :nil_test => nil }
30
30
 
31
- CUSTOM_TYPE_VALIDATION1 = { :custom_type => { :type => :customtype1, :presence => true } }
31
+ CUSTOM_TYPE_VALIDATION1 = { :custom_type => { :type => CustomType1, :presence => true } }
32
32
 
33
33
  CUSTOM_TYPE_ATTRIBUTES1 = { :custom_type => CustomType1.new }
34
34
 
35
- CUSTOM_TYPE_VALIDATION2 = { :custom_type => { :type => :customtype2, :presence => true } }
35
+ CUSTOM_TYPE_VALIDATION2 = { :custom_type => { :type => CustomType2, :presence => true } }
36
36
 
37
37
  CUSTOM_TYPE_ATTRIBUTES2 = { :custom_type => CustomType2.new }
38
38
 
@@ -161,7 +161,7 @@ class ValidateAfterTestCoordinator
161
161
  context.integer_test = 1
162
162
  context.float_test = 1.0
163
163
  context.string_test = "string"
164
- context.bool_test = false
164
+ context.bool_test = true
165
165
  context.hash_test = {}
166
166
  context.array_test = []
167
167
  context.symbol_test = :symbol
@@ -22,7 +22,7 @@ end
22
22
  class ValidateAroundCustomTypeTestTask
23
23
  include ActionLogic::ActionTask
24
24
 
25
- validates_around :custom_type => { :type => :customtype1, :presence => true }
25
+ validates_around :custom_type => { :type => CustomType1, :presence => true }
26
26
 
27
27
  def call
28
28
  end
@@ -71,7 +71,7 @@ end
71
71
  class ValidateBeforeCustomTypeTestTask
72
72
  include ActionLogic::ActionTask
73
73
 
74
- validates_before :custom_type => { :type => :customtype1, :presence => true }
74
+ validates_before :custom_type => { :type => CustomType1, :presence => true }
75
75
 
76
76
  def call
77
77
  end
@@ -117,7 +117,7 @@ class ValidateAfterTestTask
117
117
  context.integer_test = 1
118
118
  context.float_test = 1.0
119
119
  context.string_test = "string"
120
- context.bool_test = false
120
+ context.bool_test = true
121
121
  context.hash_test = {}
122
122
  context.array_test = []
123
123
  context.symbol_test = :symbol
@@ -154,7 +154,7 @@ end
154
154
  class ValidateAfterCustomTypeTestTask
155
155
  include ActionLogic::ActionTask
156
156
 
157
- validates_after :custom_type => { :type => :customtype1, :presence => true }
157
+ validates_after :custom_type => { :type => CustomType1, :presence => true }
158
158
 
159
159
  def call
160
160
  context.custom_type = CustomType1.new
@@ -164,7 +164,7 @@ end
164
164
  class ValidateAfterInvalidCustomTypeTestTask
165
165
  include ActionLogic::ActionTask
166
166
 
167
- validates_after :custom_type => { :type => :customtype2, :presence => true }
167
+ validates_after :custom_type => { :type => CustomType2, :presence => true }
168
168
 
169
169
  def call
170
170
  context.custom_type = CustomType1.new
@@ -65,7 +65,7 @@ end
65
65
  class ValidateAroundCustomTypeTestUseCase
66
66
  include ActionLogic::ActionUseCase
67
67
 
68
- validates_around :custom_type => { :type => :customtype1, :presence => true }
68
+ validates_around :custom_type => { :type => CustomType1, :presence => true }
69
69
 
70
70
  def call
71
71
  end
@@ -197,7 +197,7 @@ class ValidateAfterTestUseCase
197
197
  context.integer_test = 1
198
198
  context.float_test = 1.0
199
199
  context.string_test = "string"
200
- context.bool_test = false
200
+ context.bool_test = true
201
201
  context.hash_test = {}
202
202
  context.array_test = []
203
203
  context.symbol_test = :symbol
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_logic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Winfrey
@@ -137,3 +137,4 @@ test_files:
137
137
  - spec/fixtures/tasks.rb
138
138
  - spec/fixtures/use_cases.rb
139
139
  - spec/spec_helper.rb
140
+ has_rdoc: