Sha256: bde501847dea559f6a83137f9c0d92691e3a5400b8254b7769e37dfaa20b278d

Contents?: true

Size: 617 Bytes

Versions: 13

Compression:

Stored size: 617 Bytes

Contents

class <%= config[:class_name] %><%= " < Struct.new(:user, :#{config[:resource]})" if config[:headless] %>
  attr_reader :user, :<%= config[:resource] %>

  def initialize(user, <%= config[:resource] %>)
    @user = user
    @<%= config[:resource] %> = <%= config[:resource] %>
  end

  if ActiveRecord::Base.connection.table_exists?(:<%= config[:resource] %>_roles)
    <%= config[:constant] %>Role.pluck(:permission).each do |permission|
      define_method("#{permission}?") do
        <%= config[:constant] %>Role.find_by(permission: permission).send(user.role.<%= config[:resource] %>)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
eucalypt-0.5.0 lib/eucalypt/security/namespaces/security-policy/templates/policy.tt
eucalypt-0.4.2 lib/eucalypt/security/namespaces/security-policy/templates/policy.tt
eucalypt-0.4.1 lib/eucalypt/security/namespaces/security-policy/templates/policy.tt
eucalypt-0.4.0 lib/eucalypt/security/namespaces/security-policy/templates/policy.tt
eucalypt-0.3.5 lib/eucalypt/security/namespaces/security-policy/templates/policy.tt
eucalypt-0.3.4 lib/eucalypt/security/namespaces/security-policy/templates/policy.tt
eucalypt-0.3.3 lib/eucalypt/security/namespaces/security-policy/templates/policy.tt
eucalypt-0.3.2 lib/eucalypt/security/namespaces/security-policy/templates/policy.tt
eucalypt-0.3.1 lib/eucalypt/security/namespaces/security-policy/templates/policy.tt
eucalypt-0.3.0 lib/eucalypt/security/namespaces/security-policy/templates/policy.tt
eucalypt-0.2.2 lib/eucalypt/eucalypt-security/namespaces/security-policy/templates/policy.tt
eucalypt-0.2.1 lib/eucalypt/eucalypt-security/namespaces/security-policy/templates/policy.tt
eucalypt-0.2.0 lib/eucalypt/eucalypt-security/namespaces/security-policy/templates/policy.tt