active_form_objects 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_form_objects.rb +5 -0
- data/lib/handlers/base.rb +2 -2
- data/lib/handlers/inheritance.rb +26 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1277569aeb69dcb5cf7505976dbea68d1f6083aaa2df4574e5dc7937890eaff2
|
4
|
+
data.tar.gz: 16f628ba1c7206c8f22b419499dd517f434c0f56720aafc27830da498dca66ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dc8b54bc4e427b897d45131d57d2e72014b6f1baf64b48f72d33933ae1b8c537b8d5b94fd4c3e77b73e382f1ef1a1df97310307ccafee99e0263528e52470dc
|
7
|
+
data.tar.gz: 1dde523dcf396183a2b8f946992c0ee9f5ce70fcecc5770eec05b080e0f974d687dfe4794f93bd3bfe59581405e4431594d14a07c29e9b26f8d4db73e84a1cb6
|
data/lib/active_form_objects.rb
CHANGED
@@ -11,6 +11,7 @@ require_relative 'dsl/associates'
|
|
11
11
|
require_relative 'dsl/polymorphs'
|
12
12
|
|
13
13
|
require_relative 'handlers/initializer'
|
14
|
+
require_relative 'handlers/inheritance'
|
14
15
|
require_relative 'handlers/relations'
|
15
16
|
require_relative 'handlers/resource'
|
16
17
|
require_relative 'handlers/attributes'
|
@@ -28,6 +29,10 @@ module ActiveFormObjects
|
|
28
29
|
include Dsl::Associates
|
29
30
|
include Dsl::Savings
|
30
31
|
|
32
|
+
def self.inherited(subclass)
|
33
|
+
Handlers::Inheritance.handle(subclass, self)
|
34
|
+
end
|
35
|
+
|
31
36
|
def initialize(params, resource = nil)
|
32
37
|
@params = params.with_indifferent_access
|
33
38
|
@resource = resource
|
data/lib/handlers/base.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module Handlers
|
4
|
+
class Inheritance < Base
|
5
|
+
def initialize(subclass, klass)
|
6
|
+
@subclass = subclass
|
7
|
+
@klass = klass
|
8
|
+
end
|
9
|
+
|
10
|
+
def handle
|
11
|
+
return nil if regular_inheritance?
|
12
|
+
|
13
|
+
@klass.class_variables.each do |var_name|
|
14
|
+
dsl_values = @subclass.class_variable_get(var_name)
|
15
|
+
|
16
|
+
dsl_values[@subclass.name] = dsl_values[@klass.name]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def regular_inheritance?
|
23
|
+
@klass == ActiveFormObjects::Base
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
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: 1.0
|
4
|
+
version: 1.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-
|
11
|
+
date: 2019-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/handlers/attributes.rb
|
71
71
|
- lib/handlers/base.rb
|
72
72
|
- lib/handlers/delegates.rb
|
73
|
+
- lib/handlers/inheritance.rb
|
73
74
|
- lib/handlers/initializer.rb
|
74
75
|
- lib/handlers/polymorphs.rb
|
75
76
|
- lib/handlers/relations.rb
|
@@ -94,8 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
95
|
- !ruby/object:Gem::Version
|
95
96
|
version: '0'
|
96
97
|
requirements: []
|
97
|
-
|
98
|
-
rubygems_version: 2.7.3
|
98
|
+
rubygems_version: 3.0.1
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: A step toward an hexagonal Rails architecture
|