Sha256: da2d058275a8a30ae5100e26fd609b792febd9df5ab1c5480da1fb776f7b449a

Contents?: true

Size: 948 Bytes

Versions: 27

Compression:

Stored size: 948 Bytes

Contents

module PowerStencil
  module Plugins

    module EntityDefinitions

      def require_plugin_entity_definitions
        return unless capabilities[:entity_definitions]
        logger.info "Requiring '#{self.name}' plugin entity definitions..."
        securely_require_with_entity_class_detection
      end


      private

      def securely_require_with_entity_class_detection
        before = PowerStencil::Engine::EntitiesHandling.all_types
        plugin_definition[:entity_definitions].each do |entity_definition_file_path|
          securely_require entity_definition_file_path, fail_on_error: true
        end
        after = PowerStencil::Engine::EntitiesHandling.all_types
        after.reject { |k, _| before.keys.include? k }.each do |_, plugin_entity_class|
          plugin = self
          plugin_entity_class.instance_eval do
            @entity_type_source_provider = plugin
          end
        end
      end

    end

  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
power_stencil-0.7.4 lib/power_stencil/plugins/entity_definitions.rb
power_stencil-0.7.3 lib/power_stencil/plugins/entity_definitions.rb
power_stencil-0.7.2 lib/power_stencil/plugins/entity_definitions.rb
power_stencil-0.7.1 lib/power_stencil/plugins/entity_definitions.rb
power_stencil-0.7.0 lib/power_stencil/plugins/entity_definitions.rb
power_stencil-0.6.3 lib/power_stencil/plugins/entity_definitions.rb
power_stencil-0.6.2 lib/power_stencil/plugins/entity_definitions.rb