class Putter::FollowerData

Attributes

label[RW]

Public Class Methods

new(object, proxy, options) click to toggle source
# File lib/putter/follower_data.rb, line 5
def initialize(object, proxy, options)
  @proxy = proxy
  @proxied_methods = options[:methods] || []
  set_label(options[:label], object)
end

Public Instance Methods

add_method?(method) click to toggle source
# File lib/putter/follower_data.rb, line 11
def add_method?(method)
  return false if @proxy.instance_methods.include?(method)
  return true if @proxied_methods.include?(method)
  return true if is_allowed_method?(method)
  return false if is_denied_method?(method)
  return false if is_ignored_method?(method)
  return true if @proxied_methods.empty?
end

Private Instance Methods

is_allowed_method?(method) click to toggle source
# File lib/putter/follower_data.rb, line 32
def is_allowed_method?(method)
  ::Putter.configuration.methods_allowlist.map(&:to_sym).include?(method.to_sym)
end
is_denied_method?(method) click to toggle source
# File lib/putter/follower_data.rb, line 36
def is_denied_method?(method)
  ::Putter.configuration.methods_denylist.map(&:to_sym).include?(method.to_sym)
end
is_ignored_method?(method) click to toggle source
# File lib/putter/follower_data.rb, line 40
def is_ignored_method?(method)
  ::Putter.configuration.ignore_methods_from.each do |klass|
    return true if klass.methods.include?(method.to_sym)
    return true if klass.instance_methods.include?(method.to_sym)
  end
  return false
end
set_label(label, object) click to toggle source
# File lib/putter/follower_data.rb, line 22
def set_label(label, object)
  if !label.nil?
    @label = label
  elsif object.class == Class
    @label = object.name
  else
    @label = object.class.name + " instance"
  end
end