Class: TheShoveler::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/theShoveler/document.rb

Constant Summary collapse

@@fields =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDocument



18
19
20
21
22
23
# File 'lib/theShoveler/document.rb', line 18

def initialize
  @doc_attributes = {}
  @@fields.each do |field, args|
    @doc_attributes[field] = Document::get_field_value(args)
  end
end

Instance Attribute Details

#doc_attributesObject (readonly)

Returns the value of attribute doc_attributes.



5
6
7
# File 'lib/theShoveler/document.rb', line 5

def doc_attributes
  @doc_attributes
end

Class Method Details

.define_field(name, args) ⇒ Object



25
26
27
28
# File 'lib/theShoveler/document.rb', line 25

def self.define_field(name, args)
  TheShoveler::logger.info "field #{name}: #{args}"
  @@fields[name] = args
end

.fields_from_hash(hash = {}) ⇒ Object

args are pretty naive right now just Faker::Code.isbn



13
14
15
16
17
# File 'lib/theShoveler/document.rb', line 13

def self.fields_from_hash(hash = {})
  hash.each do |k,v|
    define_field k, v
  end
end

.get_field_value(args) ⇒ Object



7
8
9
10
# File 'lib/theShoveler/document.rb', line 7

def self.get_field_value(args)
  generater = args.split('::')
  return Faker.class_eval(generater[1])
end