class Mutiny::Subjects::Environment::Type
Attributes
configuration[R]
mod[R]
Public Class Methods
new(mod, configuration)
click to toggle source
# File lib/mutiny/subjects/environment/type.rb, line 7 def initialize(mod, configuration) @mod = mod @configuration = configuration end
Public Instance Methods
relevant?()
click to toggle source
# File lib/mutiny/subjects/environment/type.rb, line 12 def relevant? !name.nil? && in_scope? && loadable? end
to_subject()
click to toggle source
# File lib/mutiny/subjects/environment/type.rb, line 16 def to_subject Subject.new(name: name, path: absolute_path, root: load_path) end
Private Instance Methods
absolute_path()
click to toggle source
# File lib/mutiny/subjects/environment/type.rb, line 49 def absolute_path source_files.first end
in_scope?()
click to toggle source
# File lib/mutiny/subjects/environment/type.rb, line 26 def in_scope? configuration.patterns.any? { |pattern| pattern.match?(name) } end
load_path()
click to toggle source
# File lib/mutiny/subjects/environment/type.rb, line 34 def load_path configuration.load_paths.detect do |load_path| source_files.any? { |locs| locs.start_with?(load_path) } end end
loadable?()
click to toggle source
# File lib/mutiny/subjects/environment/type.rb, line 30 def loadable? !source_files.empty? end
name()
click to toggle source
# File lib/mutiny/subjects/environment/type.rb, line 22 def name mod.name end
source_files()
click to toggle source
# File lib/mutiny/subjects/environment/type.rb, line 40 def source_files mod.instance_methods(false) .map { |method_name| mod.instance_method(method_name).source_location } .reject(&:nil?) .map(&:first) .select { |source_file| configuration.can_load?(source_file) } .uniq end