Class: Nyanko::Unit::ScopeFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/nyanko/unit/scope_finder.rb

Constant Summary collapse

LABEL_SCOPE_MAP =
{
  :controller => ActionController::Base,
  :model      => ActiveRecord::Base,
  :view       => ActionView::Base,
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier) ⇒ ScopeFinder

Returns a new instance of ScopeFinder.



14
15
16
# File 'lib/nyanko/unit/scope_finder.rb', line 14

def initialize(identifier)
  @identifier = identifier
end

Class Method Details

.find(*args) ⇒ Object



10
11
12
# File 'lib/nyanko/unit/scope_finder.rb', line 10

def self.find(*args)
  new(*args).find
end

Instance Method Details

#findObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/nyanko/unit/scope_finder.rb', line 18

def find
  case
  when class?
    @identifier
  when label
    label
  else
    @identifier.to_s.constantize
  end
rescue NameError
end