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
- #inspect ⇒ Object
- #invoke!(controller, *arguments) ⇒ Object
-
#select(relative_path) ⇒ Object
relative_path = 2014/mr-potato actions => => A.
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
24 25 26 |
# File 'lib/utopia/controller/action.rb', line 24 def callback @callback end |
#options ⇒ Object
Returns the value of attribute options.
24 25 26 |
# File 'lib/utopia/controller/action.rb', line 24 def @options end |
#path ⇒ Object
Returns the value of attribute path.
24 25 26 |
# File 'lib/utopia/controller/action.rb', line 24 def path @path end |
Instance Method Details
#==(other) ⇒ Object
42 43 44 |
# File 'lib/utopia/controller/action.rb', line 42 def == other super and @callback == other.callback and @options == other. and @path == other.path end |
#arity ⇒ Object
97 98 99 |
# File 'lib/utopia/controller/action.rb', line 97 def arity @callback ? @callback.arity : 0 end |
#callback? ⇒ Boolean
26 27 28 |
# File 'lib/utopia/controller/action.rb', line 26 def callback? @callback != nil end |
#define(path, **options, &callback) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/utopia/controller/action.rb', line 83 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
34 35 36 |
# File 'lib/utopia/controller/action.rb', line 34 def eql? other super and @callback.eql? other.callback and @options.eql? other. and @path.eql? other.path end |
#hash ⇒ Object
38 39 40 |
# File 'lib/utopia/controller/action.rb', line 38 def hash [super, callback, , path].hash end |
#indirect? ⇒ Boolean
30 31 32 |
# File 'lib/utopia/controller/action.rb', line 30 def indirect? @options[:indirect] end |
#inspect ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/utopia/controller/action.rb', line 105 def inspect if callback? "<action " + super + ":#{callback.source_location}(#{})>" else "<action " + super + ">" end end |
#invoke!(controller, *arguments) ⇒ Object
101 102 103 |
# File 'lib/utopia/controller/action.rb', line 101 def invoke!(controller, *arguments) controller.instance_exec(*arguments, self, &@callback) end |
#select(relative_path) ⇒ Object
relative_path = 2014/mr-potato actions => => A
77 78 79 80 81 |
# File 'lib/utopia/controller/action.rb', line 77 def select(relative_path) selection = [].tap do |actions| append(relative_path.reverse, 0, actions) end end |