composable-form 0.0.4 → 0.0.5

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: eac30b11c0f86a3b043b50fd7f76a94a13cd1443e17a236c5a9157a56b2978dd
4
- data.tar.gz: 4f9ac11ae372fe180dba6e1fe73c00c9ce6042f1354da4edd42978d9d577d82d
3
+ metadata.gz: efeb65c7ed0b26275f1972abb1fe31cc97523ecbdaeba71f281722af7078c788
4
+ data.tar.gz: 60eb6dc89bf4b0d52ba8537ff1392a2d7c91ddec63dbf28162c860fe0e9cc8b8
5
5
  SHA512:
6
- metadata.gz: c6a56334cb2b158ffd9d691c1172053f4264c4cc50c31f2d39c5b9d0389c6f66ddb4845d1c8aaf56d0e70bb009004ecdf2c845fbcb300f488f21add7edf52c9f
7
- data.tar.gz: d4b9e142cf92f99a166ed22c57131b2d5449b562119caa0f496749aca9397174cf17cb1face0f228d34462aa60385be038fbd65b7f78fa2cd63c61d063f9a4fd
6
+ metadata.gz: afa237c8a016ea856d425835814d925db44cbac4b230127e897e21033c2f5d8bcf5b3deeafc82787fd2858bd97c4df9baa03f592f09e29618fec949918473cb8
7
+ data.tar.gz: b1465fc19ee336e4a9ab848bb82b9df1ab8d173372063a12202496c6bbbed44a37e113fbc1add3195b1c9698fdcec078c81f790022e051de9c42c4f90c3d5c7d
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Composable
4
+ module Form
5
+ class Command
6
+ extend ActiveModel::Naming
7
+
8
+ include Core::AttributeDSL
9
+ include Core::ComposableDSL
10
+ include Core::Callbacks
11
+ include ActiveModel::Conversion
12
+
13
+ class << self
14
+ def inherited(subclass)
15
+ super
16
+ subclass.prepend(Core::Command)
17
+ end
18
+
19
+ def composable(attribute, model: nil, **options, &block)
20
+ super(attribute, **options, &block)
21
+
22
+ return unless model
23
+
24
+ define_singleton_method(:model_name) do
25
+ ActiveModel::Name.new(model)
26
+ end
27
+
28
+ delegate :id, :persisted?, :new_record?, to: attribute.to_sym, allow_nil: true
29
+ end
30
+ end
31
+
32
+ def call
33
+ return unless valid?
34
+
35
+ run_callbacks :save do
36
+ save_composables { save }
37
+ end
38
+ end
39
+
40
+ def persisted?
41
+ false
42
+ end
43
+
44
+ def new_record?
45
+ true
46
+ end
47
+
48
+ private
49
+
50
+ def save
51
+ end
52
+ end
53
+ end
54
+ end
@@ -10,7 +10,7 @@ module Composable
10
10
  module VERSION
11
11
  MAJOR = 0
12
12
  MINOR = 0
13
- TINY = 4
13
+ TINY = 5
14
14
  PRE = nil
15
15
 
16
16
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -6,6 +6,7 @@ require_relative "form/version"
6
6
  module Composable
7
7
  module Form
8
8
  class Error < StandardError; end
9
- # Your code goes here...
9
+
10
+ autoload :Command, "composable/form/command"
10
11
  end
11
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composable-form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jairo Vazquez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-25 00:00:00.000000000 Z
11
+ date: 2022-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: composable-core
@@ -16,15 +16,15 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.4
19
+ version: 0.0.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.4
27
- description: Form composable object to work with ActiveRecord forms
26
+ version: 0.0.5
27
+ description: Form composable object to work with Rails ActionView forms
28
28
  email:
29
29
  - jairovm20@gmail.com
30
30
  executables: []
@@ -35,6 +35,7 @@ files:
35
35
  - LICENSE.txt
36
36
  - README.md
37
37
  - lib/composable/form.rb
38
+ - lib/composable/form/command.rb
38
39
  - lib/composable/form/gem_version.rb
39
40
  - lib/composable/form/version.rb
40
41
  homepage: https://github.com/jairovm/composables
@@ -59,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
60
  - !ruby/object:Gem::Version
60
61
  version: '0'
61
62
  requirements: []
62
- rubygems_version: 3.2.17
63
+ rubygems_version: 3.3.3
63
64
  signing_key:
64
65
  specification_version: 4
65
66
  summary: Form Composable Object