class Posgra::DSL::Grants::Role::Schema

Attributes

result[R]

Public Class Methods

new(context, schema, options, &block) click to toggle source
# File lib/posgra/dsl/grants/role/schema.rb, line 8
def initialize(context, schema, options, &block)
  @schema = schema
  @options = options
  @context = context.merge(:schema => schema)
  @result = {}
  instance_eval(&block)
end

Public Instance Methods

on(name, options = {}, &block) click to toggle source
# File lib/posgra/dsl/grants/role/schema.rb, line 16
def on(name, options = {}, &block)
  unless name.is_a?(Regexp)
    name = name.to_s
    return unless matched?(name, @options[:include_object], @options[:exclude_object])
  end

  if options[:expired]
    expired = Time.parse(options[:expired])

    if Time.new >= expired
      log(:warn, "Privilege for `#{name}` has expired", :color => :yellow)
      return
    end
  end

  @result[name] = Posgra::DSL::Grants::Role::Schema::On.new(@context, name, @options, &block).result
end