formify 0.3.7 → 0.4.0

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: a5bd2f6dbc116c9f253836e72aad9dc6e933593d32f2c46ea9556cda98b99c1d
4
- data.tar.gz: 6ea9a05f7267007fcae5cbba69f67386d124763437474937cf1ef2e15f6d6aab
3
+ metadata.gz: 72de11fb4c4933d16cd59cce57c64c037cc7abb16bd82d3d6bdf7b865e403c46
4
+ data.tar.gz: 0f3e5a864f982eb1a9a56b7694e073d69da47b793233f42a3cea203027ea3601
5
5
  SHA512:
6
- metadata.gz: 4f52969289a7dbfc5a2def6e440a88c134efb757929e996c6539a8bb785f0e3aff33b17391750db9701a5bae8a70d2146facd29bc49b0c785804120656e8e0be
7
- data.tar.gz: 66bc9fdf170fedc8d7d5179aae8a2fef9dcbea670529b7d6cf3ffbe95b6b2c1ed0914e757a7ab36a0eac661c1935bc4396b5d5d7c393f82089a8601fcfd648a6
6
+ metadata.gz: 28f012f82c0bec95ceceb3a9ac9611887e197aa42ef0786a68bc3360b810bd47f9de5d8c021f4b581d9db4bacae9599d6c3eafde4dab9a0179395d3fa63f4259
7
+ data.tar.gz: 675d7a158bcb082a598fa0020d328500bfab58c550fb6df8ad25ebe7e0ff5b6bba507e64afb6c3aed1b224b68635765ffeb052bdd9319373372c3549ea77441c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- formify (0.3.7)
4
+ formify (0.4.0)
5
5
  resonad
6
6
 
7
7
  GEM
@@ -9,10 +9,38 @@ module Formify
9
9
  include ActiveModel::Validations
10
10
  include ActiveModel::Validations::Callbacks
11
11
 
12
+ def failure(*args)
13
+ Resonad.Failure(*args)
14
+ end
15
+
16
+ def params
17
+ self.class.params
18
+ end
19
+
20
+ def return_self
21
+ Resonad.Success(self)
22
+ end
23
+
24
+ def success(*args)
25
+ Resonad.Success(*args)
26
+ end
27
+
28
+ def translation_data
29
+ {}
30
+ end
31
+
12
32
  def t(*args, **keywords)
13
33
  I18n.t(*args, **keywords)
14
34
  end
15
35
 
36
+ def translation_success
37
+ split_name = self.class.name.split('::')
38
+ split_name.shift
39
+ action = split_name.pop.underscore
40
+ key = split_name.map(&:underscore).push(action).push(:success).join('.')
41
+ return t(key) if I18n.exists?(key, translation_data)
42
+ end
43
+
16
44
  def validate_or_fail(*instances)
17
45
  unless valid?
18
46
  return Resonad.Failure(
@@ -33,22 +61,6 @@ module Formify
33
61
  Resonad.Success
34
62
  end
35
63
 
36
- def return_self
37
- Resonad.Success(self)
38
- end
39
-
40
- def translation_data
41
- {}
42
- end
43
-
44
- def translation_success
45
- split_name = self.class.name.split('::')
46
- split_name.shift
47
- action = split_name.pop.underscore
48
- key = split_name.map(&:underscore).push(action).push(:success).join('.')
49
- return t(key) if I18n.exists?(key, translation_data)
50
- end
51
-
52
64
  def with_advisory_lock(*keys, **args)
53
65
  key = keys.map do |k|
54
66
  if k.is_a?(String)
@@ -75,10 +87,6 @@ module Formify
75
87
 
76
88
  with_advisory_lock_transaction_result
77
89
  end
78
-
79
- def params
80
- self.class.params
81
- end
82
90
  end
83
91
 
84
92
  class_methods do
@@ -1,3 +1,3 @@
1
1
  module Formify
2
- VERSION = '0.3.7'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -4,8 +4,21 @@
4
4
  class <%= name.split('/').last.to_s.camelcase %>
5
5
  include Formify::Form
6
6
 
7
+ def initialize(attributes = {})
8
+ raise NotImplementedError
9
+
10
+ self.fixed_attr = attributes[:fixed_attr]
11
+ super(attributes)
12
+ end
13
+
7
14
  def save
8
15
  raise NotImplementedError
16
+
17
+ with_advisory_lock_transaction(:foo) do
18
+ validate_or_fail
19
+ .and_then { method }
20
+ .and_then { success(object) }
21
+ end
9
22
  end
10
23
  end
11
24
  <% end -%>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Jackson