Sha256: 0e0951564d8bf686163427576ac6614a70479218794e1b31450f3a6ccacf7f70

Contents?: true

Size: 790 Bytes

Versions: 2

Compression:

Stored size: 790 Bytes

Contents

require 'marc'

module MARCExtensions
  # Extensions to [MARC::Subfield](https://rubydoc.info/gems/marc/MARC/Subfield).
  module SubfieldExtensions

    # Recursively freezes this subfield, including its code and value.
    #
    # @return [Boolean] true if this subfield is frozen, false otherwise
    def frozen?
      [code, value].all?(&:frozen?) && super
    end

    # Whether this subfield and its code and value are frozen.
    # @return [MARC::Subfield] this subfield.
    def freeze
      [code, value].each(&:freeze)
      super
    end
  end
end

module MARC
  # Applies the extensions in {MARCExtensions::SubfieldExtensions}.
  # @see https://rubydoc.info/gems/marc/MARC/Subfield RubyGems documentation
  class Subfield
    prepend MARCExtensions::SubfieldExtensions
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
berkeley_library-marc-0.3.1 lib/marc_extensions/subfield.rb
berkeley_library-marc-0.3.0 lib/marc_extensions/subfield.rb