Module: Ronin::Model::HasUniqueName::ClassMethods

Defined in:
lib/ronin/model/has_unique_name.rb

Overview

Class methods that will be added when Ronin::Model::HasUniqueName is included.

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Model?

Searches for models with the unique name.

Parameters:

  • key (String, Symbol, Integer)

    The unique name or index to search for.

Returns:

  • (Model, nil)

    The matching model.

Since:

  • 1.0.0



67
68
69
70
71
72
73
74
# File 'lib/ronin/model/has_unique_name.rb', line 67

def [](key)
  case key
  when String, Symbol
    first(:name => key.to_s)
  else
    super(key)
  end
end