Class: Sinatra::Schema::DSL::Links

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/schema/dsl/links.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Links

Returns a new instance of Links.



7
8
9
10
11
12
# File 'lib/sinatra/schema/dsl/links.rb', line 7

def initialize(options)
  @href     = options.fetch(:href)
  @method   = options.fetch(:method)
  @resource = options.fetch(:resource)
  @link     = build_link
end

Instance Attribute Details

#hrefObject

Returns the value of attribute href.



5
6
7
# File 'lib/sinatra/schema/dsl/links.rb', line 5

def href
  @href
end

Returns the value of attribute link.



5
6
7
# File 'lib/sinatra/schema/dsl/links.rb', line 5

def link
  @link
end

#methodObject

Returns the value of attribute method.



5
6
7
# File 'lib/sinatra/schema/dsl/links.rb', line 5

def method
  @method
end

#resourceObject

Returns the value of attribute resource.



5
6
7
# File 'lib/sinatra/schema/dsl/links.rb', line 5

def resource
  @resource
end

Instance Method Details

#action(&blk) ⇒ Object



26
27
28
# File 'lib/sinatra/schema/dsl/links.rb', line 26

def action(&blk)
  link.action_block = blk
end

#description(description) ⇒ Object



22
23
24
# File 'lib/sinatra/schema/dsl/links.rb', line 22

def description(description)
  link.description = description
end

#propertyObject



30
31
32
# File 'lib/sinatra/schema/dsl/links.rb', line 30

def property
  DSL::Definitions.new(resource, [resource.defs, link.properties])
end

#rel(rel) ⇒ Object



18
19
20
# File 'lib/sinatra/schema/dsl/links.rb', line 18

def rel(rel)
  link.rel = rel.to_sym
end

#title(title) ⇒ Object



14
15
16
# File 'lib/sinatra/schema/dsl/links.rb', line 14

def title(title)
  link.title = title
end