Class: DNSer::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/dnser/template.rb

Defined Under Namespace

Classes: Unknown

Instance Method Summary collapse

Constructor Details

#initialize(params = {}, &block) ⇒ Template

Returns a new instance of Template.



3
4
5
6
# File 'lib/dnser/template.rb', line 3

def initialize(params = {}, &block)
  @block = block
  @params = params
end

Instance Method Details

#apply(domain, *args, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/dnser/template.rb', line 8

def apply(domain, *args, &block)
  if args.last.is_a? Hash
    args.push @params.merge(args.pop)
  else
    args.push @params
  end
  domain.instance_exec *args, &@block if @block
  domain.instance_exec *args, &block if block
end