ducktape 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ducktape/bindable.rb +9 -10
- data/lib/ducktape/hookable_array.rb +5 -0
- metadata +2 -1
data/lib/ducktape/bindable.rb
CHANGED
@@ -7,15 +7,10 @@ module Ducktape
|
|
7
7
|
|
8
8
|
module Bindable
|
9
9
|
module ClassMethods
|
10
|
-
def inherited(child)
|
11
|
-
super
|
12
|
-
child.instance_eval { @bindings_metadata = {} }
|
13
|
-
end
|
14
|
-
|
15
10
|
def bindable(name, options = {})
|
16
11
|
name = name.to_s
|
17
12
|
m = BindableAttributeMetadata.new(metadata(name) || name, options)
|
18
|
-
|
13
|
+
bindings_metadata[name] = m
|
19
14
|
define_method name, ->() { get_value(name) } unless options[:access] == :writeonly
|
20
15
|
define_method "#{name}=", ->(value) { set_value(name, value) } unless options[:access] == :readonly
|
21
16
|
nil
|
@@ -24,17 +19,21 @@ module Ducktape
|
|
24
19
|
#TODO improve metadata search
|
25
20
|
def metadata(name)
|
26
21
|
name = name.to_s
|
27
|
-
m =
|
22
|
+
m = bindings_metadata[name]
|
28
23
|
return m if m
|
29
24
|
return nil unless superclass.respond_to?(:metadata) && (m = superclass.metadata(name))
|
30
25
|
m = m.dup
|
31
|
-
|
26
|
+
bindings_metadata[name] = m
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
def bindings_metadata
|
31
|
+
@bindings_metadata ||= {}
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.included(base)
|
36
36
|
base.extend(ClassMethods)
|
37
|
-
base.instance_eval { @bindings_metadata = {} }
|
38
37
|
end
|
39
38
|
|
40
39
|
def self.extended(_)
|
@@ -78,7 +77,7 @@ module Ducktape
|
|
78
77
|
end
|
79
78
|
|
80
79
|
def get_bindable_attr(name)
|
81
|
-
raise AttributeNotDefinedError.new(self.class, name.to_s) unless metadata(name)
|
80
|
+
raise AttributeNotDefinedError.new(self.class, name.to_s) unless self.class.metadata(name)
|
82
81
|
bindable_attrs[name.to_s] ||= BindableAttribute.new(self, name)
|
83
82
|
end
|
84
83
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ducktape
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- lib/ducktape/bindable_attribute_metadata.rb
|
27
27
|
- lib/ducktape/binding_source.rb
|
28
28
|
- lib/ducktape/hookable.rb
|
29
|
+
- lib/ducktape/hookable_array.rb
|
29
30
|
homepage: https://github.com/SilverPhoenix99/ducktape
|
30
31
|
licenses: []
|
31
32
|
post_install_message:
|