Class: Gratan::DSL::Context::User
- Inherits:
-
Object
- Object
- Gratan::DSL::Context::User
- Includes:
- Validator, Logger::Helper
- Defined in:
- lib/gratan/dsl/context/user.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(user, host, options, &block) ⇒ User
constructor
A new instance of User.
- #on(name, options = {}, &block) ⇒ Object
Methods included from Logger::Helper
Methods included from Validator
Constructor Details
#initialize(user, host, options, &block) ⇒ User
Returns a new instance of User.
7 8 9 10 11 12 13 14 |
# File 'lib/gratan/dsl/context/user.rb', line 7 def initialize(user, host, , &block) @object_identifier = "User `#{user}@#{host}`" @user = user @host = host = @result = {} instance_eval(&block) end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
5 6 7 |
# File 'lib/gratan/dsl/context/user.rb', line 5 def result @result end |
Instance Method Details
#on(name, options = {}, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gratan/dsl/context/user.rb', line 16 def on(name, = {}, &block) name = name.kind_of?(Regexp) ? name : name.to_s __validate("Object `#{name}` is already defined") do not @result.has_key?(name) end if [:enable_expired] and (expired = .delete(:expired)) expired = Time.parse(expired) if Time.new >= expired log(:warn, "Object `#{name}` has expired", :color => :yellow) return end end grant = {:privs => Gratan::DSL::Context::On.new(@user, @host, name, , &block).result} grant[:with] = [:with] if [:with] @result[name] = grant end |