Class: TheShoveler::Document
- Inherits:
-
Object
- Object
- TheShoveler::Document
- Defined in:
- lib/theShoveler/document.rb
Constant Summary collapse
- @@fields =
{}
Instance Attribute Summary collapse
-
#doc_attributes ⇒ Object
readonly
Returns the value of attribute doc_attributes.
Class Method Summary collapse
- .define_field(name, args) ⇒ Object
-
.fields_from_hash(hash = {}) ⇒ Object
args are pretty naive right now just Faker::Code.isbn.
- .get_field_value(args) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Document
constructor
A new instance of Document.
Constructor Details
#initialize ⇒ Document
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_attributes ⇒ Object (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 |