Sha256: 882d599f6b18da92d138119044bfecbfe77d94f7330f533949e663a08d214dff
Contents?: true
Size: 978 Bytes
Versions: 8
Compression:
Stored size: 978 Bytes
Contents
require "active_support" module Hexx # Storage for dependencies. # # Include it to your domain module and declare necessary dependencies. # # module MyProject # include Hexx::Settigns # class << self # # depends_on :some_class # end # end # # Then you can add a setting: # # # config/initializers/my_project.rb # MyProject.configure do |c| # c.some_class_name = "ExternalModule::SomeClass" # end # # And use it in a code: # # MyProject.some_class # => ExternalModule::SomeClass # module Settings extend ActiveSupport::Concern # Settings helpers module ClassMethods def configure(&block) block.call(self) if block_given? end def depends_on(name) cattr_accessor "#{ name }_name" define_singleton_method name do const = send "#{ name }_name" const ? Kernel.const_get(const) : nil end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems