Sha256: 600d0368864d37adbffde215567a44765ac39c7d1ce1f24a22c8ef5c6e6e10d9
Contents?: true
Size: 1.11 KB
Versions: 12
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true # # Copyright (c) 2019-present, Blue Marble Payroll, LLC # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # module Dbee class Model # An Partitioner is a way to explicitly define constraints on a model. For example, say we # want to create a data model, but restrict the returned data to a subset based on a 'type' # column like ActiveRecord does for Single Table Inheritance. We could use a partition # to define this constraint. class Partitioner acts_as_hashable attr_reader :name, :value def initialize(name: '', value: nil) raise ArgumentError, 'name is required' if name.to_s.empty? @name = name.to_s @value = value end def <=>(other) "#{name}#{value}" <=> "#{other.name}#{other.value}" end def hash "#{name}#{value}".hash end def ==(other) other.instance_of?(self.class) && other.name == name && other.value == value end alias eql? == end end end
Version data entries
12 entries across 12 versions & 1 rubygems