Sha256: 2ae17a795f3cb8cddca25a7957a9813a223cf7bb7c69d6ef8d97916fbe78262a

Contents?: true

Size: 544 Bytes

Versions: 4

Compression:

Stored size: 544 Bytes

Contents

class <%= config[:class_name] %>
  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

4 entries across 4 versions & 1 rubygems

Version Path
eucalypt-0.1.3 lib/eucalypt/eucalypt-security/namespaces/security-policy/templates/policy.tt
eucalypt-0.1.2 lib/eucalypt/eucalypt-security/namespaces/security-policy/templates/policy.tt
eucalypt-0.1.1 lib/eucalypt/eucalypt-security/namespaces/security-policy/templates/policy.tt
eucalypt-0.1.0 lib/eucalypt/eucalypt-security/namespaces/security-policy/templates/policy.tt