Class: Middleman::Sprockets::ResourceStore

Inherits:
Object
  • Object
show all
Includes:
Contracts
Defined in:
lib/middleman-sprockets/resource_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResourceStore

Returns a new instance of ResourceStore.



8
9
10
# File 'lib/middleman-sprockets/resource_store.rb', line 8

def initialize
  @store = {}
end

Instance Attribute Details

#storeObject (readonly)

Returns the value of attribute store.



6
7
8
# File 'lib/middleman-sprockets/resource_store.rb', line 6

def store
  @store
end

Instance Method Details

#add(resource) ⇒ Object



13
14
15
# File 'lib/middleman-sprockets/resource_store.rb', line 13

def add resource
  store[resource.file_descriptor.full_path] = resource
end

#find_by_path(path) ⇒ Object



33
34
35
36
# File 'lib/middleman-sprockets/resource_store.rb', line 33

def find_by_path path
  path = Pathname.new(path) unless path.is_a?(Pathname)
  store.fetch path, nil
end

#matching_path?(path) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/middleman-sprockets/resource_store.rb', line 28

def matching_path? path
  paths.include?(path)
end

#pathsObject



23
24
25
# File 'lib/middleman-sprockets/resource_store.rb', line 23

def paths
  store.keys
end

#resourcesObject



18
19
20
# File 'lib/middleman-sprockets/resource_store.rb', line 18

def resources
  store.values
end