Module: Cequel::Util::HashAccessors Private

Included in:
Record::RecordSet
Defined in:
lib/cequel/util.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#hattr_accessor(hash, *attributes) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



38
39
40
41
# File 'lib/cequel/util.rb', line 38

def hattr_accessor(hash, *attributes)
  hattr_reader(hash, *attributes)
  hattr_writer(hash, *attributes)
end

#hattr_inquirer(hash, *attributes) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
21
22
23
24
25
26
# File 'lib/cequel/util.rb', line 18

def hattr_inquirer(hash, *attributes)
  attributes.each do |attribute|
    module_eval <<-RUBY, __FILE__, __LINE__ + 1
      def #{attribute}?
        !!#{hash}[#{attribute.to_sym.inspect}]
      end
    RUBY
  end
end

#hattr_reader(hash, *attributes) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
12
13
14
15
16
# File 'lib/cequel/util.rb', line 8

def hattr_reader(hash, *attributes)
  attributes.each do |attribute|
    module_eval <<-RUBY, __FILE__, __LINE__ + 1
      def #{attribute}
        #{hash}[#{attribute.to_sym.inspect}]
      end
    RUBY
  end
end

#hattr_writer(hash, *attributes) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
31
32
33
34
35
36
# File 'lib/cequel/util.rb', line 28

def hattr_writer(hash, *attributes)
  attributes.each do |attribute|
    module_eval <<-RUBY, __FILE__, __LINE__ + 1
      def #{attribute}=(value)
        #{hash}[#{attribute.to_sym.inspect}] = value
      end
    RUBY
  end
end