Class: ForestLiana::ControllerFactory

Inherits:
Object
  • Object
show all
Defined in:
app/services/forest_liana/controller_factory.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.define_controller(active_record_class, service) ⇒ Object



4
5
6
7
8
9
10
11
# File 'app/services/forest_liana/controller_factory.rb', line 4

def self.define_controller(active_record_class, service)
  controller_name = self.build_controller_name(active_record_class)
  controller_name_with_namespace = self.controller_name_with_namespace(controller_name)

  unless ForestLiana::UserSpace.const_defined?(controller_name_with_namespace)
    ForestLiana::UserSpace.const_set(controller_name, service)
  end
end

.get_controller_name(active_record_class) ⇒ Object



13
14
15
16
# File 'app/services/forest_liana/controller_factory.rb', line 13

def self.get_controller_name(active_record_class)
  controller_name = self.build_controller_name(active_record_class)
  self.controller_name_with_namespace(controller_name)
end

Instance Method Details

#controller_for(active_record_class) ⇒ Object



18
19
20
21
22
23
# File 'app/services/forest_liana/controller_factory.rb', line 18

def controller_for(active_record_class)
  controller = Class.new(ForestLiana::ResourcesController) { }

  ForestLiana::ControllerFactory.define_controller(active_record_class, controller)
  controller
end