Sha256: 9cf175978c2f4f72b368aa7138fc2deef19be35fd873703334eb5d586aeb7c97

Contents?: true

Size: 898 Bytes

Versions: 12

Compression:

Stored size: 898 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

12 entries across 12 versions & 1 rubygems

Version Path
bindata-2.3.3 lib/bindata/name.rb
bindata-2.3.2 lib/bindata/name.rb
bindata-2.3.1 lib/bindata/name.rb
bindata-2.3.0 lib/bindata/name.rb
bindata-2.2.0 lib/bindata/name.rb
bindata-2.1.0 lib/bindata/name.rb
bindata-1.8.3 lib/bindata/name.rb
bindata-2.0.0 lib/bindata/name.rb
bindata-1.8.2 lib/bindata/name.rb
bindata-1.8.1 lib/bindata/name.rb
bindata-1.8.0 lib/bindata/name.rb
bindata-1.6.0 lib/bindata/name.rb