Class: Builderator::Model::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/builderator/model.rb

Overview

Shared model interface

Constant Summary collapse

LIMIT =
4

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Base

Returns a new instance of Base.



10
11
12
# File 'lib/builderator/model.rb', line 10

def initialize(*args)
  fetch(*args)
end

Instance Attribute Details

#resourcesObject (readonly)

Returns the value of attribute resources.



7
8
9
# File 'lib/builderator/model.rb', line 7

def resources
  @resources
end

Instance Method Details

#fetchObject



14
15
16
# File 'lib/builderator/model.rb', line 14

def fetch
  @resources = {}
end

#find(filters = {}) ⇒ Object



18
19
20
# File 'lib/builderator/model.rb', line 18

def find(filters = {})
  Util.filter(resources, filters)
end

#in_use(options = {}) ⇒ Object



30
31
32
# File 'lib/builderator/model.rb', line 30

def in_use(options = {})
  find(options.fetch('filters', {}))
end

#reject(set = []) ⇒ Object



26
27
28
# File 'lib/builderator/model.rb', line 26

def reject(set = [])
  resources.reject { |k, _| set.include?(k) }
end

#select(set = []) ⇒ Object



22
23
24
# File 'lib/builderator/model.rb', line 22

def select(set = [])
  resources.select { |k, _| set.include?(k) }
end

#unused(options = {}) ⇒ Object



34
35
36
# File 'lib/builderator/model.rb', line 34

def unused(options = {})
  Util.filter(reject(in_use(options)), options.fetch('filters', {}))
end