clowne 0.1.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +11 -45
- data/.travis.yml +14 -21
- data/CHANGELOG.md +30 -0
- data/Gemfile +11 -7
- data/README.md +38 -18
- data/Rakefile +3 -3
- data/clowne.gemspec +17 -10
- data/docs/.nojekyll +0 -0
- data/docs/.rubocop.yml +8 -2
- data/docs/CNAME +1 -0
- data/docs/README.md +131 -0
- data/docs/_sidebar.md +25 -0
- data/docs/active_record.md +4 -7
- data/docs/after_clone.md +53 -0
- data/docs/after_persist.md +77 -0
- data/docs/architecture.md +2 -5
- data/docs/assets/docsify.min.js +1 -0
- data/docs/assets/prism-ruby.min.js +1 -0
- data/docs/assets/styles.css +348 -0
- data/docs/assets/vue.css +1 -0
- data/docs/clone_mapper.md +59 -0
- data/docs/customization.md +6 -7
- data/docs/exclude_association.md +6 -8
- data/docs/finalize.md +11 -15
- data/docs/from_v02_to_v1.md +83 -0
- data/docs/getting_started.md +171 -0
- data/docs/implicit_cloner.md +2 -5
- data/docs/include_association.md +24 -10
- data/docs/index.html +29 -0
- data/docs/init_as.md +13 -9
- data/docs/inline_configuration.md +5 -6
- data/docs/nullify.md +3 -7
- data/docs/operation.md +55 -0
- data/docs/parameters.md +112 -0
- data/docs/sequel.md +16 -22
- data/docs/supported_adapters.md +3 -6
- data/docs/testing.md +194 -0
- data/docs/traits.md +1 -4
- data/gemfiles/activerecord42.gemfile +7 -5
- data/gemfiles/jruby.gemfile +8 -6
- data/gemfiles/railsmaster.gemfile +8 -6
- data/lib/clowne.rb +12 -9
- data/lib/clowne/adapters/active_record.rb +4 -5
- data/lib/clowne/adapters/active_record/associations.rb +8 -6
- data/lib/clowne/adapters/active_record/associations/base.rb +1 -5
- data/lib/clowne/adapters/active_record/associations/belongs_to.rb +29 -0
- data/lib/clowne/adapters/active_record/associations/has_one.rb +3 -2
- data/lib/clowne/adapters/active_record/dsl.rb +2 -2
- data/lib/clowne/adapters/active_record/resolvers/association.rb +38 -0
- data/lib/clowne/adapters/base.rb +49 -44
- data/lib/clowne/adapters/base/association.rb +24 -15
- data/lib/clowne/adapters/registry.rb +49 -0
- data/lib/clowne/adapters/sequel.rb +14 -10
- data/lib/clowne/adapters/sequel/associations.rb +6 -6
- data/lib/clowne/adapters/sequel/associations/base.rb +9 -5
- data/lib/clowne/adapters/sequel/associations/many_to_many.rb +6 -2
- data/lib/clowne/adapters/sequel/associations/one_to_many.rb +7 -2
- data/lib/clowne/adapters/sequel/associations/one_to_one.rb +7 -2
- data/lib/clowne/adapters/sequel/operation.rb +35 -0
- data/lib/clowne/adapters/sequel/record_wrapper.rb +0 -16
- data/lib/clowne/adapters/sequel/resolvers/after_persist.rb +22 -0
- data/lib/clowne/adapters/sequel/resolvers/association.rb +51 -0
- data/lib/clowne/adapters/sequel/specifications/after_persist_does_not_support.rb +15 -0
- data/lib/clowne/cloner.rb +49 -21
- data/lib/clowne/declarations.rb +15 -12
- data/lib/clowne/declarations/after_clone.rb +21 -0
- data/lib/clowne/declarations/after_persist.rb +21 -0
- data/lib/clowne/declarations/base.rb +13 -0
- data/lib/clowne/declarations/exclude_association.rb +2 -2
- data/lib/clowne/declarations/finalize.rb +5 -4
- data/lib/clowne/declarations/include_association.rb +16 -2
- data/lib/clowne/declarations/init_as.rb +5 -4
- data/lib/clowne/declarations/nullify.rb +4 -3
- data/lib/clowne/declarations/trait.rb +1 -0
- data/lib/clowne/dsl.rb +9 -0
- data/lib/clowne/ext/lambda_as_proc.rb +17 -0
- data/lib/clowne/ext/orm_ext.rb +1 -1
- data/lib/clowne/ext/record_key.rb +12 -0
- data/lib/clowne/ext/string_constantize.rb +9 -3
- data/lib/clowne/ext/yield_self_then.rb +25 -0
- data/lib/clowne/planner.rb +16 -3
- data/lib/clowne/resolvers/after_clone.rb +17 -0
- data/lib/clowne/resolvers/after_persist.rb +18 -0
- data/lib/clowne/resolvers/finalize.rb +12 -0
- data/lib/clowne/resolvers/init_as.rb +13 -0
- data/lib/clowne/resolvers/nullify.rb +15 -0
- data/lib/clowne/rspec.rb +5 -0
- data/lib/clowne/rspec/clone_association.rb +99 -0
- data/lib/clowne/rspec/clone_associations.rb +26 -0
- data/lib/clowne/rspec/helpers.rb +35 -0
- data/lib/clowne/utils/clone_mapper.rb +26 -0
- data/lib/clowne/utils/operation.rb +95 -0
- data/lib/clowne/utils/options.rb +39 -0
- data/lib/clowne/utils/params.rb +64 -0
- data/lib/clowne/utils/plan.rb +90 -0
- data/lib/clowne/version.rb +1 -1
- metadata +99 -45
- data/docs/alternatives.md +0 -26
- data/docs/basic_example.md +0 -66
- data/docs/configuration.md +0 -29
- data/docs/execution_order.md +0 -14
- data/docs/installation.md +0 -16
- data/docs/web/.gitignore +0 -11
- data/docs/web/core/Footer.js +0 -92
- data/docs/web/i18n/en.json +0 -134
- data/docs/web/package.json +0 -14
- data/docs/web/pages/en/help.js +0 -50
- data/docs/web/pages/en/index.js +0 -231
- data/docs/web/pages/en/users.js +0 -47
- data/docs/web/sidebars.json +0 -30
- data/docs/web/siteConfig.js +0 -44
- data/docs/web/static/css/custom.css +0 -229
- data/docs/web/static/fonts/FiraCode-Medium.woff +0 -0
- data/docs/web/static/fonts/FiraCode-Regular.woff +0 -0
- data/docs/web/static/fonts/StemText.woff +0 -0
- data/docs/web/static/fonts/StemTextBold.woff +0 -0
- data/docs/web/static/img/favicon/favicon.ico +0 -0
- data/docs/web/yarn.lock +0 -1741
- data/lib/clowne/adapters/active_record/association.rb +0 -34
- data/lib/clowne/adapters/base/finalize.rb +0 -19
- data/lib/clowne/adapters/base/init_as.rb +0 -21
- data/lib/clowne/adapters/base/nullify.rb +0 -19
- data/lib/clowne/adapters/sequel/association.rb +0 -47
- data/lib/clowne/plan.rb +0 -81
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clowne
|
4
|
+
class Resolvers
|
5
|
+
module Nullify # :nodoc: all
|
6
|
+
def self.call(_source, record, declaration, **_options)
|
7
|
+
declaration.attributes.each do |attr|
|
8
|
+
record.__send__("#{attr}=", nil)
|
9
|
+
end
|
10
|
+
|
11
|
+
record
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/clowne/rspec.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clowne
|
4
|
+
module RSpec
|
5
|
+
module Matchers # :nodoc: all
|
6
|
+
class CloneAssociation < ::RSpec::Matchers::BuiltIn::BaseMatcher
|
7
|
+
include Clowne::RSpec::Helpers
|
8
|
+
|
9
|
+
AVAILABLE_PARAMS = %i[
|
10
|
+
traits
|
11
|
+
clone_with
|
12
|
+
params
|
13
|
+
scope
|
14
|
+
].freeze
|
15
|
+
|
16
|
+
attr_reader :expected_params
|
17
|
+
|
18
|
+
def initialize(name, options)
|
19
|
+
@expected = name
|
20
|
+
extract_options! options
|
21
|
+
end
|
22
|
+
|
23
|
+
# rubocop: disable Metrics/AbcSize
|
24
|
+
def match(expected, _actual)
|
25
|
+
@actual = plan.declarations
|
26
|
+
.find { |key, decl| key == :association && decl.name == expected }
|
27
|
+
|
28
|
+
return false if @actual.nil?
|
29
|
+
|
30
|
+
@actual = actual.last
|
31
|
+
|
32
|
+
AVAILABLE_PARAMS.each do |param|
|
33
|
+
if expected_params[param] != UNDEFINED
|
34
|
+
return false if expected_params[param] != actual.send(param)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
true
|
39
|
+
end
|
40
|
+
# rubocop: enable Metrics/AbcSize
|
41
|
+
|
42
|
+
def does_not_match?(*)
|
43
|
+
raise "This matcher doesn't support negation"
|
44
|
+
end
|
45
|
+
|
46
|
+
def failure_message
|
47
|
+
if @actual.nil?
|
48
|
+
"expected to include association #{expected}, but none found"
|
49
|
+
else
|
50
|
+
params_failure_message
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def extract_options!(options)
|
57
|
+
@expected_params = {}
|
58
|
+
|
59
|
+
AVAILABLE_PARAMS.each do |param|
|
60
|
+
expected_params[param] = options.fetch(param, UNDEFINED)
|
61
|
+
end
|
62
|
+
|
63
|
+
raise ArgumentError, "Lambda scope is not supported" if
|
64
|
+
expected_params[:scope].is_a?(Proc)
|
65
|
+
|
66
|
+
raise ArgumentError, "Lambda params is not supported" if
|
67
|
+
expected_params[:params].is_a?(Proc)
|
68
|
+
end
|
69
|
+
|
70
|
+
def params_failure_message
|
71
|
+
"expected :#{@expected} association " \
|
72
|
+
"to have options #{formatted_expected_params}, " \
|
73
|
+
"but got #{formatted_actual_params}"
|
74
|
+
end
|
75
|
+
|
76
|
+
def formatted_expected_params
|
77
|
+
::RSpec::Support::ObjectFormatter.format(
|
78
|
+
expected_params.reject { |_, v| v == UNDEFINED }
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
82
|
+
def formatted_actual_params
|
83
|
+
actual_params = AVAILABLE_PARAMS.each_with_object({}) do |key, acc|
|
84
|
+
acc[key] = actual.send(key)
|
85
|
+
end
|
86
|
+
::RSpec::Support::ObjectFormatter.format(actual_params)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
RSpec.configure do |config|
|
94
|
+
config.include(Module.new do
|
95
|
+
def clone_association(expected, **options)
|
96
|
+
Clowne::RSpec::Matchers::CloneAssociation.new(expected, options)
|
97
|
+
end
|
98
|
+
end, type: :cloner)
|
99
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clowne
|
4
|
+
module RSpec
|
5
|
+
module Matchers # :nodoc: all
|
6
|
+
# `clone_associations` matcher is just an extension of `contain_exactly` matcher
|
7
|
+
class CloneAssociations < ::RSpec::Matchers::BuiltIn::ContainExactly
|
8
|
+
include Clowne::RSpec::Helpers
|
9
|
+
|
10
|
+
def convert_actual_to_an_array
|
11
|
+
@actual = plan.declarations
|
12
|
+
.select { |key, _| key == :association }
|
13
|
+
.map { |_, decl| decl.name }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
config.include(Module.new do
|
22
|
+
def clone_associations(*expected)
|
23
|
+
Clowne::RSpec::Matchers::CloneAssociations.new(expected)
|
24
|
+
end
|
25
|
+
end, type: :cloner)
|
26
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clowne
|
4
|
+
module RSpec
|
5
|
+
module Helpers # :nodoc: all
|
6
|
+
attr_reader :cloner
|
7
|
+
|
8
|
+
def with_traits(*traits)
|
9
|
+
@traits = traits
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
def matches?(actual)
|
14
|
+
raise ArgumentError, non_cloner_message unless actual <= ::Clowne::Cloner
|
15
|
+
|
16
|
+
@cloner = actual
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def plan
|
21
|
+
@plan ||=
|
22
|
+
if @traits.nil?
|
23
|
+
cloner.default_plan
|
24
|
+
else
|
25
|
+
cloner.plan_with_traits(@traits)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def non_cloner_message
|
30
|
+
"expected a cloner to be passed to `expect(...)`, " \
|
31
|
+
"but got #{actual_formatted}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "clowne/ext/record_key"
|
4
|
+
|
5
|
+
module Clowne
|
6
|
+
module Utils
|
7
|
+
class CloneMapper # :nodoc: all
|
8
|
+
def initialize
|
9
|
+
@store = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def add(origin, clone)
|
13
|
+
@store[origin] ||= clone
|
14
|
+
end
|
15
|
+
|
16
|
+
def clone_of(origin)
|
17
|
+
@store[origin]
|
18
|
+
end
|
19
|
+
|
20
|
+
def origin_of(clone)
|
21
|
+
origin, _clone = @store.rassoc(clone)
|
22
|
+
origin
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "clowne/utils/clone_mapper"
|
4
|
+
|
5
|
+
module Clowne
|
6
|
+
module Utils
|
7
|
+
class Operation # :nodoc: all
|
8
|
+
THREAD_KEY = :"#{name}.clowne_operation"
|
9
|
+
DEFAULT_MAPPER = Utils::CloneMapper
|
10
|
+
|
11
|
+
private_constant :THREAD_KEY
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def current
|
15
|
+
Thread.current[THREAD_KEY]
|
16
|
+
end
|
17
|
+
|
18
|
+
def wrap(mapper: nil)
|
19
|
+
return yield if current
|
20
|
+
|
21
|
+
Thread.current[THREAD_KEY] = new(mapper || DEFAULT_MAPPER.new)
|
22
|
+
|
23
|
+
current.tap do |operation|
|
24
|
+
operation.clone = yield
|
25
|
+
clear!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def clear!
|
30
|
+
Thread.current[THREAD_KEY] = nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
attr_writer :clone
|
35
|
+
attr_reader :mapper
|
36
|
+
|
37
|
+
def initialize(mapper)
|
38
|
+
@after_clone_blocks = []
|
39
|
+
@after_persist_blocks = []
|
40
|
+
@mapper = mapper
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_after_persist(block)
|
44
|
+
@after_persist_blocks.unshift(block)
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_after_clone(block)
|
48
|
+
@after_clone_blocks.unshift(block)
|
49
|
+
end
|
50
|
+
|
51
|
+
def add_mapping(origin, clone)
|
52
|
+
@mapper.add(origin, clone)
|
53
|
+
end
|
54
|
+
|
55
|
+
def to_record
|
56
|
+
return @_record if defined?(@_record)
|
57
|
+
|
58
|
+
run_after_clone
|
59
|
+
@_record = @clone
|
60
|
+
end
|
61
|
+
|
62
|
+
def persist!
|
63
|
+
to_record.save!.tap do
|
64
|
+
run_after_persist
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def persist
|
69
|
+
to_record.save.tap do |result|
|
70
|
+
next unless result
|
71
|
+
|
72
|
+
run_after_persist
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def save
|
77
|
+
warn "[DEPRECATION] `save` is deprecated. Please use `persist` instead."
|
78
|
+
@clone.save
|
79
|
+
end
|
80
|
+
|
81
|
+
def save!
|
82
|
+
warn "[DEPRECATION] `save!` is deprecated. Please use `persist!` instead."
|
83
|
+
@clone.save!
|
84
|
+
end
|
85
|
+
|
86
|
+
def run_after_persist
|
87
|
+
@after_persist_blocks.each(&:call)
|
88
|
+
end
|
89
|
+
|
90
|
+
def run_after_clone
|
91
|
+
@after_clone_blocks.each(&:call)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clowne
|
4
|
+
module Utils # :nodoc: all
|
5
|
+
class Options
|
6
|
+
INTERNAL_KEYS = %i[adapter traits clowne_only_actions mapping only].freeze
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def traits
|
13
|
+
@_traits ||= Array(options[:traits])
|
14
|
+
end
|
15
|
+
|
16
|
+
def only
|
17
|
+
options[:clowne_only_actions]
|
18
|
+
end
|
19
|
+
|
20
|
+
def mapper
|
21
|
+
options[:mapper]
|
22
|
+
end
|
23
|
+
|
24
|
+
def adapter
|
25
|
+
options[:adapter]
|
26
|
+
end
|
27
|
+
|
28
|
+
def params
|
29
|
+
options.dup.tap do |o|
|
30
|
+
INTERNAL_KEYS.each { |key| o.delete(key) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_reader :options
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "clowne/ext/lambda_as_proc"
|
4
|
+
|
5
|
+
module Clowne
|
6
|
+
module Utils
|
7
|
+
class Params # :nodoc: all
|
8
|
+
class BaseProxy
|
9
|
+
attr_reader :value
|
10
|
+
|
11
|
+
def initialize(value)
|
12
|
+
@value = value
|
13
|
+
end
|
14
|
+
|
15
|
+
def permit(_params)
|
16
|
+
raise NotImplementedError
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class PassProxy < BaseProxy
|
21
|
+
def permit(params:, **)
|
22
|
+
params
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class NullProxy < BaseProxy
|
27
|
+
def permit(_params)
|
28
|
+
{}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class BlockProxy < BaseProxy
|
33
|
+
using Clowne::Ext::LambdaAsProc
|
34
|
+
|
35
|
+
def permit(params:, parent:)
|
36
|
+
value.to_proc.call(params, parent)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class KeyProxy < BaseProxy
|
41
|
+
def permit(params:, **)
|
42
|
+
nested_params = params.fetch(value)
|
43
|
+
return nested_params if nested_params.is_a?(Hash)
|
44
|
+
|
45
|
+
raise KeyError, "value by key '#{value}' must be a Hash"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class << self
|
50
|
+
def proxy(value)
|
51
|
+
if value == true
|
52
|
+
PassProxy
|
53
|
+
elsif value.nil? || value == false
|
54
|
+
NullProxy
|
55
|
+
elsif value.is_a?(Proc)
|
56
|
+
BlockProxy
|
57
|
+
else
|
58
|
+
KeyProxy
|
59
|
+
end.new(value)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Clowne
|
4
|
+
module Utils
|
5
|
+
class Plan # :nodoc: all
|
6
|
+
class TwoPhaseSet
|
7
|
+
def initialize
|
8
|
+
@added = {}
|
9
|
+
@removed = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def []=(k, v)
|
13
|
+
return if @removed.include?(k)
|
14
|
+
|
15
|
+
@added[k] = v
|
16
|
+
end
|
17
|
+
|
18
|
+
def delete(k)
|
19
|
+
return if @removed.include?(k)
|
20
|
+
|
21
|
+
@removed << k
|
22
|
+
@added.delete(k)
|
23
|
+
end
|
24
|
+
|
25
|
+
def values
|
26
|
+
@added.values
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(registry)
|
31
|
+
@registry = registry
|
32
|
+
@data = {}
|
33
|
+
end
|
34
|
+
|
35
|
+
def add(type, declaration)
|
36
|
+
data[type] = [] unless data.key?(type)
|
37
|
+
data[type] << declaration
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_to(type, id, declaration)
|
41
|
+
data[type] = TwoPhaseSet.new unless data.key?(type)
|
42
|
+
data[type][id] = declaration
|
43
|
+
end
|
44
|
+
|
45
|
+
def set(type, declaration)
|
46
|
+
data[type] = declaration
|
47
|
+
end
|
48
|
+
|
49
|
+
def get(type)
|
50
|
+
data[type]
|
51
|
+
end
|
52
|
+
|
53
|
+
def remove(type)
|
54
|
+
data.delete(type)
|
55
|
+
end
|
56
|
+
|
57
|
+
def remove_from(type, id)
|
58
|
+
return unless data[type]
|
59
|
+
|
60
|
+
data[type].delete(id)
|
61
|
+
end
|
62
|
+
|
63
|
+
def declarations(reload = false)
|
64
|
+
return @declarations if !reload && instance_variable_defined?(:@declarations)
|
65
|
+
|
66
|
+
@declarations =
|
67
|
+
registry.actions.flat_map do |type|
|
68
|
+
value = data[type]
|
69
|
+
next if value.nil?
|
70
|
+
|
71
|
+
value = value.values if value.is_a?(TwoPhaseSet)
|
72
|
+
value = Array(value)
|
73
|
+
value.map { |v| [type, v] }
|
74
|
+
end.compact
|
75
|
+
end
|
76
|
+
|
77
|
+
def dup
|
78
|
+
self.class.new(registry).tap do |duped|
|
79
|
+
data.each do |k, v|
|
80
|
+
duped.set(k, v.dup)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
attr_reader :data, :registry
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|