Module: Origen::Controller::ClassMethods
- Defined in:
- lib/origen/controller.rb
Instance Method Summary collapse
- #_namespace ⇒ Object
- #_resolve_model_class(options) ⇒ Object
- #model(options = {}) ⇒ Object
- #path_to_model ⇒ Object
Instance Method Details
#_namespace ⇒ Object
55 56 57 |
# File 'lib/origen/controller.rb', line 55 def _namespace to_s.sub(/::[^:]*$/, '') end |
#_resolve_model_class(options) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/origen/controller.rb', line 32 def _resolve_model_class() class_name = [:class_name] if class_name if eval("defined? #{_namespace}::#{class_name}") klass = eval("#{_namespace}::#{class_name}") else if eval("defined? #{class_name}") klass = eval(class_name) else if eval("defined? #{self}::#{class_name}") klass = eval("#{self}::#{class_name}") else puts "Could not find class: #{class_name}" fail 'Unknown model class!' end end end klass else fail "You must supply a :class_name option when defining a controller's model!" end end |
#model(options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/origen/controller.rb', line 18 def model( = {}) [:controller_class] = self if [:path] @path_to_model = [:path] else [:model_class] = _resolve_model_class() end Origen.controllers << end |
#path_to_model ⇒ Object
28 29 30 |
# File 'lib/origen/controller.rb', line 28 def path_to_model @path_to_model end |