Sha256: 999cedad052bf1dea36d7e6f73e7aa81b1c926aec5b25c456b1a58e3b93a880e

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require 'sparkle_formation'
require 'attribute_struct/monkey_camels'

class SparkleFormation
  # SparkleFormation customized AttributeStruct
  class SparkleStruct < AttributeStruct

    include ::SparkleFormation::SparkleAttribute
    # @!parse include ::SparkleFormation::SparkleAttribute

    # Override initializer to force desired behavior
    def initialize(*_)
      super
      @_camel_keys = true
      _set_state :hash_load_struct => true
    end

    # Set SparkleFormation instance
    #
    # @param inst [SparkleFormation]
    # @return [SparkleFormation]
    def _set_self(inst)
      unless(inst.is_a?(::SparkleFormation))
        ::Kernel.raise ::TypeError.new "Expecting type of `SparkleFormation` but got `#{inst.class}`"
      end
      @self = inst
    end

    # @return [SparkleFormation]
    def _self(*_)
      unless(@self)
        if(_parent.nil?)
          ::Kernel.raise ::ArgumentError.new 'Creator did not provide return reference!'
        else
          _parent._self
        end
      else
        @self
      end
    end

    # @return [Class]
    def _klass
      ::SparkleFormation::SparkleStruct
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sparkle_formation-1.0.4 lib/sparkle_formation/sparkle_struct.rb
sparkle_formation-1.0.2 lib/sparkle_formation/sparkle_struct.rb
sparkle_formation-1.0.0 lib/sparkle_formation/sparkle_struct.rb