Sha256: 5dadfc394ccead530ccc5dce144618ed1d9903076b4be29cc0811aca6821b247

Contents?: true

Size: 889 Bytes

Versions: 18

Compression:

Stored size: 889 Bytes

Contents

module BinData
  # == Parameters
  #
  # Parameters may be provided at initialisation to control the behaviour of
  # an object.  These parameters are:
  #
  # <tt>:name</tt>:: The name that this object can be referred to may be
  #                  set explicitly.  This is only useful when dynamically
  #                  generating types.
  #                  <code><pre>
  #                    BinData::Struct.new(name: :my_struct, fields: ...)
  #                    array = BinData::Array.new(type: :my_struct)
  #                  </pre></code>
  module RegisterNamePlugin

    def self.included(base) #:nodoc:
      # The registered name may be provided explicitly.
      base.optional_parameter :name
    end

    def initialize_shared_instance
      if has_parameter?(:name)
        RegisteredClasses.register(get_parameter(:name), self)
      end
      super
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
bindata-2.4.15 lib/bindata/name.rb
bindata-2.4.14 lib/bindata/name.rb
bindata-2.4.13 lib/bindata/name.rb
bindata-2.4.12 lib/bindata/name.rb
bindata-2.4.11 lib/bindata/name.rb
bindata-2.4.10 lib/bindata/name.rb
bindata-2.4.9 lib/bindata/name.rb
bindata-2.4.8 lib/bindata/name.rb
bindata-2.4.7 lib/bindata/name.rb
bindata-2.4.6 lib/bindata/name.rb
bindata-2.4.5 lib/bindata/name.rb
bindata-2.4.4 lib/bindata/name.rb
bindata-2.4.3 lib/bindata/name.rb
bindata-2.4.2 lib/bindata/name.rb
bindata-2.4.1 lib/bindata/name.rb
bindata-2.4.0 lib/bindata/name.rb
bindata-2.3.5 lib/bindata/name.rb
bindata-2.3.4 lib/bindata/name.rb