Class: HappyTitles::TemplateSet

Inherits:
Object
  • Object
show all
Defined in:
lib/happy-titles/template_set.rb

Instance Method Summary collapse

Constructor Details

#initialize(*templates) ⇒ TemplateSet

Returns a new instance of TemplateSet.



4
5
6
# File 'lib/happy-titles/template_set.rb', line 4

def initialize(*templates)
  @templates = templates
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object (private)



16
17
18
19
20
21
22
23
# File 'lib/happy-titles/template_set.rb', line 16

def method_missing(*args)
  delete_template(args[0])
  templates << HappyTitles::Template.new(
    name: args[0],
    without_title: args[1],
    with_title: args[2]
  )
end

Instance Method Details

#get(key) ⇒ Object



8
9
10
# File 'lib/happy-titles/template_set.rb', line 8

def get(key)
  find_template(key) || raise_template_not_found(key)
end