Module: ActiveRecord::Pull::Alpha::Core
- Defined in:
- lib/activerecord/pull/alpha/core.rb
Class Method Summary collapse
-
.pull(record, query) ⇒ Hash
Apply the pull query to the given record.
-
.pull_many(records, query) ⇒ Array<Hash>
Apply the pull query to a collection of records.
Class Method Details
.pull(record, query) ⇒ Hash
Apply the pull query to the given record.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/activerecord/pull/alpha/core.rb', line 27 def pull(record, query) case query when :*, '*' pull_all(record) when Symbol, String pull_symbol(record, query) when Hash pull_hash(record, query) when Array # TODO: add filter_map as a core extension for older Ruby implementations query.map { |pat| pull(record, pat) }.reduce(&:merge) else raise SyntaxError, "invalid pull syntax: #{query.inspect}" end end |
.pull_many(records, query) ⇒ Array<Hash>
Apply the pull query to a collection of records.
17 18 19 |
# File 'lib/activerecord/pull/alpha/core.rb', line 17 def pull_many(records, query) records.map { |r| pull(r, query) } end |