Sha256: e4ac225fbce81cc053d46c4a409603ea4bb43c1ba85cd4e88f9dfbfa53fd5208
Contents?: true
Size: 786 Bytes
Versions: 1
Compression:
Stored size: 786 Bytes
Contents
require "tiny/record/version" module TinyRecord def self.included(base) base.extend ClassMethods end module ClassMethods @@with_columns = [] def tiny_columns(*args) @@with_columns = *args end def fetch(id, with: @@with_columns) get(primary_lookup(id), with).take! end def fetch_by(columns = {}) with = columns.delete(:with) get(columns, with).take end def fetch_where(columns = {}) with = columns.delete(:with) get(columns, with) end def get(by_columns, with_columns) collection = where(by_columns) collection = collection.select(with_columns) if with_columns.present? collection end def primary_lookup(lookup_id) { primary_key => lookup_id } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tiny-record-1.1.0 | lib/tiny/record.rb |