clowne 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/.travis.yml +6 -3
- data/CHANGELOG.md +14 -0
- data/Gemfile +1 -1
- data/README.md +30 -9
- data/clowne.gemspec +4 -3
- data/docs/active_record.md +2 -2
- data/docs/after_persist.md +80 -0
- data/docs/basic_example.md +22 -5
- data/docs/clone_mapper.md +62 -0
- data/docs/customization.md +2 -1
- data/docs/exclude_association.md +5 -4
- data/docs/finalize.md +2 -2
- data/docs/from_v02_to_v1.md +91 -0
- data/docs/implicit_cloner.md +1 -1
- data/docs/include_association.md +4 -4
- data/docs/init_as.md +10 -2
- data/docs/inline_configuration.md +4 -2
- data/docs/installation.md +31 -1
- data/docs/nullify.md +2 -2
- data/docs/operation.md +58 -0
- data/docs/overview.md +24 -0
- data/docs/parameters.md +5 -4
- data/docs/sequel.md +15 -18
- data/docs/supported_adapters.md +2 -2
- data/docs/testing.md +7 -5
- data/docs/web/README.md +6 -0
- data/docs/web/core/Footer.js +5 -9
- data/docs/web/i18n/en.json +8 -4
- data/docs/web/pages/en/index.js +1 -1
- data/docs/web/sidebars.json +10 -4
- data/docs/web/siteConfig.js +6 -4
- data/docs/web/static/css/custom.css +16 -10
- data/gemfiles/activerecord42.gemfile +3 -1
- data/gemfiles/jruby.gemfile +2 -0
- data/gemfiles/railsmaster.gemfile +2 -0
- data/lib/clowne.rb +3 -0
- data/lib/clowne/adapters/active_record.rb +2 -3
- data/lib/clowne/adapters/active_record/associations/base.rb +0 -4
- data/lib/clowne/adapters/active_record/associations/has_one.rb +2 -1
- data/lib/clowne/adapters/active_record/resolvers/association.rb +38 -0
- data/lib/clowne/adapters/base.rb +42 -43
- data/lib/clowne/adapters/base/association.rb +24 -15
- data/lib/clowne/adapters/registry.rb +49 -0
- data/lib/clowne/adapters/sequel.rb +10 -6
- data/lib/clowne/adapters/sequel/associations/base.rb +8 -4
- 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 +32 -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 +27 -20
- data/lib/clowne/declarations.rb +2 -1
- data/lib/clowne/declarations/after_persist.rb +21 -0
- data/lib/clowne/declarations/finalize.rb +1 -0
- data/lib/clowne/declarations/include_association.rb +2 -1
- data/lib/clowne/declarations/init_as.rb +1 -0
- data/lib/clowne/declarations/nullify.rb +1 -0
- data/lib/clowne/declarations/trait.rb +1 -0
- data/lib/clowne/dsl.rb +9 -0
- data/lib/clowne/ext/lambda_as_proc.rb +1 -0
- data/lib/clowne/ext/record_key.rb +12 -0
- data/lib/clowne/ext/yield_self_then.rb +25 -0
- data/lib/clowne/planner.rb +6 -3
- 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/helpers.rb +1 -0
- data/lib/clowne/utils/clone_mapper.rb +26 -0
- data/lib/clowne/utils/operation.rb +83 -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 +44 -18
- data/docs/configuration.md +0 -29
- data/docs/execution_order.md +0 -14
- data/docs/web/static/fonts/StemText.woff +0 -0
- data/docs/web/static/fonts/StemTextBold.woff +0 -0
- 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/params.rb +0 -62
- data/lib/clowne/plan.rb +0 -83
data/lib/clowne/plan.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Clowne
|
4
|
-
class Plan # :nodoc: all
|
5
|
-
class TwoPhaseSet
|
6
|
-
def initialize
|
7
|
-
@added = {}
|
8
|
-
@removed = []
|
9
|
-
end
|
10
|
-
|
11
|
-
def []=(k, v)
|
12
|
-
return if @removed.include?(k)
|
13
|
-
@added[k] = v
|
14
|
-
end
|
15
|
-
|
16
|
-
def delete(k)
|
17
|
-
return if @removed.include?(k)
|
18
|
-
@removed << k
|
19
|
-
@added.delete(k)
|
20
|
-
end
|
21
|
-
|
22
|
-
def values
|
23
|
-
@added.values
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def initialize(registry)
|
28
|
-
@registry = registry
|
29
|
-
@data = {}
|
30
|
-
end
|
31
|
-
|
32
|
-
def add(type, declaration)
|
33
|
-
data[type] = [] unless data.key?(type)
|
34
|
-
data[type] << declaration
|
35
|
-
end
|
36
|
-
|
37
|
-
def add_to(type, id, declaration)
|
38
|
-
data[type] = TwoPhaseSet.new unless data.key?(type)
|
39
|
-
data[type][id] = declaration
|
40
|
-
end
|
41
|
-
|
42
|
-
def set(type, declaration)
|
43
|
-
data[type] = declaration
|
44
|
-
end
|
45
|
-
|
46
|
-
def get(type)
|
47
|
-
data[type]
|
48
|
-
end
|
49
|
-
|
50
|
-
def remove(type)
|
51
|
-
data.delete(type)
|
52
|
-
end
|
53
|
-
|
54
|
-
def remove_from(type, id)
|
55
|
-
return unless data[type]
|
56
|
-
data[type].delete(id)
|
57
|
-
end
|
58
|
-
|
59
|
-
def declarations(reload = false)
|
60
|
-
return @declarations if !reload && instance_variable_defined?(:@declarations)
|
61
|
-
@declarations =
|
62
|
-
registry.actions.flat_map do |type|
|
63
|
-
value = data[type]
|
64
|
-
next if value.nil?
|
65
|
-
value = value.values if value.is_a?(TwoPhaseSet)
|
66
|
-
value = Array(value)
|
67
|
-
value.map { |v| [type, v] }
|
68
|
-
end.compact
|
69
|
-
end
|
70
|
-
|
71
|
-
def dup
|
72
|
-
self.class.new(registry).tap do |duped|
|
73
|
-
data.each do |k, v|
|
74
|
-
duped.set(k, v.dup)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
private
|
80
|
-
|
81
|
-
attr_reader :data, :registry
|
82
|
-
end
|
83
|
-
end
|