Class: Enumpath::Resolver::Property

Inherits:
Object
  • Object
show all
Defined in:
lib/enumpath/resolver/property.rb

Overview

A utility for resolving a string as a property of an object

Class Method Summary collapse

Class Method Details

.resolve(property, object) ⇒ Object

Attempts to resolve a string as a property of an object. In this context a property is a public method that expects no arguments.

Parameters:

  • property (String)

    the name of the property to attempt to resolve

  • object (Object)

    the object to resolve the property against

Returns:

  • the resolved property value, or nil if it could not be resolved



14
15
16
17
18
19
# File 'lib/enumpath/resolver/property.rb', line 14

def resolve(property, object)
  # TODO: return if Enumpath.disable_property_resolver
  object.public_send(property.to_s.to_sym)
rescue ArgumentError, NoMethodError
  nil
end