Class: Crumbs::Dsl::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/crumbs/dsl/controller.rb

Instance Method Summary collapse

Constructor Details

#initialize(prefix, &block) ⇒ Controller

Returns a new instance of Controller.



5
6
7
8
# File 'lib/crumbs/dsl/controller.rb', line 5

def initialize(prefix, &block)
  @prefix = prefix
  instance_eval(&block)
end

Instance Method Details

#crumb(action, name = nil, &block) ⇒ Object



10
11
12
# File 'lib/crumbs/dsl/controller.rb', line 10

def crumb(action, name=nil, &block)
  Crumbs.definitions.add "#{@prefix}##{action}", (block_given? ? block : name)
end

#t(key) ⇒ Object



14
15
16
17
18
19
# File 'lib/crumbs/dsl/controller.rb', line 14

def t(key)
  if key.starts_with?('.')
    key.prepend 'crumbs'
  end
  I18n.t key
end