Module: AttrPrivate::SingletonMethods::ClassMethods

Defined in:
lib/attr_private.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missingObject Also known as: method_missing_without_parameter_exclusion



52
53
54
55
56
57
# File 'lib/attr_private.rb', line 52

def method_missing_with_parameter_exclusion(name, *args)
  private_fields.each do |field|
    raise ::NoMethodError, "undefined method `#{name}' for #{self}" if /_#{field}_|_#{field}$/.match(name.to_s)
  end
  method_missing_without_parameter_exclusion(name, args) 
end

Instance Method Details

#method_missing_with_parameter_exclusion(name, *args) ⇒ Object Also known as: method_missing



44
45
46
47
48
49
# File 'lib/attr_private.rb', line 44

def method_missing_with_parameter_exclusion(name, *args)
  private_fields.each do |field|
    raise ::NoMethodError, "undefined method `#{name}' for #{self}" if /_#{field}_|_#{field}$/.match(name.to_s)
  end
  method_missing_without_parameter_exclusion(name, args) 
end