Sha256: dd11fe6b1c43ee26c19be475d74945885181e1a03bc1f2ecdf9417d82f9d744f
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
require 'sequel' require 'clevic/model_column.rb' module Sequel module Plugins module Meta # plugin :meta calls this. # model is the model class. The rest is whatever options are # in the plugin call # plugin :meta def self.configure(model, options = {}) model.instance_eval do # store model-related stuff here end end module ClassMethods def meta if @meta.nil? @meta = {} db_schema.each do |key,value| @meta[key] = ModelColumn.new( key, value.merge( :association => false ) ) end association_reflections.each do |key,value| @meta[key] = ModelColumn.new( key, value.merge( :association => true ) ) end end @meta end # reload from current metadata def meta! @meta = nil meta end # column and relations, but not keys for defined relations def attributes meta.reject do |column,model_column| meta.values.map( &:keys ).include?( [ column ] ) end end end module InstanceMethods end end end end Sequel::Model.plugin :meta
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
clevic-0.13.0.b9 | lib/clevic/sequel_meta.rb |
clevic-0.13.0.b6 | lib/clevic/sequel_meta.rb |
clevic-0.13.0.b5 | lib/clevic/sequel_meta.rb |