Class: Sendgrid::Template

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(templates) ⇒ Template

Returns a new instance of Template.



6
7
8
# File 'lib/sendgrid/template.rb', line 6

def initialize(templates)
  @templates = templates
end

Instance Attribute Details

#templatesObject (readonly)

Returns the value of attribute templates.



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

def templates
  @templates
end

Instance Method Details

#get_id(name, locale) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/sendgrid/template.rb', line 10

def get_id(name, locale)
  [locale, :en].each do |lang|
    output = @templates.try(:[], name).try(:[], lang)

    return output if output
  end

  raise "No SendGrid template with #{name}, #{locale} nor :en as fallback"
end