Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Auto-vivifying hash

  • Loading branch information...
commit 4441369814c836e35a198ab1144ad0d4cef5cc1f 1 parent da3b5ca
@PavelTyk PavelTyk authored
Showing with 3 additions and 7 deletions.
  1. +2 −6 lib/send_grid/api_header.rb
  2. +1 −1  lib/send_grid/version.rb
View
8 lib/send_grid/api_header.rb
@@ -2,16 +2,15 @@ class SendGrid::ApiHeader
attr_reader :data
def initialize
- @data = {}
+ @data = Hash.new { |h,k| h[k] = Hash.new(&h.default_proc) }
end
def add_recipients(recipients)
- @data[:to] ||= []
+ @data[:to] = [] unless @data[:to].instance_of?(Array)
@data[:to] |= Array.wrap(recipients)
end
def substitute(var, val)
- @data[:sub] ||= {}
@data[:sub][var] = Array.wrap(val)
end
@@ -24,9 +23,6 @@ def category(cat)
end
def add_filter_setting(fltr, setting, val)
- @data[:filters] ||= {}
- @data[:filters][fltr] ||= {}
- @data[:filters][fltr][:settings] ||= {}
@data[:filters][fltr][:settings][setting] = val
end
View
2  lib/send_grid/version.rb
@@ -1,4 +1,4 @@
module SendGrid
- VERSION = "1.1.0"
+ VERSION = "1.1.1"
end
Please sign in to comment.
Something went wrong with that request. Please try again.