class MagicPath::PathManager
Attributes
resolvers[W]
Public Class Methods
_create_path_accessor(klass, meth)
click to toggle source
# File lib/magic_path/path_manager.rb, line 44 def _create_path_accessor(klass, meth) _fail_if_accessor_exists(klass, meth) _create_path_writer(klass, meth) _create_path_reader(klass, meth) end
_create_path_reader(klass, meth)
click to toggle source
# File lib/magic_path/path_manager.rb, line 57 def _create_path_reader(klass, meth) klass.send(:define_method, meth.to_s.delete('=')) do klass.class_variable_get("@@#{meth}".to_sym) end end
_create_path_writer(klass, meth)
click to toggle source
# File lib/magic_path/path_manager.rb, line 50 def _create_path_writer(klass, meth) klass.send(:define_method, "#{meth}=") do |opts| path = DynamicPath.new(opts[:pattern], opts[:params]) klass.class_variable_set("@@#{meth}".to_sym, path) end end
_fail_if_accessor_exists(klass, meth)
click to toggle source
# File lib/magic_path/path_manager.rb, line 63 def _fail_if_accessor_exists(klass, meth) raise(AlreadyExistsError, meth) if klass.method_defined?(meth) end
create_path(meth, opts)
click to toggle source
# File lib/magic_path/path_manager.rb, line 39 def create_path(meth, opts) _create_path_accessor(self, meth, opts) send("#{meth}=", opts) end
Public Instance Methods
add_resolver(resolver)
click to toggle source
# File lib/magic_path/path_manager.rb, line 29 def add_resolver(resolver) resolvers << resolver end
create_path(meth, opts)
click to toggle source
# File lib/magic_path/path_manager.rb, line 33 def create_path(meth, opts) self.class._create_path_accessor(singleton_class, meth) send("#{meth}=", opts) end
default_resolvers()
click to toggle source
# File lib/magic_path/path_manager.rb, line 25 def default_resolvers defined?(Nenv) ? [Nenv] : [] end
resolvers()
click to toggle source
# File lib/magic_path/path_manager.rb, line 21 def resolvers @resolvers ||= default_resolvers end