Method: Collins::Asset#method_missing

Defined in:
lib/collins/asset.rb

#method_missing(m, *args, &block) ⇒ NilClass, Object (protected)

Note:

This is never called directly

Convenience method for #get_attribute

This ‘magic’ method allows you to retrieve attributes on an asset, or check if an attribute exists via a predicate method.

Examples:

real_asset.hostname # => "foo"
bare_asset.hostname # => nil
real_asset.hostname? # => true
bare_asset.hostname? # => false

Returns:

  • (NilClass, Object)

    Nil if attribute not found, otherwise the attribute value



251
252
253
254
255
256
257
258
259
260
# File 'lib/collins/asset.rb', line 251

def method_missing(m, *args, &block)
  name = m.to_s.upcase
  is_bool = name.end_with?('?')
  if is_bool then
    name = name.sub('?', '')
    respond_to?(name)
  else
    extract(extras, "ATTRIBS", "0", name)
  end
end