Module: Heimdallr::Model

Extended by:
ActiveSupport::Concern
Defined in:
lib/heimdallr/model.rb

Overview

TODO:

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

Instance Method Summary collapse

Instance Attribute Details

#heimdallr_validatorsObject

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_validationsObject

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.

Returns:

  • (Record::Proxy)


100
101
102
# File 'lib/heimdallr/model.rb', line 100

def restrict(context, options={})
  self.class.heimdallr_proxy_class.new(context, self, options)
end