Class: Bread::Manager::Actions::ControllerScope
- Inherits:
-
Object
- Object
- Bread::Manager::Actions::ControllerScope
- Defined in:
- lib/bread/manager/actions/controller_scope.rb
Instance Attribute Summary collapse
-
#parent_crumbs ⇒ Object
readonly
Returns the value of attribute parent_crumbs.
-
#top_scope ⇒ Object
readonly
Returns the value of attribute top_scope.
Instance Method Summary collapse
- #action(action_name, &block) ⇒ Object
- #actions(*action_names, &block) ⇒ Object
- #alias_actions(action_name, *aliases) ⇒ Object
- #get_crumbset(action_name) ⇒ Object
-
#initialize(top_scope, controller_path, options) ⇒ ControllerScope
constructor
A new instance of ControllerScope.
Constructor Details
#initialize(top_scope, controller_path, options) ⇒ ControllerScope
Returns a new instance of ControllerScope.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/bread/manager/actions/controller_scope.rb', line 8 def initialize(top_scope, controller_path, ) @top_scope = top_scope @controller_path = controller_path @action_scopes = {} @aliases = {} @options = define_parent_crumbs raise_if_any_invalid_option prepend_default_alias_actions end |
Instance Attribute Details
#parent_crumbs ⇒ Object (readonly)
Returns the value of attribute parent_crumbs.
6 7 8 |
# File 'lib/bread/manager/actions/controller_scope.rb', line 6 def parent_crumbs @parent_crumbs end |
#top_scope ⇒ Object (readonly)
Returns the value of attribute top_scope.
6 7 8 |
# File 'lib/bread/manager/actions/controller_scope.rb', line 6 def top_scope @top_scope end |
Instance Method Details
#action(action_name, &block) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/bread/manager/actions/controller_scope.rb', line 35 def action(action_name, &block) action_name = action_name.to_s @action_scopes[action_name] = action_scope = ActionScope.new(self, action_name) action_scope.instance_eval(&block) true end |
#actions(*action_names, &block) ⇒ Object
31 32 33 |
# File 'lib/bread/manager/actions/controller_scope.rb', line 31 def actions(*action_names, &block) action_names.each { |action_name| action(action_name, &block) } end |
#alias_actions(action_name, *aliases) ⇒ Object
19 20 21 22 23 |
# File 'lib/bread/manager/actions/controller_scope.rb', line 19 def alias_actions(action_name, *aliases) aliases.each do |a| @aliases[a.to_s] = action_name.to_s end end |
#get_crumbset(action_name) ⇒ Object
25 26 27 28 29 |
# File 'lib/bread/manager/actions/controller_scope.rb', line 25 def get_crumbset(action_name) action_name = get_aliased_action_name(action_name) action_scope = @action_scopes[action_name] || raise("no action scope for #{@controller_path}#'#{action_name}'") action_scope.crumbset end |