Sha256: 129e6e3e145fd70e24fe483a30ee79f39aa375f37154866e900ffc8982e239e1

Contents?: true

Size: 598 Bytes

Versions: 4

Compression:

Stored size: 598 Bytes

Contents

# Handler for shared options
class Evil::Struct::Attributes
  # @private
  def self.call(*args, &block)
    new(*args).instance_eval(&block)
  end

  private

  def initialize(klass, **options)
    @klass   = klass
    @options = options
  end

  # Declares an attribute that shares options of the block
  # @param  (see Struct.attribute)
  # @option (see Struct.attribute)
  # @return (see Struct.attribute)
  def attribute(name, type = nil, **options)
    @klass.send :attribute, name, type, @options.merge(options)
  end
  alias_method :option, :attribute
  alias_method :param,  :attribute
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
evil-struct-0.0.4 lib/evil/struct/attributes.rb
evil-struct-0.0.3 lib/evil/struct/attributes.rb
evil-struct-0.0.2 lib/evil/struct/attributes.rb
evil-struct-0.0.1 lib/evil/struct/attributes.rb