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.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(controller, *arguments) ⇒ Object
- #callback? ⇒ Boolean
- #define(path, **options, &callback) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #indirect? ⇒ Boolean
-
#initialize(options = {}, &block) ⇒ Action
constructor
A new instance of Action.
- #inspect ⇒ Object
-
#select(relative_path) ⇒ Object
relative_path = 2014/mr-potato actions => => A.
Constructor Details
#initialize(options = {}, &block) ⇒ Action
Returns a new instance of Action.
24 25 26 27 28 29 |
# File 'lib/utopia/controller/action.rb', line 24 def initialize( = {}, &block) @options = @callback = block super() end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
31 32 33 |
# File 'lib/utopia/controller/action.rb', line 31 def callback @callback end |
#options ⇒ Object
Returns the value of attribute options.
31 32 33 |
# File 'lib/utopia/controller/action.rb', line 31 def @options end |
Instance Method Details
#==(other) ⇒ Object
49 50 51 |
# File 'lib/utopia/controller/action.rb', line 49 def == other super and @callback == other.callback and @options == other. end |
#call(controller, *arguments) ⇒ Object
103 104 105 |
# File 'lib/utopia/controller/action.rb', line 103 def call(controller, *arguments) controller.instance_exec(*arguments, self, &@callback) end |
#callback? ⇒ Boolean
33 34 35 |
# File 'lib/utopia/controller/action.rb', line 33 def callback? @callback != nil end |
#define(path, **options, &callback) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/utopia/controller/action.rb', line 90 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
41 42 43 |
# File 'lib/utopia/controller/action.rb', line 41 def eql? other super and @callback.eql? other.callback and @options.eql? other. end |
#hash ⇒ Object
45 46 47 |
# File 'lib/utopia/controller/action.rb', line 45 def hash [super, @callback, @options].hash end |
#indirect? ⇒ Boolean
37 38 39 |
# File 'lib/utopia/controller/action.rb', line 37 def indirect? @options[:indirect] end |
#inspect ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/utopia/controller/action.rb', line 107 def inspect if callback? "<action " + super + ":#{callback.source_location}(#{})>" else "<action " + super + ">" end end |
#select(relative_path) ⇒ Object
relative_path = 2014/mr-potato actions => => A
84 85 86 87 88 |
# File 'lib/utopia/controller/action.rb', line 84 def select(relative_path) [].tap do |actions| append(relative_path.reverse, 0, actions) end end |