class Putter::WatcherData

Attributes

label[RW]
proxy_methods[RW]

Public Class Methods

new(options, klass) click to toggle source
# File lib/putter/watcher_data.rb, line 5
def initialize(options, klass)
  @label = set_label(options[:label], klass)
  @proxy_methods = set_methods(options[:methods], klass.singleton_class)
end

Public Instance Methods

methods_to_proxy(singleton_klass) click to toggle source
# File lib/putter/watcher_data.rb, line 28
def methods_to_proxy(singleton_klass)
  ignored_methods = Putter.configuration.methods_denylist.map(&:to_sym)

  Putter.configuration.ignore_methods_from.each do |klass|
    ignored_methods += klass.methods
  end

  allowlist = Putter.configuration.methods_allowlist.map(&:to_sym) + [:new]

  singleton_klass.instance_methods - ignored_methods + allowlist
end
set_label(label, klass) click to toggle source
# 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) click to toggle source
# 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