Class: PgObjects::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_objects/manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeManager

Returns a new instance of Manager.



5
6
7
8
9
10
11
# File 'lib/pg_objects/manager.rb', line 5

def initialize
  raise UnsupportedAdapterError if ActiveRecord::Base.connection.adapter_name != 'PostgreSQL'

  @objects = []
  @config = PgObjects.config
  @log = Logger.new(config.silent)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/pg_objects/manager.rb', line 3

def config
  @config
end

#logObject (readonly)

Returns the value of attribute log.



3
4
5
# File 'lib/pg_objects/manager.rb', line 3

def log
  @log
end

#objectsObject (readonly)

Returns the value of attribute objects.



3
4
5
# File 'lib/pg_objects/manager.rb', line 3

def objects
  @objects
end

Instance Method Details

#create_objectsObject



23
24
25
# File 'lib/pg_objects/manager.rb', line 23

def create_objects
  @objects.each { |obj| create_object obj }
end

#load_filesObject



13
14
15
16
17
18
19
20
21
# File 'lib/pg_objects/manager.rb', line 13

def load_files
  config.directories.each do |dir|
    Dir[File.join(dir, '**', "*.{#{config.extensions.join(',')}}")].each do |path|
      @objects << PgObjects::DbObject.new(path)
    end
  end

  self
end