Sha256: f5a434f12ca7c481c8cd84daff1bbee142eb67a480d18e433f6686ba1cb5544c
Contents?: true
Size: 1.45 KB
Versions: 4
Compression:
Stored size: 1.45 KB
Contents
module Fish0 module Concerns module Base extend ActiveSupport::Concern def primary_key self.class.primary_key end def primary_key_value send(primary_key) end included do class << self def primary_key(val = @primary_key) @primary_key = val return default_primary_key unless @primary_key @primary_key end def cacheable include Concerns::Cacheable end def skip_coercion include Virtus.model(coerce: false) end def method_missing(method_name, *arguments, &block) if repository.respond_to?(method_name) repository.send(method_name, *arguments, &block) else super end end def respond_to_missing?(method_name, include_private = false) repository.respond_to?(method_name) || super end protected def default_primary_key :slug end def entity self end def collection model_name.collection end def repository if "#{entity}Repository".safe_constantize return "#{entity}Repository".constantize.new(collection, entity) end Fish0::Repository.new(collection, entity) end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
fish0-0.0.16 | lib/fish0/concerns/base.rb |
fish0-0.0.15 | lib/fish0/concerns/base.rb |
fish0-0.0.14 | lib/fish0/concerns/base.rb |
fish0-0.0.13 | lib/fish0/concerns/base.rb |