Class: VORuby::ActiveVOTable::Callbacks
- Inherits:
-
Object
- Object
- VORuby::ActiveVOTable::Callbacks
- Includes:
- XML::SaxParser::Callbacks
- Defined in:
- lib/voruby/active_votable/active_votable.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#base_class ⇒ Object
Returns the value of attribute base_class.
-
#data_location ⇒ Object
Returns the value of attribute data_location.
-
#data_tables ⇒ Object
Returns the value of attribute data_tables.
-
#fields_tables ⇒ Object
Returns the value of attribute fields_tables.
-
#in_error ⇒ Object
Returns the value of attribute in_error.
-
#inside_td ⇒ Object
Returns the value of attribute inside_td.
-
#meta_location ⇒ Object
Returns the value of attribute meta_location.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#row ⇒ Object
Returns the value of attribute row.
Instance Method Summary collapse
- #data_table_name ⇒ Object
- #fields_table_name ⇒ Object
-
#initialize(base_class) ⇒ Callbacks
constructor
A new instance of Callbacks.
- #on_characters(chars) ⇒ Object
- #on_end_element(name) ⇒ Object
- #on_start_element(name, attrs) ⇒ Object
Constructor Details
#initialize(base_class) ⇒ Callbacks
Returns a new instance of Callbacks.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/voruby/active_votable/active_votable.rb', line 19 def initialize(base_class) self.base_class = base_class self.row = [] self. = [] self. = OpenStruct.new(:resource => 0, :table => 0, :field => 0) self.data_location = OpenStruct.new(:resource => 0, :table => 0, :row => 0, :column => 0) self.inside_td = false self.in_error = false end |
Instance Attribute Details
#base_class ⇒ Object
Returns the value of attribute base_class.
15 16 17 |
# File 'lib/voruby/active_votable/active_votable.rb', line 15 def base_class @base_class end |
#data_location ⇒ Object
Returns the value of attribute data_location.
15 16 17 |
# File 'lib/voruby/active_votable/active_votable.rb', line 15 def data_location @data_location end |
#data_tables ⇒ Object
Returns the value of attribute data_tables.
15 16 17 |
# File 'lib/voruby/active_votable/active_votable.rb', line 15 def data_tables @data_tables end |
#fields_tables ⇒ Object
Returns the value of attribute fields_tables.
15 16 17 |
# File 'lib/voruby/active_votable/active_votable.rb', line 15 def fields_tables @fields_tables end |
#in_error ⇒ Object
Returns the value of attribute in_error.
15 16 17 |
# File 'lib/voruby/active_votable/active_votable.rb', line 15 def in_error @in_error end |
#inside_td ⇒ Object
Returns the value of attribute inside_td.
15 16 17 |
# File 'lib/voruby/active_votable/active_votable.rb', line 15 def inside_td @inside_td end |
#meta_location ⇒ Object
Returns the value of attribute meta_location.
15 16 17 |
# File 'lib/voruby/active_votable/active_votable.rb', line 15 def @meta_location end |
#metadata ⇒ Object
Returns the value of attribute metadata.
15 16 17 |
# File 'lib/voruby/active_votable/active_votable.rb', line 15 def @metadata end |
#row ⇒ Object
Returns the value of attribute row.
15 16 17 |
# File 'lib/voruby/active_votable/active_votable.rb', line 15 def row @row end |
Instance Method Details
#data_table_name ⇒ Object
89 90 91 |
# File 'lib/voruby/active_votable/active_votable.rb', line 89 def data_table_name "#{self.base_class.table_name}_#{Base::DATA_ID}_#{self.data_location.resource}_#{self.data_location.table}" end |
#fields_table_name ⇒ Object
93 94 95 |
# File 'lib/voruby/active_votable/active_votable.rb', line 93 def fields_table_name "#{self.base_class.table_name}_#{Base::SCHEMA_ID}_#{self..resource}_#{self..table}" end |
#on_characters(chars) ⇒ Object
84 85 86 87 |
# File 'lib/voruby/active_votable/active_votable.rb', line 84 def on_characters(chars) raise "Query status error: #{chars}" if self.in_error self.row << chars if self.inside_td end |
#on_end_element(name) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/voruby/active_votable/active_votable.rb', line 69 def on_end_element(name) case name when 'TABLE' self..clear when 'TABLEDATA' self.base_class.connection.commit_db_transaction() when 'TR' create_record() when 'TD' self.inside_td = false when 'INFO' self.in_error = false end end |
#on_start_element(name, attrs) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/voruby/active_votable/active_votable.rb', line 31 def on_start_element(name, attrs) case name when 'RESOURCE' self..resource += 1 self.data_location.resource += 1 self..table = 0 self.data_location.table = 0 when 'TABLE' self..table += 1 self..field = 0 self.data_location.table += 1 self.data_location.row = 0 self.data_location.column = 0 create_db_tables() when 'FIELD' self..field += 1 self. << attrs when 'DATA' create_data_schema() # create the table and make it available () when 'TABLEDATA' self.base_class.connection.begin_db_transaction() when 'TR' self.data_location.resource = self..resource self.data_location.table = self..table self.data_location.row += 1 self.data_location.column = 0 self.row.clear when 'TD' self.data_location.column += 1 self.inside_td = true when 'INFO' self.in_error = true if attrs['name'] == 'QUERY_STATUS' and attrs['value'] == 'ERROR' end end |