Module: BangBang::Controller::Controllers::ClassMethods

Defined in:
lib/bang-bang/controller.rb

Instance Method Summary collapse

Instance Method Details

#controllersObject



62
63
64
# File 'lib/bang-bang/controller.rb', line 62

def controllers
  @controllers ||= []
end

#define_routes(&route_definition) ⇒ Object



56
57
58
59
60
# File 'lib/bang-bang/controller.rb', line 56

def define_routes(&route_definition)
  controller = Class.new(self)
  controller.class_eval(&route_definition)
  controllers << controller
end

#pagelet_access_resources(pagelet_json_path, paglet_asset_json_path, html_path = nil) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/bang-bang/controller.rb', line 66

def pagelet_access_resources(pagelet_json_path, paglet_asset_json_path, html_path=nil)
  if html_path
    get html_path do
      send(html_path)
    end
  end

  get pagelet_json_path do
    response['Content-Type'] = 'application/json'
    send(paglet_asset_json_path).merge(
      html_path ? {
        :html => send(html_path)
      } : {}
    ).to_json
  end

  get paglet_asset_json_path do
    response['Content-Type'] = 'application/json'
    send(paglet_asset_json_path).to_json
  end
end