Class: Freddie::Handlers::Resource
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#after_perform, #before_perform, #call, call, #context, #finish!, #finished?, #initialize, #layout, #method_missing, #params, #perform_freddie_block, #request, #response, #session
Constructor Details
This class inherits a constructor from Freddie::Handlers::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Freddie::Handlers::Base
Instance Method Details
#perform ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/freddie/handlers.rb', line 144 def perform name = args.shift = args.shift || {} = { name: name.to_s, singular_name: name.to_s.singularize, plural_name: name.to_s.pluralize, klass: name.to_s.classify.constantize }.merge() path([:name]) do |n| n.path('new') do n.template "#{[:plural_name]}/new.html.haml", [:singular_name] => [:klass].new end n.path(:id) do |n| resource = [:klass].find(params[:id]) n.path('edit') do |n| n.template "#{[:plural_name]}/edit.html.haml", [:singular_name] => resource end n.template "#{[:plural_name]}/show.html.haml", [:singular_name] => resource end n.template "#{[:plural_name]}/index.html.haml", [:plural_name] => [:klass].all end end |