Sha256: 565ac9739fd95051bffd8e6a23a8123189b9a159e4a4698d29c3f76f7b910fe0

Contents?: true

Size: 392 Bytes

Versions: 1

Compression:

Stored size: 392 Bytes

Contents

class Entity < ActiveRecord::Base
  include Heimdallr::Model

  has_many :things, :dependent => :destroy

  restrict do |user, record|
    if user.admin
      scope :fetch
      scope :delete
      can [:view, :create, :update]
    else
      scope :fetch,  -> { where('public = ? or owner_id = ?', true, user.id) }
      scope :delete, -> { where('owner_id = ?', user.id) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heimdallr-resource-1.2.0 spec/dummy/app/models/entity.rb