Module: Hammock::RestfulSupport::ClassMethods

Defined in:
lib/hammock/restful_support.rb

Instance Method Summary collapse

Instance Method Details

#controller_refObject



32
33
34
# File 'lib/hammock/restful_support.rb', line 32

def controller_ref
  self
end

#mdlObject

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_nameObject

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