Sha256: c8b909188ca2c318526cf98b82f6276606e59d24fb9233486c9234045a3b4378

Contents?: true

Size: 933 Bytes

Versions: 26

Compression:

Stored size: 933 Bytes

Contents

module ForestLiana
  class ControllerFactory

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

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

    def self.get_controller_name(active_record_class)
      controller_name = self.build_controller_name(active_record_class)
      "ForestLiana::UserSpace::#{controller_name}"
    end

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

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

    private

    def self.build_controller_name(active_record_class)
      component_prefix = ForestLiana.component_prefix(active_record_class)
      "#{component_prefix}Controller"
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
forest_liana-2.5.2 app/services/forest_liana/controller_factory.rb
forest_liana-2.5.1 app/services/forest_liana/controller_factory.rb
forest_liana-2.5.0 app/services/forest_liana/controller_factory.rb
forest_liana-2.4.9 app/services/forest_liana/controller_factory.rb
forest_liana-2.4.8 app/services/forest_liana/controller_factory.rb
forest_liana-2.4.7 app/services/forest_liana/controller_factory.rb
forest_liana-2.4.6 app/services/forest_liana/controller_factory.rb
forest_liana-2.4.5 app/services/forest_liana/controller_factory.rb
forest_liana-2.4.4 app/services/forest_liana/controller_factory.rb
forest_liana-2.4.3 app/services/forest_liana/controller_factory.rb
forest_liana-2.4.2 app/services/forest_liana/controller_factory.rb
forest_liana-2.4.1 app/services/forest_liana/controller_factory.rb
forest_liana-2.4.0 app/services/forest_liana/controller_factory.rb
forest_liana-2.3.5 app/services/forest_liana/controller_factory.rb
forest_liana-2.3.4 app/services/forest_liana/controller_factory.rb
forest_liana-2.3.3 app/services/forest_liana/controller_factory.rb
forest_liana-2.3.2 app/services/forest_liana/controller_factory.rb
forest_liana-2.3.1 app/services/forest_liana/controller_factory.rb
forest_liana-2.3.0 app/services/forest_liana/controller_factory.rb
forest_liana-2.2.2 app/services/forest_liana/controller_factory.rb