Class: Gratan::DSL::Context::On

Inherits:
Object
  • Object
show all
Includes:
Validator
Defined in:
lib/gratan/dsl/context/on.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validator

#__identify, #__validate

Constructor Details

#initialize(user, host, object, options, &block) ⇒ On

Returns a new instance of On.



6
7
8
9
10
11
12
13
14
# File 'lib/gratan/dsl/context/on.rb', line 6

def initialize(user, host, object, options, &block)
  @object_identifier = "User `#{user}@#{host}` on `#{object}`"
  @user = user
  @host = host
  @object = object
  @options = options
  @result = []
  instance_eval(&block)
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



4
5
6
# File 'lib/gratan/dsl/context/on.rb', line 4

def result
  @result
end

Instance Method Details

#grant(name, options = {}) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/gratan/dsl/context/on.rb', line 16

def grant(name, options = {})
  __validate("Grant `#{name}` is already defined") do
    not @result.include?(name)
  end

  @result << name
end