Sha256: 5b97fa5cca723543d847af6fc0376f93e25fc1ce007c5c118ab5c5945368deec

Contents?: true

Size: 1.3 KB

Versions: 15

Compression:

Stored size: 1.3 KB

Contents

require 'olivander/resources/model_registry'

module Olivander
  module Resources
    module ModelRegistrar
      extend ActiveSupport::Concern

      included do
        def this_is_included_method
          puts 'hi'
        end
      end

      class_methods do
        def register_model(model = self, context: :default, using: self, &block)
          Rails.logger.debug "###################"
          Rails.logger.debug "registering model #{model.name} in context #{context} using #{using&.name} at #{self.name}"
          using.register_model(model, context: context, &block) && return unless using == self

          ::Olivander::Resources::ModelRegistry.global_registry.register(model, &block)
          Rails.logger.debug "###################\n"
        end
      end
    end

    class TestRegistrant
    end

    class TestRegistrar
      include ModelRegistrar
    end

    class TestRegistrar2
      include ModelRegistrar

      # register_model do
      #   puts 'hello'
      #   field_layout :show do :all end
      # end
      # register_model Olivander::Resources::TestRegistrant, context: :foo do
      #   puts 'this is the other thing'
      #   field_layout do [[1, :id]] end
      # end
      # register_model context: :bar, using: TestRegistrar do
      #   puts 'and lastly...'
      # end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
five-two-nw-olivander-0.1.2.43.a app/controllers/concerns/olivander/resources/model_registrar.rb
five-two-nw-olivander-0.1.2.43 app/controllers/concerns/olivander/resources/model_registrar.rb
five-two-nw-olivander-0.1.2.42 app/controllers/concerns/olivander/resources/model_registrar.rb
five-two-nw-olivander-0.1.2.41 app/controllers/concerns/olivander/resources/model_registrar.rb
five-two-nw-olivander-0.1.2.40 app/controllers/concerns/olivander/resources/model_registrar.rb
five-two-nw-olivander-0.1.2.39 app/controllers/concerns/olivander/resources/model_registrar.rb
five-two-nw-olivander-0.1.2.38 app/controllers/concerns/olivander/resources/model_registrar.rb
five-two-nw-olivander-0.1.2.37 app/controllers/concerns/olivander/resources/model_registrar.rb
five-two-nw-olivander-0.1.2.36 app/controllers/concerns/olivander/resources/model_registrar.rb
five-two-nw-olivander-0.1.2.35 app/controllers/concerns/olivander/resources/model_registrar.rb
five-two-nw-olivander-0.1.2.34 app/controllers/concerns/olivander/resources/model_registrar.rb
five-two-nw-olivander-0.1.2.33 app/controllers/concerns/olivander/resources/model_registrar.rb
five-two-nw-olivander-0.1.2.32 app/controllers/concerns/olivander/resources/model_registrar.rb
five-two-nw-olivander-0.1.2.31 app/controllers/concerns/olivander/resources/model_registrar.rb
five-two-nw-olivander-0.1.2.30 app/controllers/concerns/olivander/resources/model_registrar.rb