Class: Ducktape::BindableAttribute
- Inherits:
-
Object
- Object
- Ducktape::BindableAttribute
- Includes:
- Hookable
- Defined in:
- lib/ducktape/bindable_attribute.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Bindable.
-
#owner ⇒ Object
readonly
Bindable.
-
#value ⇒ Object
Bindable.
Instance Method Summary collapse
- #binding_source ⇒ Object
- #has_source? ⇒ Boolean
-
#initialize(owner, name) ⇒ BindableAttribute
constructor
:source # Link - link between source and target.
- #metadata ⇒ Object
-
#remove_source(reset = true) ⇒ Object
After unbinding the source the value can be reset, or kept.
- #reset_value ⇒ Object
- #to_s ⇒ Object
Methods included from Hookable
#add_hook, #clear_hooks, extended, included, #remove_hook
Constructor Details
#initialize(owner, name) ⇒ BindableAttribute
:source # Link - link between source and target
18 19 20 21 22 |
# File 'lib/ducktape/bindable_attribute.rb', line 18 def initialize(owner, name) @owner, @name, = owner, name.to_s @source = nil reset_value end |
Instance Attribute Details
#name ⇒ Object (readonly)
Bindable
13 14 15 |
# File 'lib/ducktape/bindable_attribute.rb', line 13 def name @name end |
#owner ⇒ Object (readonly)
Bindable
13 14 15 |
# File 'lib/ducktape/bindable_attribute.rb', line 13 def owner @owner end |
#value ⇒ Object
Bindable
13 14 15 |
# File 'lib/ducktape/bindable_attribute.rb', line 13 def value @value end |
Instance Method Details
#binding_source ⇒ Object
24 25 26 27 |
# File 'lib/ducktape/bindable_attribute.rb', line 24 def binding_source return unless @source @source.binding_source end |
#has_source? ⇒ Boolean
29 30 31 |
# File 'lib/ducktape/bindable_attribute.rb', line 29 def has_source? !!@source end |
#metadata ⇒ Object
33 34 35 |
# File 'lib/ducktape/bindable_attribute.rb', line 33 def @owner.send(:metadata, @name) end |
#remove_source(reset = true) ⇒ Object
After unbinding the source the value can be reset, or kept. The default is to reset the target’s (self) value.
39 40 41 42 43 44 45 |
# File 'lib/ducktape/bindable_attribute.rb', line 39 def remove_source(reset = true) return unless @source src, @source = @source, nil src.unbind reset_value if reset src.binding_source end |
#reset_value ⇒ Object
47 48 49 |
# File 'lib/ducktape/bindable_attribute.rb', line 47 def reset_value set_value(.default) end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/ducktape/bindable_attribute.rb', line 55 def to_s "#<#{self.class}:0x#{object_id.to_s(16)} @name=#{name}>" end |