Class: Flame::Router::Route

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/flame/router/route.rb

Overview

Class for Route in Router.routes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, action) ⇒ Route

Create a new instance

Parameters:



19
20
21
22
# File 'lib/flame/router/route.rb', line 19

def initialize(controller, action)
  @controller = controller
  @action = action
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



12
13
14
# File 'lib/flame/router/route.rb', line 12

def action
  @action
end

#controllerObject (readonly)

Returns the value of attribute controller.



12
13
14
# File 'lib/flame/router/route.rb', line 12

def controller
  @controller
end

Instance Method Details

#==(other) ⇒ true, false

Method for Routes comparison

Parameters:

Returns:

  • (true, false)

    equal or not



27
28
29
30
31
32
33
34
35
# File 'lib/flame/router/route.rb', line 27

def ==(other)
  return false unless other.is_a? self.class

  i[controller action].reduce(true) do |result, method|
    result && (
      public_send(method) == other.public_send(method)
    )
  end
end

#to_sObject



37
38
39
# File 'lib/flame/router/route.rb', line 37

def to_s
  "#{controller}##{action}"
end