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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e99d26a7f22a07026033f6bb80606ef503aee1449010469f8652d9b10bd62812
4
- data.tar.gz: 0f7fd36f0be826e6ffcdf8a1b45a54018ab83b1f9aebcb3ff723bb9d21fdd5f4
3
+ metadata.gz: 1277569aeb69dcb5cf7505976dbea68d1f6083aaa2df4574e5dc7937890eaff2
4
+ data.tar.gz: 16f628ba1c7206c8f22b419499dd517f434c0f56720aafc27830da498dca66ee
5
5
  SHA512:
6
- metadata.gz: ec428c4fccec9acd974d5af6cbbb6e4dcd99f26eae2f32260e73d27e8446abef87c835f4fcae31ef25825421ef26f7ec7de272bd36bc428f086165ce97082cf9
7
- data.tar.gz: c5423033eb5dc15c6315efeb1d04cf3d14827d76710969e20133de6669fe598237c7d1af61823cf97d931d89d094bcc3a9a285dc130e838982208e0babebe86a
6
+ metadata.gz: 5dc8b54bc4e427b897d45131d57d2e72014b6f1baf64b48f72d33933ae1b8c537b8d5b94fd4c3e77b73e382f1ef1a1df97310307ccafee99e0263528e52470dc
7
+ data.tar.gz: 1dde523dcf396183a2b8f946992c0ee9f5ce70fcecc5770eec05b080e0f974d687dfe4794f93bd3bfe59581405e4431594d14a07c29e9b26f8d4db73e84a1cb6
@@ -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
@@ -7,8 +7,8 @@ module Handlers
7
7
  @resource = @klass.instance_variable_get(:@resource)
8
8
  end
9
9
 
10
- def self.handle(klass)
11
- new(klass).handle
10
+ def self.handle(*params)
11
+ new(*params).handle
12
12
  end
13
13
 
14
14
  def upper(var)
@@ -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.3
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-01-30 00:00:00.000000000 Z
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
- rubyforge_project:
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