# File lib/bank/collection_config.rb, line 34 def primary_key(value = nil) value ? @_primary_key = value : @_primary_key ||= :id end
class Bank::CollectionConfig
Constants
- IDENTITY
Public Instance Methods
columns()
click to toggle source
# File lib/bank/collection_config.rb, line 38 def columns @_columns ||= Bank.db.schema(db) end
columns_of_type(type)
click to toggle source
# File lib/bank/collection_config.rb, line 42 def columns_of_type(type) columns.select { |col, opts| opts[:type] == type } end
db(&block)
click to toggle source
# File lib/bank/collection_config.rb, line 24 def db(&block) if block_given? @_db_block = block @_db = nil else value = @_db_block.call @_db ||= value.is_a?(Symbol) ? Bank[value] : value end end
model(&block)
click to toggle source
# File lib/bank/collection_config.rb, line 9 def model(&block) block_given? ? self._model_block = block : @_model ||= _model_block.call end
packer(blk)
click to toggle source
# File lib/bank/collection_config.rb, line 13 def packer(blk) packers << blk end
packers()
click to toggle source
# File lib/bank/collection_config.rb, line 16 def packers @_packers ||= Bank.config.default_packers end
primary_key(value = nil)
click to toggle source
unpacker(blk)
click to toggle source
# File lib/bank/collection_config.rb, line 14 def unpacker(blk) unpackers << blk end
unpackers()
click to toggle source
# File lib/bank/collection_config.rb, line 20 def unpackers @_unpackers ||= Bank.config.default_unpackers end