Module: Airbed::Resources::ClassMethods
- Defined in:
- lib/airbed.rb
Instance Method Summary collapse
-
#Resource(model_class, options = {}) ⇒ Object
Make a controller into a resource.
Instance Method Details
#Resource(model_class, options = {}) ⇒ Object
Make a controller into a resource.
Just do
module Camping::Controllers
class Users < Resource User; end
end
or maybe something more complex
module Camping::Controllers
class Users < Resource User, :show_options => {:include => [:achievements]}
def show(user)
user.tweak!
super
end
end
end
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/airbed.rb', line 250 def Resource(model_class,={}) class_name = model_class.to_s.demodulize name = [:name] || class_name.underscore.pluralize r = @r u = [:urls] || ["/#{name}", "/#{name}/(\\d+)", "/#{name}/(\\d+)/(.+)"] Class.new(Airbed::Resources::Resty) { (:model_class) { model_class } (:options) { } (:urls) { u } (:inherited){|x| r << x} } end |