Method: Aspire::Object::ResourcePropertyMixin#get_property_name_from_method

Defined in:
lib/aspire/object/resource.rb

#get_property_name_from_method(method_name, _include_all = false) ⇒ String?

Returns the property name from a citation_<property> missing method call

Parameters:

  • method_name (Symbol)

    the method name

  • _include_all (Boolean) (defaults to: false)

    if true, include private/protected methods

Returns:

  • (String, nil)

    the property name, or nil if not a valid property



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/aspire/object/resource.rb', line 43

def get_property_name_from_method(method_name, _include_all = false)
  # Ignore method names not beginning with citation_
  return nil unless method_name.to_s.start_with?('citation_')
  # Remove the 'citation_' prefix to get the property name
  property = method_name[9..-1]
  return nil if property.nil? || property.empty?
  # Accept only whitelisted properties
  return nil unless CITATION_PROPERTIES.include?(property)
  # Accept only properties with accessor methods
  return nil unless respond_to?(property)
  # Return the property name
  property
end