Class: Droutes::ClassStruct

Inherits:
Object
  • Object
show all
Defined in:
lib/droutes/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_name, docs = "") ⇒ ClassStruct

Returns a new instance of ClassStruct.



5
6
7
8
9
10
11
12
13
14
# File 'lib/droutes/parser.rb', line 5

def initialize(class_name, docs="")
  @name = class_name
  if class_name
    controller = class_name.underscore
    @controller = controller[0, controller.length - "_controller".length]
  end
  @paths = ::Hash.new { |h, k| h[k] = {} }
  @children = []
  @docs = docs || ""
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



3
4
5
# File 'lib/droutes/parser.rb', line 3

def children
  @children
end

#controllerObject (readonly)

Returns the value of attribute controller.



3
4
5
# File 'lib/droutes/parser.rb', line 3

def controller
  @controller
end

#docsObject (readonly)

Returns the value of attribute docs.



3
4
5
# File 'lib/droutes/parser.rb', line 3

def docs
  @docs
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/droutes/parser.rb', line 3

def name
  @name
end

#pathsObject (readonly)

Returns the value of attribute paths.



3
4
5
# File 'lib/droutes/parser.rb', line 3

def paths
  @paths
end

Instance Method Details

#add_to_path(struct) ⇒ Object



16
17
18
# File 'lib/droutes/parser.rb', line 16

def add_to_path(struct)
  @paths[struct.path][struct.action] = struct
end