Class: Utopia::Middleware::Controller::Action
- Defined in:
- lib/utopia/middleware/controller/action.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #callback? ⇒ Boolean
- #define(path, options = {}, &callback) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #indirect? ⇒ Boolean
- #inspect ⇒ Object
- #invoke!(controller, *arguments) ⇒ Object
-
#select(relative_path) ⇒ Object
relative_path = 2014/mr-potato actions => => A.
Methods inherited from Hash
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
25 26 27 |
# File 'lib/utopia/middleware/controller/action.rb', line 25 def callback @callback end |
#options ⇒ Object
Returns the value of attribute options.
26 27 28 |
# File 'lib/utopia/middleware/controller/action.rb', line 26 def @options end |
Instance Method Details
#==(other) ⇒ Object
44 45 46 |
# File 'lib/utopia/middleware/controller/action.rb', line 44 def == other super and (self.callback == other.callback) and (self. == other.) end |
#callback? ⇒ Boolean
28 29 30 |
# File 'lib/utopia/middleware/controller/action.rb', line 28 def callback? @callback != nil end |
#define(path, options = {}, &callback) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/utopia/middleware/controller/action.rb', line 89 def define(path, = {}, &callback) current = self path.reverse.each do |name| current = (current[name.to_sym] ||= Action.new) end current. = current.callback = callback return current end |
#eql?(other) ⇒ Boolean
36 37 38 |
# File 'lib/utopia/middleware/controller/action.rb', line 36 def eql? other super and self.callback.eql? other.callback and self..eql? other. end |
#hash ⇒ Object
40 41 42 |
# File 'lib/utopia/middleware/controller/action.rb', line 40 def hash [super, callback, ].hash end |
#indirect? ⇒ Boolean
32 33 34 |
# File 'lib/utopia/middleware/controller/action.rb', line 32 def indirect? @options[:indirect] end |
#inspect ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/utopia/middleware/controller/action.rb', line 111 def inspect if callback? "<action " + super + ":#{callback.source_location}(#{})>" else "<action " + super + ">" end end |
#invoke!(controller, *arguments) ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'lib/utopia/middleware/controller/action.rb', line 102 def invoke!(controller, *arguments) if @options[:unbound] # This is the old code path for explicit methods. controller.instance_exec(controller, *arguments, &@callback) else controller.instance_exec(*arguments, &@callback) end end |
#select(relative_path) ⇒ Object
relative_path = 2014/mr-potato actions => => A
79 80 81 82 83 84 85 86 87 |
# File 'lib/utopia/middleware/controller/action.rb', line 79 def select(relative_path) actions = [] append(relative_path.reverse, 0, actions) # puts "select(#{relative_path}, #{self.inspect}) => #{actions.inspect}" return actions end |