Class: WelltreatStoreFramework::Core
- Inherits:
-
Object
- Object
- WelltreatStoreFramework::Core
- Defined in:
- lib/welltreat_store_framework/core.rb
Constant Summary collapse
- @@configuration =
WelltreatStoreFramework::Configuration.new
- @@stores =
nil
Class Method Summary collapse
-
.connect_database! ⇒ Object
Establish database connection.
-
.disconnect_database! ⇒ Object
Return connection to poll.
-
.find_store_by_name(name, partition_object = nil) ⇒ Object
Find store by the given name Return StoreApp instance.
-
.find_stores(partition_object = nil) ⇒ Object
Find all stores from the configured path return an array of instance StoreApp.
-
.reset! ⇒ Object
Reset internal cached data.
-
.setup(&block) ⇒ Object
Configure through passing block.
Class Method Details
.connect_database! ⇒ Object
Establish database connection
36 37 38 39 40 41 42 43 |
# File 'lib/welltreat_store_framework/core.rb', line 36 def connect_database! ActiveRecord::Base.establish_connection configuration.database_config if configuration.database_schema_file.present? puts "Importing database schema - " require configuration.database_schema_file end end |
.disconnect_database! ⇒ Object
Return connection to poll
46 47 48 49 50 |
# File 'lib/welltreat_store_framework/core.rb', line 46 def disconnect_database! if ActiveRecord::Base.connection.present? ActiveRecord::Base.connection.close end end |
.find_store_by_name(name, partition_object = nil) ⇒ Object
Find store by the given name Return StoreApp instance
31 32 33 |
# File 'lib/welltreat_store_framework/core.rb', line 31 def find_store_by_name(name, partition_object = nil) find_stores(partition_object)[name] end |
.find_stores(partition_object = nil) ⇒ Object
Find all stores from the configured path return an array of instance StoreApp
25 26 27 |
# File 'lib/welltreat_store_framework/core.rb', line 25 def find_stores(partition_object = nil) self.stores ||= _detect_stores(partition_object) end |
.reset! ⇒ Object
Reset internal cached data
12 13 14 15 |
# File 'lib/welltreat_store_framework/core.rb', line 12 def reset! self.stores = nil self.configuration = WelltreatStoreFramework::Configuration.new end |
.setup(&block) ⇒ Object
Configure through passing block. block will be yield with configuration instance
19 20 21 |
# File 'lib/welltreat_store_framework/core.rb', line 19 def setup(&block) block.call(self.configuration) end |