Class: Apical::Resource::Blueprint

Inherits:
Object
  • Object
show all
Defined in:
lib/apical/resource.rb

Instance Method Summary collapse

Constructor Details

#initialize(resource, &block) ⇒ Blueprint

Returns a new instance of Blueprint.



22
23
24
25
# File 'lib/apical/resource.rb', line 22

def initialize(resource, &block)
  @resource = resource
  instance_eval &block
end

Instance Method Details

#accept(format) ⇒ Object



31
32
33
# File 'lib/apical/resource.rb', line 31

def accept(format)
  @resource.accept = ContentType[format]
end

#after(&block) ⇒ Object



55
56
57
# File 'lib/apical/resource.rb', line 55

def after(&block)
  @resource.after_blocks << block
end

#auth_header(token) ⇒ Object



43
44
45
# File 'lib/apical/resource.rb', line 43

def auth_header(token)
  header 'Authorization', token
end

#before(&block) ⇒ Object



51
52
53
# File 'lib/apical/resource.rb', line 51

def before(&block)
  @resource.before_blocks << block
end

#content_type(format) ⇒ Object



35
36
37
# File 'lib/apical/resource.rb', line 35

def content_type(format)
  @resource.content_type = ContentType[format]
end

#desc(val) ⇒ Object



27
28
29
# File 'lib/apical/resource.rb', line 27

def desc(val)
  @resource.desc = val
end

#header(name, value) ⇒ Object



39
40
41
# File 'lib/apical/resource.rb', line 39

def header(name, value)
  @resource.custom_headers[name] = value
end

#params(&block) ⇒ Object



47
48
49
# File 'lib/apical/resource.rb', line 47

def params(&block)
  @resource.params = block
end