Class: Innodb::System
- Inherits:
-
Object
- Object
- Innodb::System
- Defined in:
- lib/innodb/system.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#spaces ⇒ Object
Returns the value of attribute spaces.
Instance Method Summary collapse
- #add_space(space) ⇒ Object
- #add_space_file(space_file) ⇒ Object
- #each_index ⇒ Object
- #each_record_from_data_dictionary_index(table, index) ⇒ Object
- #each_table ⇒ Object
- #index_by_id(value) ⇒ Object
- #index_by_name(table_name, index_name) ⇒ Object
-
#initialize(system_space_file) ⇒ System
constructor
A new instance of System.
- #object_by_field(method, field, value) ⇒ Object
- #object_by_two_fields(method, f1, v1, f2, v2) ⇒ Object
- #system_space ⇒ Object
- #table_by_id(value) ⇒ Object
- #table_by_name(value) ⇒ Object
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/innodb/system.rb', line 4 def config @config end |
#spaces ⇒ Object
Returns the value of attribute spaces.
5 6 7 |
# File 'lib/innodb/system.rb', line 5 def spaces @spaces end |
Instance Method Details
#add_space(space) ⇒ Object
81 82 83 |
# File 'lib/innodb/system.rb', line 81 def add_space(space) @spaces[space.space_id] = space end |
#add_space_file(space_file) ⇒ Object
85 86 87 |
# File 'lib/innodb/system.rb', line 85 def add_space_file(space_file) add_space(Innodb::Space.new(space_file)) end |
#each_index ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/innodb/system.rb', line 41 def each_index unless block_given? return enum_for(:each_index) end each_record_from_data_dictionary_index(:SYS_INDEXES, :PRIMARY) do |record| yield record.fields end end |
#each_record_from_data_dictionary_index(table, index) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/innodb/system.rb', line 19 def each_record_from_data_dictionary_index(table, index) unless block_given? return enum_for(:each_record_from_data_dictionary_index, table, index) end index = system_space.data_dictionary.index(table, index) index.each_record do |record| yield record end nil end |
#each_table ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/innodb/system.rb', line 31 def each_table unless block_given? return enum_for(:each_table) end each_record_from_data_dictionary_index(:SYS_TABLES, :PRIMARY) do |record| yield record.fields end end |
#index_by_id(value) ⇒ Object
67 68 69 |
# File 'lib/innodb/system.rb', line 67 def index_by_id(value) object_by_field(:each_index, "ID", value) end |
#index_by_name(table_name, index_name) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/innodb/system.rb', line 71 def index_by_name(table_name, index_name) unless table = table_by_name(table_name) return nil end object_by_two_fields(:each_index, "TABLE_ID", table["ID"], "NAME", index_name) end |
#object_by_field(method, field, value) ⇒ Object
51 52 53 |
# File 'lib/innodb/system.rb', line 51 def object_by_field(method, field, value) send(method).select { |o| o[field] == value }.first end |
#object_by_two_fields(method, f1, v1, f2, v2) ⇒ Object
55 56 57 |
# File 'lib/innodb/system.rb', line 55 def object_by_two_fields(method, f1, v1, f2, v2) send(method).select { |o| o[f1] == v1 && o[f2] == v2 }.first end |
#system_space ⇒ Object
15 16 17 |
# File 'lib/innodb/system.rb', line 15 def system_space @spaces[0] end |
#table_by_id(value) ⇒ Object
59 60 61 |
# File 'lib/innodb/system.rb', line 59 def table_by_id(value) object_by_field(:each_table, "ID", value) end |
#table_by_name(value) ⇒ Object
63 64 65 |
# File 'lib/innodb/system.rb', line 63 def table_by_name(value) object_by_field(:each_table, "NAME", value) end |