Class: Gratan::Client
- Inherits:
-
Object
- Object
- Gratan::Client
- Defined in:
- lib/gratan/client.rb
Instance Method Summary collapse
- #apply(file, options = {}) ⇒ Object
- #export(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
2 3 4 5 6 7 |
# File 'lib/gratan/client.rb', line 2 def initialize( = {}) = [:identifier] ||= Gratan::Identifier::Null.new client = Mysql2::Client.new() @driver = Gratan::Driver.new(client, ) end |
Instance Method Details
#apply(file, options = {}) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/gratan/client.rb', line 30 def apply(file, = {}) = .merge() in_progress do walk(file, ) end end |
#export(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gratan/client.rb', line 9 def export( = {}) = .merge() exported = Gratan::Exporter.export(@driver, ) if block_given? exported.sort_by {|user_host, attrs| user_host }.chunk {|user_host, attrs| user_host[0].empty? ? 'root' : user_host[0] }.each {|user, grants| h = {} grants.each {|k, v| h[k] = v } dsl = Gratan::DSL.convert(h, ) yield(user, dsl) } else exported = Gratan::Exporter.export(@driver, ) Gratan::DSL.convert(exported, ) end end |