Module: IronBank::Local
- Included in:
- User
- Defined in:
- lib/iron_bank/local.rb
Overview
A local store for exported records.
Instance Method Summary collapse
- #all ⇒ Object
- #find(id) ⇒ Object
- #find_each(&block) ⇒ Object
- #first ⇒ Object
- #reset_store ⇒ Object
- #where(conditions, limit: IronBank::Actions::Query::DEFAULT_ZUORA_LIMIT) ⇒ Object
Instance Method Details
#all ⇒ Object
18 19 20 |
# File 'lib/iron_bank/local.rb', line 18 def all store.any? ? store.values : super end |
#find(id) ⇒ Object
7 8 9 |
# File 'lib/iron_bank/local.rb', line 7 def find(id) store[id] || super end |
#find_each(&block) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/iron_bank/local.rb', line 11 def find_each(&block) return enum_for(:find_each) unless block values = store.values values.any? ? values.each(&block) : super end |
#first ⇒ Object
22 23 24 |
# File 'lib/iron_bank/local.rb', line 22 def first store.any? ? store.values.first : super end |
#reset_store ⇒ Object
36 37 38 |
# File 'lib/iron_bank/local.rb', line 36 def reset_store @store = nil end |
#where(conditions, limit: IronBank::Actions::Query::DEFAULT_ZUORA_LIMIT) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/iron_bank/local.rb', line 26 def where(conditions, limit: IronBank::Actions::Query::DEFAULT_ZUORA_LIMIT) records = store.values.select do |record| conditions.all? do |field, match_value| value_matches?(record.public_send(field), match_value) end end records.any? ? records : super end |