Skip to content

Commit

Permalink
🐛 📖 Fix #49 with new query_ary_irrelevant_keys method.
Browse files Browse the repository at this point in the history
Add missing documentation for query_ary
  • Loading branch information
elifoster committed Sep 28, 2016
1 parent bf4299a commit e46acb5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion lib/mediawiki/butt.rb
Expand Up @@ -92,9 +92,19 @@ def query(params, base_return = [])
base_return
end

# Helper method for query methods that return a two-dimensional hashes in which the keys are not relevant to the
# returning value. In most cases this key is a redundant page or revision ID that is also available in the object.
# @param (see #query_ary)
def query_ary_irrelevant_keys(params, base_response_key, property_key)
query(params) do |return_val, query|
return_val.concat(query[base_response_key].values.collect { |obj| obj[property_key] })
end
end

# Helper method for query methods that return an array built from the query objects.
# @param params [Hash] A hash containing MediaWiki API parameters.
# @param
# @param base_response_key [String] The key inside the "query" object to collect.
# @param property_key [String] The key inside the object (under the base_response_key) to collect.
def query_ary(params, base_response_key, property_key)
query(params) do |return_val, query|
return_val.concat(query[base_response_key].collect { |obj| obj[property_key] })
Expand Down
2 changes: 1 addition & 1 deletion lib/mediawiki/query/properties/files.rb
Expand Up @@ -38,7 +38,7 @@ def get_all_duplicated_files(limit = @query_limit_default)
dflimit: get_limited(limit)
}

query_ary(params, 'pages', 'title')
query_ary_irrelevant_keys(params, 'pages', 'title')
end

# Gets the size of an image in bytes.
Expand Down

0 comments on commit e46acb5

Please sign in to comment.