Class: Utopia::Controller::Action

Inherits:
Hash
  • Object
show all
Defined in:
lib/utopia/controller/action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



24
25
26
# File 'lib/utopia/controller/action.rb', line 24

def callback
  @callback
end

#optionsObject

Returns the value of attribute options.



25
26
27
# File 'lib/utopia/controller/action.rb', line 25

def options
  @options
end

Instance Method Details

#==(other) ⇒ Object



43
44
45
# File 'lib/utopia/controller/action.rb', line 43

def == other
  super and (self.callback == other.callback) and (self.options == other.options)
end

#callback?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/utopia/controller/action.rb', line 27

def callback?
  @callback != nil
end

#define(path, options = {}, &callback) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/utopia/controller/action.rb', line 86

def define(path, options = {}, &callback)
  current = self
  
  path.reverse.each do |name|
    current = (current[name.to_sym] ||= Action.new)
  end
  
  current.options = options
  current.callback = callback
  
  return current
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/utopia/controller/action.rb', line 35

def eql? other
  super and self.callback.eql? other.callback and self.options.eql? other.options
end

#hashObject



39
40
41
# File 'lib/utopia/controller/action.rb', line 39

def hash
  [super, callback, options].hash
end

#indirect?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/utopia/controller/action.rb', line 31

def indirect?
  @options[:indirect]
end

#inspectObject



103
104
105
106
107
108
109
# File 'lib/utopia/controller/action.rb', line 103

def inspect
  if callback?
    "<action " + super + ":#{callback.source_location}(#{options})>"
  else
    "<action " + super + ">"
  end
end

#invoke!(controller, *arguments) ⇒ Object



99
100
101
# File 'lib/utopia/controller/action.rb', line 99

def invoke!(controller, *arguments)
  controller.instance_exec(*arguments, &@callback)
end

#select(relative_path) ⇒ Object

relative_path = 2014/mr-potato actions => => A



78
79
80
81
82
83
84
# File 'lib/utopia/controller/action.rb', line 78

def select(relative_path)
  actions = []
  
  append(relative_path.reverse, 0, actions)
  
  return actions
end