Sha256: 953dc73bf07bb941b6fcb273fb4c5b328b96b5e3317ad594bf34b0fc4cca3ec2

Contents?: true

Size: 865 Bytes

Versions: 18

Compression:

Stored size: 865 Bytes

Contents

# frozen_string_literal: true

# A singleton class to get the list of attributes
# from a work.
#
# It is a Singleton so that there is only one of these
# initialized and uses the ||= operator so that when you
# read the attributes property it uses an already initialized
# work.
#
# This is to ensure that we can get a list of the attributes
# programmatically, but without using any unnecessary memory.
module Zizia
  class WorkAttributes
    include Singleton
    attr_reader :attributes, :properties, :validators, :local_attributes

    def initialize
      work ||= klass.new
      @local_attributes || work.local_attributes
      @attributes ||= work.local_attributes
      @properties ||= work.send(:properties)
      @validators ||= work.send(:_validators)
    end

    # Override to choose a different Work class
    def klass
      Work
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
zizia-6.0.1 app/lib/zizia/work_attributes.rb
zizia-6.0.0 app/lib/zizia/work_attributes.rb
zizia-5.5.0 app/lib/zizia/work_attributes.rb
zizia-5.4.0 app/lib/zizia/work_attributes.rb
zizia-5.3.0 app/lib/zizia/work_attributes.rb
zizia-5.2.0 app/lib/zizia/work_attributes.rb
zizia-5.1.0 app/lib/zizia/work_attributes.rb
zizia-5.0.1 app/lib/zizia/work_attributes.rb
zizia-5.0.0 app/lib/zizia/work_attributes.rb
zizia-4.6.0.alpha.01 app/lib/zizia/work_attributes.rb
zizia-4.5.4.alpha.01 app/lib/zizia/work_attributes.rb
zizia-4.5.3.alpha.01 app/lib/zizia/work_attributes.rb
zizia-4.5.2.alpha.01 app/lib/zizia/work_attributes.rb
zizia-4.5.1.alpha.01 app/lib/zizia/work_attributes.rb
zizia-4.4.1.alpha.01 app/lib/zizia/work_attributes.rb
zizia-4.4.0.alpha.01 app/lib/zizia/work_attributes.rb
zizia-4.3.1.alpha.01 app/lib/zizia/work_attributes.rb
zizia-4.2.0.alpha.01 app/lib/zizia/work_attributes.rb