Class: Banken::LoyaltyFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/banken/loyalty_finder.rb

Constant Summary collapse

SUFFIX =
"Loyalty"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ LoyaltyFinder

Returns a new instance of LoyaltyFinder.



7
8
9
# File 'lib/banken/loyalty_finder.rb', line 7

def initialize(controller)
  @controller = controller.to_s
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



5
6
7
# File 'lib/banken/loyalty_finder.rb', line 5

def controller
  @controller
end

Instance Method Details

#loyaltyObject



11
12
13
14
15
# File 'lib/banken/loyalty_finder.rb', line 11

def loyalty
  loyalty_name.constantize
rescue NameError
  nil
end

#loyalty!Object

Raises:



17
18
19
20
# File 'lib/banken/loyalty_finder.rb', line 17

def loyalty!
  raise NotDefinedError, "unable to find loyalty of nil" unless controller
  loyalty || raise(NotDefinedError, "unable to find loyalty `#{loyalty_name}` for `#{controller}`")
end