Method: PlainRecord::Model#all
- Defined in:
- lib/plain_record/model.rb
#all(matchers = { }, &block) ⇒ Object
Return all entries, which is match for matchers and return true on block.
Matchers is a Hash with property name in key and String or Regexp for match in value.
Post.all(title: 'Post title')
Post.all(title: /^Post/, summary: /cool/)
Post.all { |post| 20 < Post.content.length }
96 97 98 99 100 101 |
# File 'lib/plain_record/model.rb', line 96 def all(matchers = { }, &block) entries = all_entries(matchers) entries.delete_if { |i| not match(i, matchers) } if matchers entries.delete_if { |i| not block.call(i) } if block_given? entries end |