Module: TrueWeb::Controller::Controllers::ClassMethods

Defined in:
lib/true-web/controller.rb

Instance Method Summary collapse

Instance Method Details

#controllersObject



75
76
77
# File 'lib/true-web/controller.rb', line 75

def controllers
  @controllers ||= []
end

#define_routes(&route_definition) ⇒ Object



69
70
71
72
73
# File 'lib/true-web/controller.rb', line 69

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



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/true-web/controller.rb', line 79

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