class Cattri::Context

def method_defined?(attribute, name: nil)

Returns:
  • (Boolean) -

Parameters:
  • name (Symbol, nil) --
  • attribute (Cattri::Attribute) --
def method_defined?(attribute, name: nil)
  normalized_name = (name || attribute.name).to_sym
  target = target_for(attribute)
  defined_locally = (
    target.public_instance_methods(false) +
      target.protected_instance_methods(false) +
      target.private_instance_methods(false)
  )
  defined_locally.include?(normalized_name) ||
    __cattri_defined_methods[attribute.name].include?(normalized_name)
end