Module: Heimdallr::Model
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/heimdallr/model.rb
Overview
Improve description
Heimdallr is attached to your models by including the module and defining the restrictions in your classes.
class Article < ActiveRecord::Base
include Heimdallr::Model
restrict do |context|
# ...
end
end
Model should be included prior to any other modules, as it may omit some named scopes defined by those if it is not.
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#heimdallr_validators ⇒ Object
private
An internal attribute to store the Heimdallr security validators for the context in which this object is currently being saved.
Instance Method Summary collapse
-
#heimdallr_validations ⇒ Object
private
An internal method to run Heimdallr security validators, when applicable.
-
#restrict(context, options = {}) ⇒ Record::Proxy
Return a secure proxy object for this record.
Instance Attribute Details
#heimdallr_validators ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
An internal attribute to store the Heimdallr security validators for the context in which this object is currently being saved.
108 109 110 |
# File 'lib/heimdallr/model.rb', line 108 def heimdallr_validators @heimdallr_validators end |
Instance Method Details
#heimdallr_validations ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
An internal method to run Heimdallr security validators, when applicable.
113 114 115 |
# File 'lib/heimdallr/model.rb', line 113 def heimdallr_validations validates_with Heimdallr::Validator end |
#restrict(context, options = {}) ⇒ Record::Proxy
Return a secure proxy object for this record.
100 101 102 |
# File 'lib/heimdallr/model.rb', line 100 def restrict(context, ={}) self.class.heimdallr_proxy_class.new(context, self, ) end |