Module: Hammock::RestfulSupport::ClassMethods
- Defined in:
- lib/hammock/restful_support.rb
Instance Method Summary collapse
- #controller_ref ⇒ Object
-
#mdl ⇒ Object
The model this controller operates on.
-
#mdl_name ⇒ Object
The lowercase name of the model this controller operates on.
Instance Method Details
#controller_ref ⇒ Object
32 33 34 |
# File 'lib/hammock/restful_support.rb', line 32 def controller_ref self end |
#mdl ⇒ Object
The model this controller operates on. Defined as the singularized controller name. For example, for GelatinousBlobsController
, this will return the GelatinousBlob
class.
21 22 23 24 25 26 |
# File 'lib/hammock/restful_support.rb', line 21 def mdl @hammock_cached_mdl ||= Object.const_get controller_ref.to_s.sub('Controller', '').classify rescue log "Error loading '#{to_s.sub('Controller', '').classify}': #{$!}." nil end |
#mdl_name ⇒ Object
The lowercase name of the model this controller operates on. For example, for GelatinousBlobsController
, this will return “gelatinous_blob”.
28 29 30 |
# File 'lib/hammock/restful_support.rb', line 28 def mdl_name @hammock_cached_mdl_name ||= controller_ref.to_s.sub('Controller', '').singularize.underscore end |