Class: Putter::WatcherData
- Inherits:
-
Object
- Object
- Putter::WatcherData
- Defined in:
- lib/putter/watcher_data.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
Returns the value of attribute label.
-
#proxy_methods ⇒ Object
Returns the value of attribute proxy_methods.
Instance Method Summary collapse
-
#initialize(options, klass) ⇒ WatcherData
constructor
A new instance of WatcherData.
- #methods_to_proxy(singleton_klass) ⇒ Object
- #set_label(label, klass) ⇒ Object
- #set_methods(methods, singleton_klass) ⇒ Object
Constructor Details
#initialize(options, klass) ⇒ WatcherData
Returns a new instance of WatcherData.
5 6 7 8 |
# File 'lib/putter/watcher_data.rb', line 5 def initialize(, klass) @label = set_label([:label], klass) @proxy_methods = set_methods([:methods], klass.singleton_class) end |
Instance Attribute Details
#label ⇒ Object
Returns the value of attribute label.
3 4 5 |
# File 'lib/putter/watcher_data.rb', line 3 def label @label end |
#proxy_methods ⇒ Object
Returns the value of attribute proxy_methods.
3 4 5 |
# File 'lib/putter/watcher_data.rb', line 3 def proxy_methods @proxy_methods end |
Instance Method Details
#methods_to_proxy(singleton_klass) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/putter/watcher_data.rb', line 28 def methods_to_proxy(singleton_klass) ignored_methods = Putter.configuration.methods_blacklist.map(&:to_sym) Putter.configuration.ignore_methods_from.each do |klass| ignored_methods += klass.methods end whitelist = Putter.configuration.methods_whitelist.map(&:to_sym) + [:new] singleton_klass.instance_methods - ignored_methods + whitelist end |
#set_label(label, klass) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/putter/watcher_data.rb', line 10 def set_label(label, klass) if !label.nil? && label != "" label else klass.name end end |
#set_methods(methods, singleton_klass) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/putter/watcher_data.rb', line 18 def set_methods(methods, singleton_klass) if methods.nil? methods_to_proxy(singleton_klass) elsif !methods.is_a?(Array) [methods] else methods end end |