Class: RailsDbViews::Factory

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_db_views/factory.rb

Defined Under Namespace

Classes: AmbigousNameError

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.symbolsObject (readonly)

Returns the value of attribute symbols.



8
9
10
# File 'lib/rails_db_views/factory.rb', line 8

def symbols
  @symbols
end

Class Method Details

.clear!Object



42
43
44
# File 'lib/rails_db_views/factory.rb', line 42

def clear!
  @symbols = {}
end

.create(symbol_class) ⇒ Object



32
33
34
35
36
# File 'lib/rails_db_views/factory.rb', line 32

def create(symbol_class)
  symbol_list = @symbols[symbol_class.to_s]

  symbol_list.values.each(&:create!) if symbol_list
end

.drop(symbol_class) ⇒ Object



26
27
28
29
30
# File 'lib/rails_db_views/factory.rb', line 26

def drop(symbol_class)
  symbol_list = @symbols[symbol_class.to_s]

  symbol_list.values.each(&:drop!) if symbol_list
end

.get(symbol_class, name) ⇒ Object



38
39
40
# File 'lib/rails_db_views/factory.rb', line 38

def get(symbol_class, name)
  (@symbols[symbol_class.to_s]||{})[name]
end

.register_files(symbol_class, files) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rails_db_views/factory.rb', line 10

def register_files symbol_class, files
  @symbols[symbol_class.to_s] ||= {}

  files.each do |file|
    symbol = symbol_class.new(file)

    if s=@symbols[symbol_class.to_s][symbol.name]
      raise AmbigousNameError, "between #{file} and #{s.path}"
    end

    @symbols[symbol_class.to_s][symbol.name] = symbol
  end

  @symbols.values.map(&:values).flatten.each(&:process_inverse_of_required!)
end