Sha256: 4aa535f3913175dc441f10f1a4389a42dc92830e38094a64567114c9813c23ce

Contents?: true

Size: 939 Bytes

Versions: 15

Compression:

Stored size: 939 Bytes

Contents

module ForestLiana
  class ControllerFactory

    def self.define_controller(active_record_class, service)
      class_name = active_record_class.table_name.classify
      module_name = class_name.deconstantize

      name = module_name if module_name
      name += class_name.demodulize

      ForestLiana::UserSpace.const_set("#{name}Controller", service)
    end

    def self.get_controller_name(active_record_class)
      class_name = active_record_class.table_name.classify
      module_name = class_name.deconstantize

      name = module_name if module_name
      name += class_name.demodulize

      "ForestLiana::UserSpace::#{name}Controller"
    end

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

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
forest_liana-1.6.5 app/services/forest_liana/controller_factory.rb
forest_liana-1.6.4 app/services/forest_liana/controller_factory.rb
forest_liana-1.6.3 app/services/forest_liana/controller_factory.rb
forest_liana-1.6.2 app/services/forest_liana/controller_factory.rb
forest_liana-1.6.1 app/services/forest_liana/controller_factory.rb
forest_liana-1.6.0 app/services/forest_liana/controller_factory.rb
forest_liana-1.5.26 app/services/forest_liana/controller_factory.rb
forest_liana-1.5.25 app/services/forest_liana/controller_factory.rb
forest_liana-1.5.24 app/services/forest_liana/controller_factory.rb
forest_liana-1.5.23 app/services/forest_liana/controller_factory.rb
forest_liana-1.5.22 app/services/forest_liana/controller_factory.rb
forest_liana-1.5.21 app/services/forest_liana/controller_factory.rb
forest_liana-1.5.20 app/services/forest_liana/controller_factory.rb
forest_liana-1.5.19 app/services/forest_liana/controller_factory.rb
forest_liana-1.5.18 app/services/forest_liana/controller_factory.rb