Module: Hammock::RestfulSupport::ClassMethods
- Defined in:
- lib/hammock/restful_support.rb
Instance Method Summary collapse
-
#mdl ⇒ Object
The model this controller operates on.
-
#mdl_name ⇒ Object
The lowercase name of the model this controller operates on.
Instance Method Details
#mdl ⇒ Object
The model this controller operates on. Defined as the singularized controller name. For example, for GelatinousBlobsController
, this will return the GelatinousBlob
class.
19 20 21 22 23 24 |
# File 'lib/hammock/restful_support.rb', line 19 def mdl @hammock_cached_mdl ||= Object.const_get to_s.sub('Controller', '').classify rescue log "No such model '#{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”.
26 27 28 |
# File 'lib/hammock/restful_support.rb', line 26 def mdl_name @hammock_cached_mdl_name ||= to_s.sub('Controller', '').singularize.underscore end |