Module: I18n::Tasks::Command::DSL::ClassMethods
- Defined in:
- lib/i18n/tasks/command/dsl.rb
Instance Method Summary collapse
- #arg(ref, *args) ⇒ Object
- #cmd(name, conf = nil) ⇒ Object
- #cmds ⇒ Object
- #dsl(key) ⇒ Object
-
#included(base) ⇒ Object
if class is a module, merge DSL definitions when it is included.
-
#t(*args, **kwargs) ⇒ Object
late-bound I18n.t for module bodies.
Instance Method Details
#arg(ref, *args) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/i18n/tasks/command/dsl.rb', line 28 def arg(ref, *args) if args.present? dsl(:args)[ref] = args else dsl(:args)[ref] end end |
#cmd(name, conf = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/i18n/tasks/command/dsl.rb', line 18 def cmd(name, conf = nil) if conf conf = conf.dup conf[:args] = (conf[:args] || []).map { |arg| arg.is_a?(Symbol) ? arg(arg) : arg } dsl(:cmds)[name] = conf else dsl(:cmds)[name] end end |
#cmds ⇒ Object
36 37 38 |
# File 'lib/i18n/tasks/command/dsl.rb', line 36 def cmds dsl(:cmds) end |
#dsl(key) ⇒ Object
40 41 42 |
# File 'lib/i18n/tasks/command/dsl.rb', line 40 def dsl(key) @dsl[key] end |
#included(base) ⇒ Object
if class is a module, merge DSL definitions when it is included
50 51 52 |
# File 'lib/i18n/tasks/command/dsl.rb', line 50 def included(base) base.instance_variable_get(:@dsl).deep_merge!(@dsl) end |
#t(*args, **kwargs) ⇒ Object
late-bound I18n.t for module bodies
45 46 47 |
# File 'lib/i18n/tasks/command/dsl.rb', line 45 def t(*args, **kwargs) proc { I18n.t(*args, **kwargs) } end |