Class: Hovercraft::Builder

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hovercraft/builder.rb

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



15
16
17
# File 'lib/hovercraft/builder.rb', line 15

def initialize
  @loader = Loader.new
end

Instance Method Details

#applicationObject



19
20
21
22
23
24
25
# File 'lib/hovercraft/builder.rb', line 19

def application
  application = Sinatra.new
  application = configure(application)
  application = generate_filters(application)
  application = generate_routes(application)
  application
end

#configure(application) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/hovercraft/builder.rb', line 27

def configure(application)
  application.register(Hovercraft::Helpers)
  application.register(Hovercraft::Filters)
  application.register(Hovercraft::Routes)
  application.use(Rack::PostBodyContentTypeParser)
  application
end

#generate_filters(application) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/hovercraft/builder.rb', line 35

def generate_filters(application)
  Hovercraft::Filters.public_instance_methods.each do |filter|
    application.send(filter)
  end

  application
end

#generate_routes(application) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/hovercraft/builder.rb', line 43

def generate_routes(application)
  with_each_model do |model_class, model_name, plural_model_name|
    Hovercraft::Routes.public_instance_methods.each do |route|
      application.send(route, model_class, model_name, plural_model_name)
    end
  end

  application
end