Class: RubyHaze::Config

Inherits:
Object
  • Object
show all
Includes:
Mixins::Proxy
Defined in:
lib/rubyhaze/configs/config.rb

Instance Attribute Summary

Attributes included from Mixins::Proxy

#proxy_object

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixins::Proxy

included, #method_missing, #respond_to?

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



11
12
13
14
15
16
17
18
# File 'lib/rubyhaze/configs/config.rb', line 11

def initialize(options = {})
  @proxy_object = Java::ComHazelcastConfig::Config.new
  set_group   options[:group]
  set_network options[:network]
  set_maps    options[:maps]
  set_queues  options[:queues]
  set_topics  options[:topics]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RubyHaze::Mixins::Proxy

Class Method Details

.new_from_yamlObject



52
53
54
55
# File 'lib/rubyhaze/configs/config.rb', line 52

def new_from_yaml
  hsh = yaml_hash
  new(hsh) if hsh
end

.yaml_hashObject



47
48
49
50
# File 'lib/rubyhaze/configs/config.rb', line 47

def yaml_hash
  yml_path = File.expand_path('./hazelcast.yml')
  YAML.load_file(yml_path) if File.file? yml_path
end

Instance Method Details

#set_group(options = nil) ⇒ Object



20
21
22
23
# File 'lib/rubyhaze/configs/config.rb', line 20

def set_group(options = nil)
  options ||= RubyHaze::GroupConfig.default_options
  proxy_object.setGroupConfig RubyHaze::GroupConfig.new(options).proxy_object
end

#set_maps(hash = nil) ⇒ Object



30
31
32
33
# File 'lib/rubyhaze/configs/config.rb', line 30

def set_maps(hash = nil)
  return if hash.nil? || hash.empty?
  proxy_object.setMapConfigs hash.map{ |name, options| RubyHaze::MapConfig.new(name, options).proxy_object }
end

#set_network(options = nil) ⇒ Object



25
26
27
28
# File 'lib/rubyhaze/configs/config.rb', line 25

def set_network(options = nil)
  options ||= RubyHaze::NetworkConfig.default_options
  proxy_object.setNetworkConfig RubyHaze::NetworkConfig.new(options).proxy_object
end

#set_queues(hash = nil) ⇒ Object



35
36
37
38
# File 'lib/rubyhaze/configs/config.rb', line 35

def set_queues(hash = nil)
  return if hash.nil? || hash.empty?
  proxy_object.setMapQConfigs hash.map{ |name, options| RubyHaze::QueueConfig.new(name, options).proxy_object }
end

#set_topics(hash = nil) ⇒ Object



40
41
42
43
# File 'lib/rubyhaze/configs/config.rb', line 40

def set_topics(hash = nil)
  return if hash.nil? || hash.empty?
  proxy_object.setTopicConfigs hash.map{ |name, options| RubyHaze::TopicConfig.new(name, options).proxy_object }
end