Sha256: 8d82c3a0c11a89ff167b6843a9db875b53732a763ebb08afa7cd1163be6770be

Contents?: true

Size: 625 Bytes

Versions: 3

Compression:

Stored size: 625 Bytes

Contents

class Gratan::DSL::Context::User
  include Gratan::DSL::Validator

  attr_reader :result

  def initialize(user, host, &block)
    @error_identifier = "User `#{user}@#{host}`"
    @user = user
    @host = host
    @result = {}
    instance_eval(&block)
  end

  def on(name, options = {}, &block)
    name = name.kind_of?(Regexp) ? name : name.to_s

    __validate("Object `#{name}` is already defined") do
      not @result.has_key?(name)
    end

    grant = {:privs => Gratan::DSL::Context::On.new(@user, @host, name, &block).result}
    grant[:with] = options[:with] if options[:with]
    @result[name] = grant
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gratan-0.1.7 lib/gratan/dsl/context/user.rb
gratan-0.1.6 lib/gratan/dsl/context/user.rb
gratan-0.1.5 lib/gratan/dsl/context/user.rb