Class: CRUDtree::EndNode

Inherits:
Object
  • Object
show all
Defined in:
lib/crudtree/tree/endnode.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, params) ⇒ EndNode

The params Hash takes the following keys:

:type may either be member or collection

:path path to this endnode - you can use join or join/:date/:foo/:whatever the interface will handle those parameters. Defaults to call.to_s

:rest which REST method should match this route. Defaults to nil, aka all.

:call The method to be called if this route is matched. Required.

:name The name of this route, used for generating. Symbol. Defaults to call

Raises:

  • (ArgumentError)


26
27
28
29
30
31
32
33
34
35
# File 'lib/crudtree/tree/endnode.rb', line 26

def initialize(parent, params)
  @type = params[:type] if [:member, :collection].include? params[:type]
  raise ArgumentError, "Invalid type: #{params[:type]}" unless @type
  @call = params[:call] or raise ArgumentError, "No call given."
  @path = params[:path] || @call.to_s
  raise ArgumentError, "No path given." unless @path
  @rest = params[:rest]
  @name = params[:name] || @call
  @parent = parent
end

Instance Attribute Details

#callObject (readonly)

Returns the value of attribute call.



37
38
39
# File 'lib/crudtree/tree/endnode.rb', line 37

def call
  @call
end

#nameObject (readonly)

Returns the value of attribute name.



37
38
39
# File 'lib/crudtree/tree/endnode.rb', line 37

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



37
38
39
# File 'lib/crudtree/tree/endnode.rb', line 37

def parent
  @parent
end

#pathObject (readonly)

Returns the value of attribute path.



37
38
39
# File 'lib/crudtree/tree/endnode.rb', line 37

def path
  @path
end

#restObject (readonly)

Returns the value of attribute rest.



37
38
39
# File 'lib/crudtree/tree/endnode.rb', line 37

def rest
  @rest
end

#typeObject (readonly)

Returns the value of attribute type.



37
38
39
# File 'lib/crudtree/tree/endnode.rb', line 37

def type
  @type
end