Class: EgovUtils::LoveMock

Inherits:
OpenStruct
  • Object
show all
Defined in:
app/resources/egov_utils/love.rb

Direct Known Subclasses

OrganizationMock

Class Method Summary collapse

Class Method Details

.allObject

Raises:

  • (NotImplemented)


18
19
20
# File 'app/resources/egov_utils/love.rb', line 18

def self.all
  raise NotImplemented # you need to provide .all for your mock class
end

.where(clauses = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/resources/egov_utils/love.rb', line 22

def self.where(clauses = {})
  all.select do |l|
    clauses.all? do |(k, filter)|
      case filter
      when Array
        filter = filter.collect(&:to_s)
        value = l.send(k)
        pp k, filter, value
        if value.is_a?(Array)
          !(value.collect(&:to_s) & filter).empty?
        else
          filter.include?(value.to_s)
        end
      else
        l.send(k) == filter
      end
    end
  end
end