Class: CassandraModel::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/cassandra-model/config.rb

Constant Summary collapse

@@cfg_file =
nil
@@hosts =
['127.0.0.1:9160']
@@username =
nil
@@password =
nil
@@keyspace =
nil

Class Method Summary collapse

Class Method Details

.cfg_fileObject



15
16
17
# File 'lib/cassandra-model/config.rb', line 15

def self.cfg_file
  @@cfg_file ||= File.join(Rails.root,'config','cassandra_conf.yml')
end

.cfg_file=(file) ⇒ Object



19
20
21
# File 'lib/cassandra-model/config.rb', line 19

def self.cfg_file=(file)
  @@cfg_file = file
end

.hostsObject



23
24
25
# File 'lib/cassandra-model/config.rb', line 23

def self.hosts
  @@hosts
end

.hosts=(hosts) ⇒ Object



27
28
29
# File 'lib/cassandra-model/config.rb', line 27

def self.hosts=(hosts)
  @@hosts = hosts
end

.initObject



55
56
57
58
# File 'lib/cassandra-model/config.rb', line 55

def self.init
  cfg = YAML.load_file(self.cfg_file)[::Rails.env]
  initialize_props cfg
end

.initialize_props(props) ⇒ Object



60
61
62
63
64
65
# File 'lib/cassandra-model/config.rb', line 60

def self.initialize_props props
  self.hosts    = props['hosts']
  self.username = props['username']
  self.password = props['password']
  self.keyspace = props['keyspace']
end

.keyspaceObject



47
48
49
# File 'lib/cassandra-model/config.rb', line 47

def self.keyspace
  @@keyspace
end

.keyspace=(keyspace) ⇒ Object



51
52
53
# File 'lib/cassandra-model/config.rb', line 51

def self.keyspace=(keyspace)
  @@keyspace = keyspace
end

.passwordObject



39
40
41
# File 'lib/cassandra-model/config.rb', line 39

def self.password
  @@password
end

.password=(password) ⇒ Object



43
44
45
# File 'lib/cassandra-model/config.rb', line 43

def self.password=(password)
  @@password = password
end

.usernameObject



31
32
33
# File 'lib/cassandra-model/config.rb', line 31

def self.username
  @@username
end

.username=(username) ⇒ Object



35
36
37
# File 'lib/cassandra-model/config.rb', line 35

def self.username=(username)
  @@username = username
end