active_form_objects 2.0.4 → 2.1.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
  SHA256:
3
- metadata.gz: 2daaa8dd6cc58ada79b0fbab645c19bdc3f8ba9439d5c2c58e2a9db8d45b64ff
4
- data.tar.gz: 2ca8cb23a9f2b1118cfbf699463d64e1e6db8d9a3804ce8e56abffbdbef846e5
3
+ metadata.gz: 126da84d089de0420d5365580fe87b46913fb16a0123dab3c0c17f178996df76
4
+ data.tar.gz: e4c1c195cfb94aea99f0b9eae4beecb2629a89f00bc4a688a78201847512be84
5
5
  SHA512:
6
- metadata.gz: c2f92a20ca5941af70874c8bce8d7c4cf1a963fe61c933e08a9321e67212a8dfc4c8a88936ded00a063f07825b26d44185fbc50c667e8ded2ce22b3ce10f67a9
7
- data.tar.gz: 49b4ab98dc7d917878ef897a080ce95b61d11345077ee5c93554ac64e1472ad474e9f7ba4ba45cb5c05887c3bb36b5c32640a5712ee3d5b034edf12c3b62a466
6
+ metadata.gz: 6d2beadaf88fb9600e95bc5068f81b5c638a57bb977a7d0a04329819f421d90d0c3badc8b899cab8a9c77b45212af564ce863a7d28b45144bcde60c6304f7760
7
+ data.tar.gz: e86dbc316cf39905f6314c117a28d78479207162f6135c812817c771492edc425c3e5d9ca45234e879ae709ef48fc0305ea6a9d2ee752b93572d83bd4c21eeb4
@@ -8,6 +8,7 @@ module Dsl
8
8
 
9
9
  @@attributes = {}
10
10
  @@overrided_params = {}
11
+ @@remaped_params = {}
11
12
  @@default_params = {}
12
13
  @@preparers = {}
13
14
 
@@ -46,6 +47,15 @@ module Dsl
46
47
  send(:attributes, param)
47
48
  end
48
49
 
50
+ def self.remap(key, options)
51
+ @@remaped_params[name] = (@@remaped_params[name] || []) + [{
52
+ key: key,
53
+ to: options[:to]
54
+ }]
55
+
56
+ send(:attributes, options[:to])
57
+ end
58
+
49
59
  def self.prepare(*params)
50
60
  raise ActiveFormObjects::DslError.new("[#{self.name}] prepare takes a lambda as second argument, not a #{params.last.class.name}") if !params.last.respond_to?(:call)
51
61
 
@@ -8,6 +8,7 @@ module Handlers
8
8
  def handle
9
9
  start_with_default_params!
10
10
  affect_prepared_values!
11
+ remap_attributes!
11
12
  merge_with_resource_attributes!
12
13
  affect_relation_values!
13
14
  merge_overrided_params!
@@ -27,6 +28,13 @@ module Handlers
27
28
  end
28
29
  end
29
30
 
31
+ # DSL method : remap
32
+ def remap_attributes!
33
+ (upper(:@@remaped_params) || []).each do |remaped|
34
+ @params[remaped[:to]] = @raw_params[remaped[:key].to_s]
35
+ end
36
+ end
37
+
30
38
  def merge_with_resource_attributes!
31
39
  return unless @resource.respond_to?(:attributes)
32
40
  @params.reverse_merge!(@resource.attributes.symbolize_keys)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_form_objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michaël Villeneuve
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-15 00:00:00.000000000 Z
11
+ date: 2019-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport