Sha256: 7776fd2335e8a016d64515ed2bd2c98b76b1894e68a3ff187202431632f99438

Contents?: true

Size: 408 Bytes

Versions: 8

Compression:

Stored size: 408 Bytes

Contents

module XDR::DSL::Struct
  def attribute(name, type)

    unless type.is_a?(XDR::Concerns::ConvertsToXDR)
      raise ArgumentError, "#{type} does not convert to xdr"
    end

    self.fields = self.fields.merge(name => type)

    define_method name do
      read_attribute(name)
    end

    define_method "#{name}=" do |v|
      write_attribute(name, v)
    end

    define_attribute_methods name
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
xdr-3.0.2 lib/xdr/dsl/struct.rb
xdr-3.0.1 lib/xdr/dsl/struct.rb
xdr-3.0.0 lib/xdr/dsl/struct.rb
xdr-2.0.0 lib/xdr/dsl/struct.rb
xdr-1.0.0 lib/xdr/dsl/struct.rb
xdr-0.1.0 lib/xdr/dsl/struct.rb
xdr-0.0.4 lib/xdr/dsl/struct.rb
xdr-0.0.3 lib/xdr/dsl/struct.rb