Module: Vandelay::Buildable::InstanceMethods

Defined in:
lib/vandelay/buildable.rb

Instance Method Summary collapse

Instance Method Details

#buildHash

Returns a hash of all the attributes & their set values. Best to practice would be to override this for your required formats.

def build
  base = super

  {
    extra_fields: 'my_values',
    buildable: base
  }
end

This could also be used to build a new object

class CarBuilder
  include Vandelay::Buildable
  made_of :wheels, :doors

  def get_car
    Car.new(build)
  end
end

Returns:

  • (Hash)

    filled with attributes and set values


42
43
44
# File 'lib/vandelay/buildable.rb', line 42

def build
  attribute_hash
end