Class: Cassandra::Mapper::Utility::Config::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/cassandra/mapper/utility/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ DSL

Returns a new instance of DSL.



16
17
18
19
20
21
22
23
24
25
# File 'lib/cassandra/mapper/utility/config.rb', line 16

def initialize(&block)
  @options = {
    types: {},
    before_insert: [],
    after_insert: [],
    after_remove: [],
    before_remove: []
  }
  instance_eval &block
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/cassandra/mapper/utility/config.rb', line 14

def options
  @options
end

Instance Method Details

#after_insert(&block) ⇒ Object



47
48
49
# File 'lib/cassandra/mapper/utility/config.rb', line 47

def after_insert(&block)
  @options[:after_insert].push block
end

#after_remove(&block) ⇒ Object



51
52
53
# File 'lib/cassandra/mapper/utility/config.rb', line 51

def after_remove(&block)
  @options[:after_remove].push block
end

#before_insert(&block) ⇒ Object



39
40
41
# File 'lib/cassandra/mapper/utility/config.rb', line 39

def before_insert(&block)
  @options[:before_insert].push block
end

#before_remove(&block) ⇒ Object



43
44
45
# File 'lib/cassandra/mapper/utility/config.rb', line 43

def before_remove(&block)
  @options[:before_remove].push block
end

#key(*fields) ⇒ Object



27
28
29
# File 'lib/cassandra/mapper/utility/config.rb', line 27

def key(*fields)
  @options[:key] = fields
end

#subkey(*fields) ⇒ Object



31
32
33
# File 'lib/cassandra/mapper/utility/config.rb', line 31

def subkey(*fields)
  @options[:subkey] = fields
end

#type(field, type) ⇒ Object



35
36
37
# File 'lib/cassandra/mapper/utility/config.rb', line 35

def type(field, type)
  @options[:types][field] = type
end