Sha256: 0ef9d77feba95766272cd83960d785a38a523b6f13b4ba7c3356f55714a94b52
Contents?: true
Size: 1.05 KB
Versions: 26
Compression:
Stored size: 1.05 KB
Contents
module Foobara class Entity < Model module Concerns module PrimaryKey include Concern foobara_delegate :primary_key_attribute, to: :class module ClassMethods def primary_key(attribute_name) if primary_key_attribute # :nocov: raise "Primary key already set to #{primary_key_attribute}" # :nocov: end if attribute_name.nil? || attribute_name.empty? # :nocov: raise ArgumentError, "Primary key can't be blank" # :nocov: end @primary_key_attribute = attribute_name.to_sym set_model_type end def primary_key_attribute return @primary_key_attribute if @primary_key_attribute unless superclass == Entity @primary_key_attribute = superclass.primary_key_attribute end end end def primary_key read_attribute(primary_key_attribute) end end end end end
Version data entries
26 entries across 26 versions & 1 rubygems