Class: Grouik::Types::Loadables

Inherits:
Array
  • Object
show all
Defined in:
src/lib/grouik/types.rb

Overview

Get filtered loadables, using ignores regexp

Returns:

Instance Method Summary collapse

Instance Method Details

#add_file(file, basedir = nil) ⇒ self

Returns:

  • (self)


36
37
38
39
40
# File 'src/lib/grouik/types.rb', line 36

def add_file(file, basedir = nil)
  self.push(make_loadable(basedir, file))

  self
end

#ignores(regexps) ⇒ self

Removes ignored patterns (regexps)

Parameters:

  • regexps (Array<Regexp>)

Returns:

  • (self)


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'src/lib/grouik/types.rb', line 21

def ignores(regexps)
  filter = lambda do |loadable, regexps|
    regexps.each do |regexp|
      return true if loadable and regexp.match(loadable.to_s)
    end

    false
  end

  self.clone.delete_if do |loadable|
    filter.call(loadable, regexps)
  end
end

#make_loadable(*args) ⇒ Grouik::Loadable

Returns:



43
44
45
# File 'src/lib/grouik/types.rb', line 43

def make_loadable(*args)
  Grouik.get(:loadable_factory).call(*args)
end