class FoxPage::Controller
Constants
- DEFAULT_LAYOUT
Public Class Methods
before_action(method_name)
click to toggle source
# File lib/fox_page/controller.rb, line 12 def self.before_action(method_name) @__before_actions ||= [] @__before_actions << method_name end
generate_all(model)
click to toggle source
Instructs the site builder to generate pages for all records of `model`. model can be a symbol (which will use an actual FoxPage::Model
), or a Proc returning an Enumerable.
# File lib/fox_page/controller.rb, line 20 def self.generate_all(model) @__generate_all = model end
generate_all_ids(generate_all_ids)
click to toggle source
Set this to true if `generate_all` returns IDs (i.e. urls)
# File lib/fox_page/controller.rb, line 25 def self.generate_all_ids(generate_all_ids) @__generate_all_ids = generate_all_ids end
layout()
click to toggle source
# File lib/fox_page/controller.rb, line 8 def self.layout DEFAULT_LAYOUT end
method_added(method_name)
click to toggle source
# File lib/fox_page/controller.rb, line 33 def self.method_added(method_name) return unless @__generate_all.nil? || @__use_layout.nil? || @__generate_all_ids.nil? set_method_option(method_name, "generate_all") set_method_option(method_name, "generate_all_ids") set_method_option(method_name, "use_layout") end
use_layout(layout)
click to toggle source
# File lib/fox_page/controller.rb, line 29 def self.use_layout(layout) @__use_layout = layout end
Private Class Methods
set_method_option(method_name, option)
click to toggle source
# File lib/fox_page/controller.rb, line 41 def self.set_method_option(method_name, option) ivar_name = :"@__#{option}" ivar_for_name = :"@__#{option}_for" ivar_val = instance_variable_get(ivar_name) return if ivar_val.nil? instance_variable_set(ivar_name, nil) unless instance_variable_get(ivar_for_name) instance_variable_set(ivar_for_name, {}) end instance_variable_get(ivar_for_name)[method_name] = ivar_val end