Class: AcceptableApi::Builder

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

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



9
10
11
12
# File 'lib/acceptable_api/builder.rb', line 9

def initialize
  self.mappers = Mappers.new
  self.routes = Routes.new
end

Instance Method Details

#expose(controller_action, options = {}) ⇒ Object



21
22
23
24
# File 'lib/acceptable_api/builder.rb', line 21

def expose controller_action, options = {}
  route = Route.new options, controller_action
  self.routes << route
end

#register(from_to, &map_block) ⇒ Object



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

def register from_to, &map_block
  from = from_to.keys[0]
  to = from_to.values[0]
  mapper = Mapper.new from, to, &map_block
  self.mappers << mapper
end

#to_appObject



26
27
28
# File 'lib/acceptable_api/builder.rb', line 26

def to_app
  Application.new mappers, routes
end