Sha256: 98efeb9c0a13912b4c089ac26b45546d01bacc8ae435a6af43fef0ea415b50ad

Contents?: true

Size: 893 Bytes

Versions: 39

Compression:

Stored size: 893 Bytes

Contents

module Inferno
  module Web
    module Controllers
      class Controller
        # Ensure that each request gets a new instance of the controller.
        def self.call(params)
          new.call(params)
        end

        def self.inherited(subclass)
          super

          # This does some sort of magic that requires it be included in the
          # subclass rather than superclass.
          subclass.include Hanami::Action

          subclass.include Import[repo: "repositories.#{subclass.resource_name}"]

          subclass.define_method(:serialize) do |*args|
            Inferno::Web::Serializers.const_get(self.class.resource_class).render(*args)
          end
        end

        def self.resource_name
          name.split('::')[-2].underscore
        end

        def self.resource_class
          name.split('::')[-2].singularize
        end
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
inferno_core-0.3.12 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.3.11 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.3.10 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.3.9 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.3.8 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.3.7 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.3.6 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.3.5 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.3.4 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.3.3 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.3.2 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.3.1 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.3.0 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.3.0.rc1 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.2.0 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.2.0.rc4 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.2.0.rc3 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.2.0.rc2 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.2.0.rc1 lib/inferno/apps/web/controllers/controller.rb
inferno_core-0.1.4.pre lib/inferno/apps/web/controllers/controller.rb