nakajima-fixjour 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/core_ext/object.rb +6 -0
- data/lib/fixjour/merging_proxy.rb +25 -1
- metadata +2 -1
@@ -9,13 +9,37 @@ module Fixjour
|
|
9
9
|
@klass = klass
|
10
10
|
@overrides = overrides
|
11
11
|
end
|
12
|
+
|
13
|
+
def protected(*attrs)
|
14
|
+
attrs = attrs.empty? ?
|
15
|
+
@protected :
|
16
|
+
@protected = attrs
|
17
|
+
Set.new(attrs)
|
18
|
+
end
|
12
19
|
|
13
20
|
def new(defaults={})
|
14
|
-
|
21
|
+
attrs = defaults.merge(@overrides)
|
22
|
+
accessible, inaccessible = partition(attrs)
|
23
|
+
returning @klass.new(accessible) do |instance|
|
24
|
+
inaccessible.each do |key,val|
|
25
|
+
instance.send("#{key}=", val)
|
26
|
+
end
|
27
|
+
end
|
15
28
|
end
|
16
29
|
|
17
30
|
def method_missing(sym, *args, &block)
|
18
31
|
@klass.respond_to?(sym) ? @klass.send(sym, *args, &block) : super
|
19
32
|
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def partition(attrs)
|
37
|
+
accessible = attrs.keys.inject({ }) do |m, key|
|
38
|
+
next m if protected.include?(key)
|
39
|
+
m[key] = attrs.delete(key)
|
40
|
+
m
|
41
|
+
end
|
42
|
+
[accessible, attrs]
|
43
|
+
end
|
20
44
|
end
|
21
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nakajima-fixjour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Nakajima
|
@@ -32,6 +32,7 @@ extra_rdoc_files: []
|
|
32
32
|
files:
|
33
33
|
- lib/core_ext
|
34
34
|
- lib/core_ext/hash.rb
|
35
|
+
- lib/core_ext/object.rb
|
35
36
|
- lib/fixjour
|
36
37
|
- lib/fixjour/builders.rb
|
37
38
|
- lib/fixjour/definitions.rb
|