Class: Utopia::Controller::Action
- Inherits:
-
Hash
- Object
- Hash
- Utopia::Controller::Action
- Defined in:
- lib/utopia/controller/action.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#options ⇒ Object
Returns the value of attribute options.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #arity ⇒ Object
- #callback? ⇒ Boolean
- #define(path, **options, &callback) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #indirect? ⇒ Boolean
-
#initialize ⇒ Action
constructor
A new instance of Action.
- #inspect ⇒ Object
- #invoke!(controller, *arguments) ⇒ Object
-
#select(relative_path) ⇒ Object
relative_path = 2014/mr-potato actions => => A.
Constructor Details
#initialize ⇒ Action
Returns a new instance of Action.
24 25 26 27 28 29 30 |
# File 'lib/utopia/controller/action.rb', line 24 def initialize @path = nil = @callback = nil super end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
32 33 34 |
# File 'lib/utopia/controller/action.rb', line 32 def callback @callback end |
#options ⇒ Object
Returns the value of attribute options.
32 33 34 |
# File 'lib/utopia/controller/action.rb', line 32 def end |
#path ⇒ Object
Returns the value of attribute path.
32 33 34 |
# File 'lib/utopia/controller/action.rb', line 32 def path @path end |
Instance Method Details
#==(other) ⇒ Object
50 51 52 |
# File 'lib/utopia/controller/action.rb', line 50 def == other super and @callback == other.callback and == other. and @path == other.path end |
#arity ⇒ Object
105 106 107 |
# File 'lib/utopia/controller/action.rb', line 105 def arity @callback ? @callback.arity : 0 end |
#callback? ⇒ Boolean
34 35 36 |
# File 'lib/utopia/controller/action.rb', line 34 def callback? @callback != nil end |
#define(path, **options, &callback) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/utopia/controller/action.rb', line 91 def define(path, **, &callback) current = self path.reverse.each do |name| current = (current[name.to_sym] ||= Action.new) end current.path = path current. = current.callback = callback return current end |
#eql?(other) ⇒ Boolean
42 43 44 |
# File 'lib/utopia/controller/action.rb', line 42 def eql? other super and @callback.eql? other.callback and .eql? other. and @path.eql? other.path end |
#hash ⇒ Object
46 47 48 |
# File 'lib/utopia/controller/action.rb', line 46 def hash [super, callback, , path].hash end |
#indirect? ⇒ Boolean
38 39 40 |
# File 'lib/utopia/controller/action.rb', line 38 def indirect? [:indirect] end |
#inspect ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/utopia/controller/action.rb', line 113 def inspect if callback? "<action " + super + ":#{callback.source_location}(#{options})>" else "<action " + super + ">" end end |
#invoke!(controller, *arguments) ⇒ Object
109 110 111 |
# File 'lib/utopia/controller/action.rb', line 109 def invoke!(controller, *arguments) controller.instance_exec(*arguments, self, &@callback) end |
#select(relative_path) ⇒ Object
relative_path = 2014/mr-potato actions => => A
85 86 87 88 89 |
# File 'lib/utopia/controller/action.rb', line 85 def select(relative_path) [].tap do |actions| append(relative_path.reverse, 0, actions) end end |