Class: Resource
- Inherits:
-
DomainElement
- Object
- DomainElement
- Resource
- Includes:
- FileBase
- Defined in:
- lib/rails_elements.rb
Constant Summary
Constants included from FileBase
Instance Attribute Summary collapse
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#model ⇒ Object
Returns the value of attribute model.
Attributes inherited from DomainElement
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(name) ⇒ Resource
constructor
A new instance of Resource.
- #method_missing(method, *args, &blk) ⇒ Object
Methods included from FileBase
#copy, #destroy, #exists?, #file_path, #has_location?, #home, #location, #make_dir, #mkdir, #move, #path, #reset_location, #set_home, #set_location, #write
Methods inherited from DomainElement
Constructor Details
#initialize(name) ⇒ Resource
Returns a new instance of Resource.
130 131 132 133 134 |
# File 'lib/rails_elements.rb', line 130 def initialize(name) super @model = Model.new name @controller = Controller.new name end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &blk) ⇒ Object
145 146 147 148 149 150 151 152 153 154 |
# File 'lib/rails_elements.rb', line 145 def method_missing(method, *args, &blk) case when model.respond_to?(method) then model.send(method, *args, &blk) when controller.respond_to?(method) then controller.send(method, *args, &blk) else super end end |
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
128 129 130 |
# File 'lib/rails_elements.rb', line 128 def controller @controller end |
#model ⇒ Object
Returns the value of attribute model.
128 129 130 |
# File 'lib/rails_elements.rb', line 128 def model @model end |
Instance Method Details
#generate ⇒ Object
136 137 138 139 140 141 142 143 |
# File 'lib/rails_elements.rb', line 136 def generate puts "\n#- - - - - - - - - - - - - - - - - - -#\n" puts "generating #{name} resource with specs\n" system "script/generate rspec_resource #{name} #{attribute_string}\n" model.write_associations model.write_plugin_methods controller.write_actions end |