Class: Gumdrop::Data::SqliteLiveData

Inherits:
Object
  • Object
show all
Defined in:
lib/gumdrop/data_providers/sqlite.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db, provider) ⇒ SqliteLiveData

Returns a new instance of SqliteLiveData.



23
24
25
26
27
# File 'lib/gumdrop/data_providers/sqlite.rb', line 23

def initialize(db, provider)
  @db= db
  @provider= provider
  @data_hash= Hash.new &method(:load_data_for)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key, *args) ⇒ Object



38
39
40
# File 'lib/gumdrop/data_providers/sqlite.rb', line 38

def method_missing(key, *args)
  @data_hash[key]
end

Instance Attribute Details

#dbObject (readonly)

Returns the value of attribute db.



21
22
23
# File 'lib/gumdrop/data_providers/sqlite.rb', line 21

def db
  @db
end

#providerObject (readonly)

Returns the value of attribute provider.



21
22
23
# File 'lib/gumdrop/data_providers/sqlite.rb', line 21

def provider
  @provider
end

Instance Method Details

#load_data_for(hash, table_name) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/gumdrop/data_providers/sqlite.rb', line 29

def load_data_for(hash, table_name)
  data=[]
  db.results_as_hash = true
  db.execute( "select * from #{ table_name.to_s };" ) do |row|
    data << row.reject {|key,col| key.is_a? Fixnum }
  end
  hash[table_name]= provider.supply_data data
end