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


58
59
60
61
62
63
# File 'lib/attr_private.rb', line 58

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


50
51
52
53
54
55
# File 'lib/attr_private.rb', line 50

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