Class: Stratagem::Model::Component::Controller
- Defined in:
- lib/stratagem/model/components/controller.rb
Constant Summary
Constants included from ParseUtil
ParseUtil::RUBY_OUTPUT_REGEX, ParseUtil::RUBY_REGEX
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#invalid_routes ⇒ Object
named routes linked to the controller that are invalid.
Attributes inherited from Base
#app_model, #klass, #parse_tree, #path, #source
Instance Method Summary collapse
- #action(name) ⇒ Object
- #add_routable_action(name, method) ⇒ Object
- #export ⇒ Object
-
#initialize(*args) ⇒ Controller
constructor
A new instance of Controller.
- #references ⇒ Object
Methods inherited from Base
#==, load_all, logger, #logger, #name
Methods included from ParseUtil
find_classes, #gsub_ruby_blocks, qualified_class_name, #ruby_blocks, #ruby_output_blocks
Constructor Details
#initialize(*args) ⇒ Controller
Returns a new instance of Controller.
38 39 40 41 42 |
# File 'lib/stratagem/model/components/controller.rb', line 38 def initialize(*args) super(*args) @invalid_routes = {} @actions = [] end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
35 36 37 |
# File 'lib/stratagem/model/components/controller.rb', line 35 def actions @actions end |
#invalid_routes ⇒ Object
named routes linked to the controller that are invalid
36 37 38 |
# File 'lib/stratagem/model/components/controller.rb', line 36 def invalid_routes @invalid_routes end |
Instance Method Details
#action(name) ⇒ Object
44 45 46 |
# File 'lib/stratagem/model/components/controller.rb', line 44 def action(name) @actions.find {|a| a.name.to_s == name.to_s } end |
#add_routable_action(name, method) ⇒ Object
48 49 50 |
# File 'lib/stratagem/model/components/controller.rb', line 48 def add_routable_action(name, method) @actions << Action.new(self, name, method) end |
#export ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/stratagem/model/components/controller.rb', line 52 def export { :external_id => self.object_id, :path => @path ? @path.gsub(RAILS_ROOT+'/', '') : nil, :class_name => klass.name, # :invalid_routes => @invalid_routes } end |
#references ⇒ Object
61 62 63 |
# File 'lib/stratagem/model/components/controller.rb', line 61 def references actions.map {|action| action.model_invocations }.flatten.uniq.map {|inv| inv.to_reference } end |