class Athena::Record

Attributes

block[R]
id[R]
struct[R]

Public Class Methods

[](field = nil, config = nil) click to toggle source
   # File lib/athena/record.rb
46 def [](field = nil, config = nil)
47   record = records.last
48   raise NoRecordError unless record
49 
50   record.fill(field, config) if field && config
51   record
52 end
new(id = nil, block = nil, add = !block) { |self| ... } click to toggle source
   # File lib/athena/record.rb
58 def initialize(id = nil, block = nil, add = !block)
59   @id, @block, @struct = id || object_id.map_positive, block, {}
60 
61   add_record if add
62 
63   if block_given?
64     begin
65       yield self
66     ensure
67       close
68     end
69   end
70 end
records() click to toggle source
   # File lib/athena/record.rb
42 def records
43   @records
44 end

Public Instance Methods

close() click to toggle source
   # File lib/athena/record.rb
81 def close
82   block ? block[self] : self
83 end
fill(field, config) click to toggle source
   # File lib/athena/record.rb
72 def fill(field, config)
73   struct[field] ||= config.merge(:values => Hash.new { |h, k| h[k] = [] })
74 end
to(format) click to toggle source
   # File lib/athena/record.rb
85 def to(format)
86   Formats[:out, format].convert(self)
87 end
update(element, data, field_config = nil) click to toggle source
   # File lib/athena/record.rb
76 def update(element, data, field_config = nil)
77   field_config.each { |field, config| fill(field, config) } if field_config
78   struct.each_key { |field| struct[field][:values][element] << data }
79 end

Private Instance Methods

add_record() click to toggle source
   # File lib/athena/record.rb
91 def add_record
92   self.class.records << self
93 end