Class: WCC::Contentful::Store::MemoryStore::Query
- Inherits:
-
Base::Query
- Object
- Base::Query
- WCC::Contentful::Store::MemoryStore::Query
- Defined in:
- lib/wcc/contentful/store/memory_store.rb
Instance Method Summary collapse
- #eq(field, expected, context = nil) ⇒ Object
-
#initialize(relation) ⇒ Query
constructor
A new instance of Query.
- #result ⇒ Object
Methods inherited from Base::Query
Constructor Details
#initialize(relation) ⇒ Query
Returns a new instance of Query.
51 52 53 |
# File 'lib/wcc/contentful/store/memory_store.rb', line 51 def initialize(relation) @relation = relation end |
Instance Method Details
#eq(field, expected, context = nil) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/wcc/contentful/store/memory_store.rb', line 55 def eq(field, expected, context = nil) locale = context[:locale] if context.present? locale ||= 'en-US' Query.new(@relation.select do |v| val = v.dig('fields', field, locale) if val.is_a? Array val.include?(expected) else val == expected end end) end |
#result ⇒ Object
47 48 49 |
# File 'lib/wcc/contentful/store/memory_store.rb', line 47 def result @relation.dup end |