Class: Halibut::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/halibut/builder.rb

Overview

Builder provides a very thin wrapper around creating a HAL resource.

Defined Under Namespace

Classes: RelationContext, RootContext

Instance Method Summary collapse

Constructor Details

#initialize(href = nil, &resource_definition) ⇒ Builder

Initializes a Builder object. Optionally receives an href pointing to the representation and a block containing DSL methods to build the resource.

Parameters:

  • href (String) (defaults to: nil)

    optional URI for the resource

  • resource_definition (Proc)

    DSL methods to build the resource


14
15
16
17
18
# File 'lib/halibut/builder.rb', line 14

def initialize(href=nil, &resource_definition)
  @resource = Halibut::Core::Resource.new href

  RootContext.new(@resource, &resource_definition)
end

Instance Method Details

#resourceHalibut::Core::Resource

Returns the resource built.

Returns:


23
24
25
# File 'lib/halibut/builder.rb', line 23

def resource
  @resource
end