Class: Terrazzo::Namespace::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/terrazzo/namespace/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(route) ⇒ Resource

Returns a new instance of Resource.



6
7
8
# File 'lib/terrazzo/namespace/resource.rb', line 6

def initialize(route)
  @route = route
end

Instance Attribute Details

#routeObject (readonly)

Returns the value of attribute route.



4
5
6
# File 'lib/terrazzo/namespace/resource.rb', line 4

def route
  @route
end

Instance Method Details

#==(other) ⇒ Object



26
27
28
# File 'lib/terrazzo/namespace/resource.rb', line 26

def ==(other)
  resource_name == other.resource_name
end

#controller_pathObject



14
15
16
# File 'lib/terrazzo/namespace/resource.rb', line 14

def controller_path
  route.defaults[:controller]
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/terrazzo/namespace/resource.rb', line 30

def eql?(other)
  resource_name == other.resource_name
end

#hashObject



34
35
36
# File 'lib/terrazzo/namespace/resource.rb', line 34

def hash
  resource_name.hash
end

#resource_nameObject



10
11
12
# File 'lib/terrazzo/namespace/resource.rb', line 10

def resource_name
  controller_path.split("/").last
end

#to_sObject



18
19
20
# File 'lib/terrazzo/namespace/resource.rb', line 18

def to_s
  resource_name
end

#to_symObject



22
23
24
# File 'lib/terrazzo/namespace/resource.rb', line 22

def to_sym
  resource_name.to_sym
end