Class: Motion::Xray::PropertyEditor
- Defined in:
- lib/motion-xray/xray_editors.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Editor
Instance Method Summary collapse
- #get_value ⇒ Object
-
#initialize(target, property) ⇒ PropertyEditor
constructor
A new instance of PropertyEditor.
- #set_value(value) ⇒ Object
Methods inherited from Editor
#did_change?, #get_edit_view, with_target
Constructor Details
#initialize(target, property) ⇒ PropertyEditor
Returns a new instance of PropertyEditor.
34 35 36 37 |
# File 'lib/motion-xray/xray_editors.rb', line 34 def initialize(target, property) super @original = get_value end |
Instance Method Details
#get_value ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/motion-xray/xray_editors.rb', line 39 def get_value if target.respond_to?(property) return target.send(property) elsif target.respond_to?("#{property}?") value = target.send("#{property}?") return target.send("#{property}?") end end |
#set_value(value) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/motion-xray/xray_editors.rb', line 48 def set_value(value) assign = "#{property}=" setter = "set#{property.sub(/^./) { |c| c.upcase }}" if target.respond_to?(assign) target.send(assign, value) elsif target.respond_to?(setter) target.send(setter, value) end XrayTargetDidChangeNotification.post_notification(@target, { 'property' => @property, 'value' => value, 'original' => @original }) end |