ducktape 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ducktape/bindable.rb +1 -1
- data/lib/ducktape/bindable_attribute_metadata.rb +11 -10
- data/lib/ducktape/hookable.rb +6 -5
- data/lib/ducktape/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8a085735246f605392018ae227b1ff561bb2a12
|
4
|
+
data.tar.gz: 2d3baf29ccdb08ac0728b3cf34b5e602a7cb6e94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c74d85e393cf8a48fcf2f3596f4cca53f4c0d3d35fdb948a1117037080db06f429133f2b5241f95ae1736b74a0282a5221ec0c43a3183a1a8418e4509c90577
|
7
|
+
data.tar.gz: 65367871b957ae760debacf750b2b3702c56dc7432b521d91efc4ad606e9f68c931ce59745ceccad3430ab0dd31f55ba94b9887d76c110c7ef28a032adec3d45
|
data/lib/ducktape/bindable.rb
CHANGED
@@ -12,16 +12,16 @@ module Ducktape
|
|
12
12
|
options.keys.reject { |k| VALID_OPTIONS.member?(k) }.
|
13
13
|
each { |k| $stderr.puts "WARNING: invalid option #{k.inspect} for #{name.inspect} attribute. Will be ignored." }
|
14
14
|
|
15
|
-
if name.is_a?(BindableAttributeMetadata)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
@name = if name.is_a?(BindableAttributeMetadata)
|
16
|
+
options = name.send(:as_options).merge!(options)
|
17
|
+
name.name
|
18
|
+
else
|
19
|
+
name
|
20
|
+
end
|
21
21
|
|
22
22
|
@default = options[:default]
|
23
23
|
@validation = validation(*options[:validate])
|
24
|
-
@coercion = options[:coerce]
|
24
|
+
@coercion = options[:coerce]
|
25
25
|
@access = options[:access] || :both
|
26
26
|
@getter = options[:getter]
|
27
27
|
@setter = options[:setter]
|
@@ -59,8 +59,9 @@ module Ducktape
|
|
59
59
|
raise InvalidAttributeValueError.new(@name, value) unless valid?(value)
|
60
60
|
end
|
61
61
|
|
62
|
-
def coercion(&block)
|
63
|
-
|
62
|
+
def coercion(proc_obj = nil, &block)
|
63
|
+
raise ArgumentError, 'Expected only a parameter or a block, but both were passed.' if proc_obj && block
|
64
|
+
@coercion = block || proc_obj
|
64
65
|
end
|
65
66
|
|
66
67
|
def coerce(owner, value)
|
@@ -68,7 +69,7 @@ module Ducktape
|
|
68
69
|
end
|
69
70
|
|
70
71
|
def self.register_validator(validator_class)
|
71
|
-
@validators
|
72
|
+
@validators.unshift validator_class
|
72
73
|
end
|
73
74
|
|
74
75
|
private
|
data/lib/ducktape/hookable.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module Ducktape
|
2
2
|
module Hookable
|
3
3
|
def self.included(base)
|
4
|
+
base.extend ClassMethods
|
5
|
+
|
4
6
|
if base.is_a?(Class)
|
5
7
|
base.include InstanceMethods
|
6
|
-
base.extend ClassMethods
|
7
8
|
base.def_hook(:on_changed) unless base.method_defined?(:on_changed)
|
8
9
|
return
|
9
10
|
end
|
@@ -90,12 +91,12 @@ module Ducktape
|
|
90
91
|
define_method(original_method.name) do |*args, &block|
|
91
92
|
bound_method = original_method.bind(self)
|
92
93
|
result = bound_method.(*args, &block)
|
93
|
-
params = OpenStruct.new(args: args, result: result)
|
94
|
+
params = OpenStruct.new(args: args, method: original_method.name, result: result)
|
94
95
|
call_name = "call_#{ type }s"
|
95
|
-
|
96
|
-
unless
|
96
|
+
hook_result = send(call_name, hook_name, self, params)
|
97
|
+
unless hook_result && type == :handler
|
97
98
|
# invoke if previous call is false or nil
|
98
|
-
send call_name, :on_changed,
|
99
|
+
send call_name, :on_changed, self, params
|
99
100
|
end
|
100
101
|
result
|
101
102
|
end
|
data/lib/ducktape/version.rb
CHANGED
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.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SilverPhoenix99
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: facets
|
@@ -110,7 +110,7 @@ post_install_message: |
|
|
110
110
|
Thank you for choosing Ducktape.
|
111
111
|
|
112
112
|
==========================================================================
|
113
|
-
0.5.
|
113
|
+
0.5.1 Changes:
|
114
114
|
- Added Bindable::bind method to wrap BindingSource construction.
|
115
115
|
- Added support for Range validation in bindable attributes.
|
116
116
|
- Internal refactorings.
|