Sha256: 153b7cc4d9c8bd23d33c1b456a286c89b67e18c6e42ea93f784704e4f42a9aa5

Contents?: true

Size: 553 Bytes

Versions: 2

Compression:

Stored size: 553 Bytes

Contents

module ShirinjiRails
  module ResolverBinding
    extend ActiveSupport::Concern

    module ClassMethods
      def dependency(*deps)
        deps.each { |dep| _define_dependency_reader(dep) }
      end

      def _define_dependency_reader(bean, method = bean)
        if bean.is_a?(Hash)
          return bean.each { |k,v| _define_dependency_reader(k, v) }
        end

        define_method(method) do
          resolver.resolve(bean)
        end
      end
    end

    def resolver
      ::Rails.application.config.shirinji.resolver
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shirinji-rails-0.0.5 lib/shirinji-rails/resolver_binding.rb
shirinji-rails-0.0.4 lib/shirinji-rails/resolver_binding.rb