lib/tumblr/post.rb in tumblr_client-0.7.2 vs lib/tumblr/post.rb in tumblr_client-0.7.3
- old
+ new
@@ -2,10 +2,11 @@
module Post
STANDARD_POST_OPTIONS = [:state, :tags, :tweet, :date, :markdown, :slug, :format]
def edit(blog_name, options = {})
+ convert_source_array :source, options
post(blog_path(blog_name, 'post/edit'), options)
end
def reblog(blog_name, options = {})
post(blog_path(blog_name, 'post/reblog'), options)
@@ -17,19 +18,12 @@
def photo(blog_name, options = {})
valid_opts = STANDARD_POST_OPTIONS + [:caption, :link, :data, :data_raw, :source, :photoset_layout]
validate_options(valid_opts, options)
validate_no_collision options, [:data, :source]
+ convert_source_array :source, options
- # Allow source to be passed as an Array
- if options.has_key?(:source) && options[:source].kind_of?(Array)
- options[:source].each.with_index do |src, idx|
- options["source[#{idx}]"] = src
- end
- options.delete(:source)
- end
-
options[:type] = 'photo'
extract_data!(options)
post(post_path(blog_name), options)
end
@@ -87,9 +81,19 @@
private
def post_path(blog_name)
blog_path(blog_name, 'post')
+ end
+
+ # Allow source to be passed as an Array
+ def convert_source_array(key, options)
+ if options.has_key?(key) && options[key].kind_of?(Array)
+ options[key].each.with_index do |src, idx|
+ options["#{key.to_s}[#{idx}]"] = src
+ end
+ options.delete(key)
+ end
end
# Look for the various ways that data can be passed, and normalize
# the result in this hash
def extract_data!(options)