Module: Neo::Rails::Scenarios::ClassMethods
- Defined in:
- lib/neo/rails/scenarios.rb
Instance Method Summary collapse
- #list_scenarios ⇒ Object
-
#scenario(action, name, options = {}, &block) ⇒ Object
Defines a scenario.
Instance Method Details
#list_scenarios ⇒ Object
54 55 56 |
# File 'lib/neo/rails/scenarios.rb', line 54 def list_scenarios self.scenarios.values.map(&:values).flatten end |
#scenario(action, name, options = {}, &block) ⇒ Object
Defines a scenario
Usage
class AController < ActionController::Base
include Neo::Rails::Exposure
include Neo::Rails::Scenarios
exposes :foo
def show
...
end
scenario :show, :a_scenario do
expose :foo, "bar" # any expose calls on :foo will be ignored in the action
end
end
Raises DuplicatedScenario if there is already a scenario for the action with the same name
46 47 48 49 50 51 52 |
# File 'lib/neo/rails/scenarios.rb', line 46 def scenario(action, name, ={}, &block) scenario = Scenario.new(action, name, block, ) raise DuplicatedScenario if self.scenarios[scenario.action][scenario.name] self.scenarios[scenario.action][scenario.name] = scenario end |