Class: RailsDbViews::Factory
- Inherits:
-
Object
- Object
- RailsDbViews::Factory
- Defined in:
- lib/rails_db_views/factory.rb
Class Attribute Summary collapse
-
.symbols ⇒ Object
readonly
Returns the value of attribute symbols.
Class Method Summary collapse
- .clear! ⇒ Object
- .create(symbol_class) ⇒ Object
- .drop(symbol_class) ⇒ Object
- .get(symbol_class, name) ⇒ Object
- .register_files(symbol_class, files) ⇒ Object
Class Attribute Details
.symbols ⇒ Object (readonly)
Returns the value of attribute symbols.
7 8 9 |
# File 'lib/rails_db_views/factory.rb', line 7 def symbols @symbols end |
Class Method Details
.clear! ⇒ Object
41 42 43 |
# File 'lib/rails_db_views/factory.rb', line 41 def clear! @symbols = {} end |
.create(symbol_class) ⇒ Object
31 32 33 34 35 |
# File 'lib/rails_db_views/factory.rb', line 31 def create(symbol_class) symbol_list = @symbols[symbol_class.to_s] symbol_list.values.each(&:create!) if symbol_list end |
.drop(symbol_class) ⇒ Object
25 26 27 28 29 |
# File 'lib/rails_db_views/factory.rb', line 25 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
37 38 39 |
# File 'lib/rails_db_views/factory.rb', line 37 def get(symbol_class, name) (@symbols[symbol_class.to_s]||{})[name] end |
.register_files(symbol_class, files) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rails_db_views/factory.rb', line 9 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 RailsDbViews::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 |