Module: Heimdallr::LegacyResource::ClassMethods
- Defined in:
- lib/heimdallr/legacy_resource.rb
Overview
Class methods for Resource. See also ActiveSupport::Concern
.
Configuration collapse
-
#model ⇒ Class
readonly
Returns the attached model class.
Configuration collapse
-
#resource_for(model, options = {}) ⇒ Object
Attaches this resource to a model.
Instance Attribute Details
#model ⇒ Class (readonly)
Returns the attached model class.
250 251 252 |
# File 'lib/heimdallr/legacy_resource.rb', line 250 def model @model end |
Instance Method Details
#resource_for(model, options = {}) ⇒ Object
Attaches this resource to a model.
Note that ActiveSupport before_filter
replaces the list of actions for specified filter and not appends to it. For example, the following code will only run filter_a
when bar
action is invoked:
class FooController < ApplicationController
before_filter :filter_a, :only => :foo
before_filter :filter_a, :only => :bar
def foo; end
def ; end
end
For convenience, you can pass additional actions to register with default filters in options
. It is also possible to use append_before_filter
.
276 277 278 279 280 281 |
# File 'lib/heimdallr/legacy_resource.rb', line 276 def resource_for(model, ={}) @model = model.to_s.camelize.constantize before_filter :load_all_resources, only: [ :index ].concat([:all] || []) before_filter :load_referenced_resources, only: [ :show, :update, :destroy ].concat([:referenced] || []) end |