Class: RecordEncoder::Bert

Inherits:
Object
  • Object
show all
Defined in:
lib/record_encoder/bert.rb

Constant Summary collapse

SUPPORTED_OPTIONS =
i( primary_key delete_primary_key )

Instance Method Summary collapse

Constructor Details

#initialize(klass, *attributes) ⇒ Bert

Returns a new instance of Bert.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/record_encoder/bert.rb', line 12

def initialize klass, *attributes
  @klass = klass
  raise "klass can't be blank!" if @klass.blank?
  raise "klass must be a Class!" unless @klass.is_a? Class

  options = attributes.extract_options!.slice!(SUPPORTED_OPTIONS)
  @primary_key = options[:primary_key] || :id
  @delete_primary_key = options[:delete_primary_key] || true

  bert_prefix_and_suffix
end

Instance Method Details

#to_bertObject



24
25
26
27
# File 'lib/record_encoder/bert.rb', line 24

def to_bert
  to_bert_internal {|r| yield r }
  nil
end