Module: Dataset::ContextClassMethods
- Defined in:
- lib/dataset.rb
Overview
Methods that are added to the class that Dataset is included in (the test context class).
Class Method Summary collapse
-
.extended(context_class) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#add_dataset(*datasets, &block) ⇒ Object
:nodoc:.
-
#dataset_session_in_hierarchy ⇒ Object
:nodoc:.
-
#datasets_directory(path) ⇒ Object
Replaces the default Dataset::Resolver with one that will look for dataset class definitions in the specified directory.
Class Method Details
.extended(context_class) ⇒ Object
:nodoc:
93 94 95 96 97 98 |
# File 'lib/dataset.rb', line 93 def self.extended(context_class) # :nodoc: context_class.module_eval do include InstanceMethods superclass_delegating_accessor :dataset_session end end |
Instance Method Details
#add_dataset(*datasets, &block) ⇒ Object
:nodoc:
112 113 114 115 116 117 118 |
# File 'lib/dataset.rb', line 112 def add_dataset(*datasets, &block) # :nodoc: dataset_session = dataset_session_in_hierarchy datasets.each { |dataset| dataset_session.add_dataset(self, dataset) } dataset_session.add_dataset(self, Class.new(Dataset::Block) { define_method :doload, block }) unless block.nil? end |
#dataset_session_in_hierarchy ⇒ Object
:nodoc:
120 121 122 123 124 125 126 127 |
# File 'lib/dataset.rb', line 120 def dataset_session_in_hierarchy # :nodoc: self.dataset_session ||= begin database_spec = ActiveRecord::Base.configurations['test'].with_indifferent_access database_class = Dataset::Database.const_get(database_spec[:adapter].classify) database = database_class.new(database_spec, Dataset::ContextClassMethods.datasets_database_dump_path) Dataset::Session.new(database) end end |
#datasets_directory(path) ⇒ Object
Replaces the default Dataset::Resolver with one that will look for dataset class definitions in the specified directory. Captures of the database will be stored in a subdirectory ‘tmp’ (see Dataset::Database::Base).
107 108 109 110 |
# File 'lib/dataset.rb', line 107 def datasets_directory(path) Dataset::Resolver.default = Dataset::DirectoryResolver.new(path) Dataset::ContextClassMethods.datasets_database_dump_path = File.join(path, '/tmp/dataset') end |