Class: Trestle::Configuration

Inherits:
Object
  • Object
show all
Includes:
Configurable
Defined in:
lib/trestle/configuration.rb

Defined Under Namespace

Classes: Action

Instance Method Summary collapse

Methods included from Configurable

#as_json, #assign, #configure, #fetch, #inspect, #options

Instance Method Details

#after_action(options = {}, &block) ⇒ Object

Register a global after action



144
145
146
# File 'lib/trestle/configuration.rb', line 144

def after_action(options={}, &block)
  after_actions << Action.new(options, block)
end

#around_action(options = {}, &block) ⇒ Object

Register a global around action



152
153
154
# File 'lib/trestle/configuration.rb', line 152

def around_action(options={}, &block)
  around_actions << Action.new(options, block)
end

#before_action(options = {}, &block) ⇒ Object

Register a global before action



136
137
138
# File 'lib/trestle/configuration.rb', line 136

def before_action(options={}, &block)
  before_actions << Action.new(options, block)
end

#form_field(name, field) ⇒ Object

Register a custom form field class



98
99
100
# File 'lib/trestle/configuration.rb', line 98

def form_field(name, field)
  Form::Builder.register(name, field)
end

#helper(*helpers, &block) ⇒ Object

Register global helpers available to all Trestle admins



77
78
79
80
# File 'lib/trestle/configuration.rb', line 77

def helper(*helpers, &block)
  self.helpers << helpers
  self.helper_module.module_eval(&block) if block_given?
end

#hook(name, options = {}, &block) ⇒ Object

Register an extension hook



106
107
108
# File 'lib/trestle/configuration.rb', line 106

def hook(name, options={}, &block)
  hooks.append(name, options, &block)
end

Register a global navigation menu block



64
65
66
# File 'lib/trestle/configuration.rb', line 64

def menu(&block)
  menus << Navigation::Block.new(&block)
end

#theme=(colors) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/trestle/configuration.rb', line 28

def theme=(colors)
  if [true, false].include?(colors)
    Trestle.deprecator.warn("Passing a boolean to config.theme is deprecated. Please pass primary and secondary theme colors as a hash.")
  else
    original = fetch(:colors) || {}
    colors = colors.transform_values { |color| Trestle::Color.parse(color) }

    assign(:theme, original.merge(colors))
  end
end