id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
17,600 | github/elastomer-client | lib/elastomer/client/rest_api_spec/api_spec.rb | Elastomer::Client::RestApiSpec.ApiSpec.valid_param? | def valid_param?(api:, param:)
rest_api = get(api)
return true if rest_api.nil?
rest_api.valid_param?(param)
end | ruby | def valid_param?(api:, param:)
rest_api = get(api)
return true if rest_api.nil?
rest_api.valid_param?(param)
end | [
"def",
"valid_param?",
"(",
"api",
":",
",",
"param",
":",
")",
"rest_api",
"=",
"get",
"(",
"api",
")",
"return",
"true",
"if",
"rest_api",
".",
"nil?",
"rest_api",
".",
"valid_param?",
"(",
"param",
")",
"end"
] | Given an API descriptor name and a single request parameter, returns
`true` if the parameter is valid for the given API. This method always
returns `true` if the API is unknown.
api - the api descriptor name as a String
param - the request parameter name as a String
Returns `true` if the param is valid for the... | [
"Given",
"an",
"API",
"descriptor",
"name",
"and",
"a",
"single",
"request",
"parameter",
"returns",
"true",
"if",
"the",
"parameter",
"is",
"valid",
"for",
"the",
"given",
"API",
".",
"This",
"method",
"always",
"returns",
"true",
"if",
"the",
"API",
"is"... | b02aa42f23df9776443449d44c176f1dcea5e08d | https://github.com/github/elastomer-client/blob/b02aa42f23df9776443449d44c176f1dcea5e08d/lib/elastomer/client/rest_api_spec/api_spec.rb#L40-L44 |
17,601 | github/elastomer-client | lib/elastomer/client/rest_api_spec/api_spec.rb | Elastomer::Client::RestApiSpec.ApiSpec.select_parts | def select_parts(api:, from:)
rest_api = get(api)
return from if rest_api.nil?
rest_api.select_parts(from: from)
end | ruby | def select_parts(api:, from:)
rest_api = get(api)
return from if rest_api.nil?
rest_api.select_parts(from: from)
end | [
"def",
"select_parts",
"(",
"api",
":",
",",
"from",
":",
")",
"rest_api",
"=",
"get",
"(",
"api",
")",
"return",
"from",
"if",
"rest_api",
".",
"nil?",
"rest_api",
".",
"select_parts",
"(",
"from",
":",
"from",
")",
"end"
] | Given an API descriptor name and a set of request path parts, select those
parts that are accepted by the API endpoint.
api - the api descriptor name as a String
from - the Hash containing the path parts
Returns a new Hash containing the valid path parts for the api | [
"Given",
"an",
"API",
"descriptor",
"name",
"and",
"a",
"set",
"of",
"request",
"path",
"parts",
"select",
"those",
"parts",
"that",
"are",
"accepted",
"by",
"the",
"API",
"endpoint",
"."
] | b02aa42f23df9776443449d44c176f1dcea5e08d | https://github.com/github/elastomer-client/blob/b02aa42f23df9776443449d44c176f1dcea5e08d/lib/elastomer/client/rest_api_spec/api_spec.rb#L53-L57 |
17,602 | github/elastomer-client | lib/elastomer/client/rest_api_spec/api_spec.rb | Elastomer::Client::RestApiSpec.ApiSpec.valid_part? | def valid_part?(api:, part:)
rest_api = get(api)
return true if rest_api.nil?
rest_api.valid_part?(part)
end | ruby | def valid_part?(api:, part:)
rest_api = get(api)
return true if rest_api.nil?
rest_api.valid_part?(part)
end | [
"def",
"valid_part?",
"(",
"api",
":",
",",
"part",
":",
")",
"rest_api",
"=",
"get",
"(",
"api",
")",
"return",
"true",
"if",
"rest_api",
".",
"nil?",
"rest_api",
".",
"valid_part?",
"(",
"part",
")",
"end"
] | Given an API descriptor name and a single path part, returns `true` if the
path part is valid for the given API. This method always returns `true` if
the API is unknown.
api - the api descriptor name as a String
part - the path part name as a String
Returns `true` if the path part is valid for the API. | [
"Given",
"an",
"API",
"descriptor",
"name",
"and",
"a",
"single",
"path",
"part",
"returns",
"true",
"if",
"the",
"path",
"part",
"is",
"valid",
"for",
"the",
"given",
"API",
".",
"This",
"method",
"always",
"returns",
"true",
"if",
"the",
"API",
"is",
... | b02aa42f23df9776443449d44c176f1dcea5e08d | https://github.com/github/elastomer-client/blob/b02aa42f23df9776443449d44c176f1dcea5e08d/lib/elastomer/client/rest_api_spec/api_spec.rb#L67-L71 |
17,603 | github/elastomer-client | lib/elastomer/client/rest_api_spec/api_spec.rb | Elastomer::Client::RestApiSpec.ApiSpec.select_common_params | def select_common_params(from:)
return from if @common_params.empty?
from.select {|k,v| valid_common_param?(k)}
end | ruby | def select_common_params(from:)
return from if @common_params.empty?
from.select {|k,v| valid_common_param?(k)}
end | [
"def",
"select_common_params",
"(",
"from",
":",
")",
"return",
"from",
"if",
"@common_params",
".",
"empty?",
"from",
".",
"select",
"{",
"|",
"k",
",",
"v",
"|",
"valid_common_param?",
"(",
"k",
")",
"}",
"end"
] | Select the common request parameters from the given params.
from - the Hash containing the request params
Returns a new Hash containing the valid common request params | [
"Select",
"the",
"common",
"request",
"parameters",
"from",
"the",
"given",
"params",
"."
] | b02aa42f23df9776443449d44c176f1dcea5e08d | https://github.com/github/elastomer-client/blob/b02aa42f23df9776443449d44c176f1dcea5e08d/lib/elastomer/client/rest_api_spec/api_spec.rb#L78-L81 |
17,604 | github/elastomer-client | lib/elastomer/client/rest_api_spec/api_spec.rb | Elastomer::Client::RestApiSpec.ApiSpec.validate_params! | def validate_params!(api:, params:)
rest_api = get(api)
return params if rest_api.nil?
params.keys.each do |key|
unless rest_api.valid_param?(key) || valid_common_param?(key)
raise ::Elastomer::Client::IllegalArgument, "'#{key}' is not a valid parameter for the '#{api}' API"
... | ruby | def validate_params!(api:, params:)
rest_api = get(api)
return params if rest_api.nil?
params.keys.each do |key|
unless rest_api.valid_param?(key) || valid_common_param?(key)
raise ::Elastomer::Client::IllegalArgument, "'#{key}' is not a valid parameter for the '#{api}' API"
... | [
"def",
"validate_params!",
"(",
"api",
":",
",",
"params",
":",
")",
"rest_api",
"=",
"get",
"(",
"api",
")",
"return",
"params",
"if",
"rest_api",
".",
"nil?",
"params",
".",
"keys",
".",
"each",
"do",
"|",
"key",
"|",
"unless",
"rest_api",
".",
"va... | Given an API descriptor name and a set of request parameters, ensure that
all the request parameters are valid for the API endpoint. If an invalid
parameter is found then an IllegalArgument exception is raised.
api - the api descriptor name as a String
from - the Hash containing the request params
Returns the p... | [
"Given",
"an",
"API",
"descriptor",
"name",
"and",
"a",
"set",
"of",
"request",
"parameters",
"ensure",
"that",
"all",
"the",
"request",
"parameters",
"are",
"valid",
"for",
"the",
"API",
"endpoint",
".",
"If",
"an",
"invalid",
"parameter",
"is",
"found",
... | b02aa42f23df9776443449d44c176f1dcea5e08d | https://github.com/github/elastomer-client/blob/b02aa42f23df9776443449d44c176f1dcea5e08d/lib/elastomer/client/rest_api_spec/api_spec.rb#L97-L107 |
17,605 | github/elastomer-client | lib/elastomer/client/multi_search.rb | Elastomer.Client.multi_search | def multi_search(body = nil, params = nil)
if block_given?
params, body = (body || {}), nil
yield msearch_obj = MultiSearch.new(self, params)
msearch_obj.call
else
raise "multi_search request body cannot be nil" if body.nil?
params ||= {}
response = self.post... | ruby | def multi_search(body = nil, params = nil)
if block_given?
params, body = (body || {}), nil
yield msearch_obj = MultiSearch.new(self, params)
msearch_obj.call
else
raise "multi_search request body cannot be nil" if body.nil?
params ||= {}
response = self.post... | [
"def",
"multi_search",
"(",
"body",
"=",
"nil",
",",
"params",
"=",
"nil",
")",
"if",
"block_given?",
"params",
",",
"body",
"=",
"(",
"body",
"||",
"{",
"}",
")",
",",
"nil",
"yield",
"msearch_obj",
"=",
"MultiSearch",
".",
"new",
"(",
"self",
",",
... | Execute an array of searches in bulk. Results are returned in an
array in the order the queries were sent.
The `multi_search` method can be used in two ways. Without a block
the method will perform an API call, and it requires a bulk request
body and optional request parameters.
See https://www.elastic.co/guide/... | [
"Execute",
"an",
"array",
"of",
"searches",
"in",
"bulk",
".",
"Results",
"are",
"returned",
"in",
"an",
"array",
"in",
"the",
"order",
"the",
"queries",
"were",
"sent",
"."
] | b02aa42f23df9776443449d44c176f1dcea5e08d | https://github.com/github/elastomer-client/blob/b02aa42f23df9776443449d44c176f1dcea5e08d/lib/elastomer/client/multi_search.rb#L34-L46 |
17,606 | github/elastomer-client | lib/elastomer/client/multi_percolate.rb | Elastomer.Client.multi_percolate | def multi_percolate(body = nil, params = nil)
if block_given?
params, body = (body || {}), nil
yield mpercolate_obj = MultiPercolate.new(self, params)
mpercolate_obj.call
else
raise "multi_percolate request body cannot be nil" if body.nil?
params ||= {}
respo... | ruby | def multi_percolate(body = nil, params = nil)
if block_given?
params, body = (body || {}), nil
yield mpercolate_obj = MultiPercolate.new(self, params)
mpercolate_obj.call
else
raise "multi_percolate request body cannot be nil" if body.nil?
params ||= {}
respo... | [
"def",
"multi_percolate",
"(",
"body",
"=",
"nil",
",",
"params",
"=",
"nil",
")",
"if",
"block_given?",
"params",
",",
"body",
"=",
"(",
"body",
"||",
"{",
"}",
")",
",",
"nil",
"yield",
"mpercolate_obj",
"=",
"MultiPercolate",
".",
"new",
"(",
"self"... | Execute an array of percolate actions in bulk. Results are returned in an
array in the order the actions were sent.
The `multi_percolate` method can be used in two ways. Without a block
the method will perform an API call, and it requires a bulk request
body and optional request parameters.
See https://www.elast... | [
"Execute",
"an",
"array",
"of",
"percolate",
"actions",
"in",
"bulk",
".",
"Results",
"are",
"returned",
"in",
"an",
"array",
"in",
"the",
"order",
"the",
"actions",
"were",
"sent",
"."
] | b02aa42f23df9776443449d44c176f1dcea5e08d | https://github.com/github/elastomer-client/blob/b02aa42f23df9776443449d44c176f1dcea5e08d/lib/elastomer/client/multi_percolate.rb#L34-L46 |
17,607 | github/elastomer-client | lib/elastomer/client/bulk.rb | Elastomer.Client.bulk | def bulk( body = nil, params = nil )
if block_given?
params, body = (body || {}), nil
yield bulk_obj = Bulk.new(self, params)
bulk_obj.call
else
raise "bulk request body cannot be nil" if body.nil?
params ||= {}
response = self.post "{/index}{/type}/_bulk", ... | ruby | def bulk( body = nil, params = nil )
if block_given?
params, body = (body || {}), nil
yield bulk_obj = Bulk.new(self, params)
bulk_obj.call
else
raise "bulk request body cannot be nil" if body.nil?
params ||= {}
response = self.post "{/index}{/type}/_bulk", ... | [
"def",
"bulk",
"(",
"body",
"=",
"nil",
",",
"params",
"=",
"nil",
")",
"if",
"block_given?",
"params",
",",
"body",
"=",
"(",
"body",
"||",
"{",
"}",
")",
",",
"nil",
"yield",
"bulk_obj",
"=",
"Bulk",
".",
"new",
"(",
"self",
",",
"params",
")",... | The `bulk` method can be used in two ways. Without a block the method
will perform an API call, and it requires a bulk request body and
optional request parameters. If given a block, the method will use a
Bulk instance to assemble the operations called in the block into a
bulk request and dispatch it at the end of ... | [
"The",
"bulk",
"method",
"can",
"be",
"used",
"in",
"two",
"ways",
".",
"Without",
"a",
"block",
"the",
"method",
"will",
"perform",
"an",
"API",
"call",
"and",
"it",
"requires",
"a",
"bulk",
"request",
"body",
"and",
"optional",
"request",
"parameters",
... | b02aa42f23df9776443449d44c176f1dcea5e08d | https://github.com/github/elastomer-client/blob/b02aa42f23df9776443449d44c176f1dcea5e08d/lib/elastomer/client/bulk.rb#L31-L44 |
17,608 | github/elastomer-client | lib/elastomer/client/bulk.rb | Elastomer.Client.bulk_stream_responses | def bulk_stream_responses(ops, params = {})
bulk_obj = Bulk.new(self, params)
Enumerator.new do |yielder|
ops.each do |action, *args|
response = bulk_obj.send(action, *args)
yielder.yield response unless response.nil?
end
response = bulk_obj.call
yielder... | ruby | def bulk_stream_responses(ops, params = {})
bulk_obj = Bulk.new(self, params)
Enumerator.new do |yielder|
ops.each do |action, *args|
response = bulk_obj.send(action, *args)
yielder.yield response unless response.nil?
end
response = bulk_obj.call
yielder... | [
"def",
"bulk_stream_responses",
"(",
"ops",
",",
"params",
"=",
"{",
"}",
")",
"bulk_obj",
"=",
"Bulk",
".",
"new",
"(",
"self",
",",
"params",
")",
"Enumerator",
".",
"new",
"do",
"|",
"yielder",
"|",
"ops",
".",
"each",
"do",
"|",
"action",
",",
... | Stream bulk actions from an Enumerator.
Examples
ops = [
[:index, document1, {:_type => "foo", :_id => 1}],
[:create, document2],
[:delete, {:_type => "bar", :_id => 42}]
]
bulk_stream_responses(ops, :index => 'default-index').each do |response|
puts response
end
Returns an Enumerat... | [
"Stream",
"bulk",
"actions",
"from",
"an",
"Enumerator",
"."
] | b02aa42f23df9776443449d44c176f1dcea5e08d | https://github.com/github/elastomer-client/blob/b02aa42f23df9776443449d44c176f1dcea5e08d/lib/elastomer/client/bulk.rb#L60-L72 |
17,609 | github/elastomer-client | lib/elastomer/client/bulk.rb | Elastomer.Client.bulk_stream_items | def bulk_stream_items(ops, params = {})
stats = {
"took" => 0,
"errors" => false,
"success" => 0,
"failure" => 0
}
bulk_stream_responses(ops, params).each do |response|
stats["took"] += response["took"]
stats["errors"] |= response["errors"]
res... | ruby | def bulk_stream_items(ops, params = {})
stats = {
"took" => 0,
"errors" => false,
"success" => 0,
"failure" => 0
}
bulk_stream_responses(ops, params).each do |response|
stats["took"] += response["took"]
stats["errors"] |= response["errors"]
res... | [
"def",
"bulk_stream_items",
"(",
"ops",
",",
"params",
"=",
"{",
"}",
")",
"stats",
"=",
"{",
"\"took\"",
"=>",
"0",
",",
"\"errors\"",
"=>",
"false",
",",
"\"success\"",
"=>",
"0",
",",
"\"failure\"",
"=>",
"0",
"}",
"bulk_stream_responses",
"(",
"ops",... | Stream bulk actions from an Enumerator and passes the response items to
the given block.
Examples
ops = [
[:index, document1, {:_type => "foo", :_id => 1}],
[:create, document2],
[:delete, {:_type => "bar", :_id => 42}]
]
bulk_stream_items(ops, :index => 'default-index') do |item|
puts ... | [
"Stream",
"bulk",
"actions",
"from",
"an",
"Enumerator",
"and",
"passes",
"the",
"response",
"items",
"to",
"the",
"given",
"block",
"."
] | b02aa42f23df9776443449d44c176f1dcea5e08d | https://github.com/github/elastomer-client/blob/b02aa42f23df9776443449d44c176f1dcea5e08d/lib/elastomer/client/bulk.rb#L119-L142 |
17,610 | mdsol/representors | lib/representors/representor.rb | Representors.Representor.identifier | def identifier
@identifier ||= begin
uri = @representor_hash.href || self.object_id
protocol = @representor_hash.protocol || (uri == self.object_id ? UNKNOWN_PROTOCOL : DEFAULT_PROTOCOL)
PROTOCOL_TEMPLATE % [protocol, uri]
end
end | ruby | def identifier
@identifier ||= begin
uri = @representor_hash.href || self.object_id
protocol = @representor_hash.protocol || (uri == self.object_id ? UNKNOWN_PROTOCOL : DEFAULT_PROTOCOL)
PROTOCOL_TEMPLATE % [protocol, uri]
end
end | [
"def",
"identifier",
"@identifier",
"||=",
"begin",
"uri",
"=",
"@representor_hash",
".",
"href",
"||",
"self",
".",
"object_id",
"protocol",
"=",
"@representor_hash",
".",
"protocol",
"||",
"(",
"uri",
"==",
"self",
".",
"object_id",
"?",
"UNKNOWN_PROTOCOL",
... | The URI for the object
@note If the URI can't be made from the provided information it constructs one from the Ruby ID
@return [String] | [
"The",
"URI",
"for",
"the",
"object"
] | 319e5c1a42c93ef65a252ddd1e1a21dcc962a0ee | https://github.com/mdsol/representors/blob/319e5c1a42c93ef65a252ddd1e1a21dcc962a0ee/lib/representors/representor.rb#L54-L60 |
17,611 | mdsol/representors | lib/representor_support/utilities.rb | RepresentorSupport.Utilities.symbolize_keys | def symbolize_keys(hash)
Hash[hash.map{|(k,v)| [k.to_sym,v]}]
end | ruby | def symbolize_keys(hash)
Hash[hash.map{|(k,v)| [k.to_sym,v]}]
end | [
"def",
"symbolize_keys",
"(",
"hash",
")",
"Hash",
"[",
"hash",
".",
"map",
"{",
"|",
"(",
"k",
",",
"v",
")",
"|",
"[",
"k",
".",
"to_sym",
",",
"v",
"]",
"}",
"]",
"end"
] | Accepts a hash and returns a new hash with symbolized keys | [
"Accepts",
"a",
"hash",
"and",
"returns",
"a",
"new",
"hash",
"with",
"symbolized",
"keys"
] | 319e5c1a42c93ef65a252ddd1e1a21dcc962a0ee | https://github.com/mdsol/representors/blob/319e5c1a42c93ef65a252ddd1e1a21dcc962a0ee/lib/representor_support/utilities.rb#L5-L7 |
17,612 | mdsol/representors | lib/representors/serialization/hale_deserializer.rb | Representors.HaleDeserializer.deserialize_embedded | def deserialize_embedded(builder, media)
make_embedded_resource = ->(x) { self.class.new(x).to_representor_hash.to_h }
(media[EMBEDDED_KEY] || {}).each do |name, value|
resource_hash = map_or_apply(make_embedded_resource, value)
builder = builder.add_embedded(name, resource_hash)
end
... | ruby | def deserialize_embedded(builder, media)
make_embedded_resource = ->(x) { self.class.new(x).to_representor_hash.to_h }
(media[EMBEDDED_KEY] || {}).each do |name, value|
resource_hash = map_or_apply(make_embedded_resource, value)
builder = builder.add_embedded(name, resource_hash)
end
... | [
"def",
"deserialize_embedded",
"(",
"builder",
",",
"media",
")",
"make_embedded_resource",
"=",
"->",
"(",
"x",
")",
"{",
"self",
".",
"class",
".",
"new",
"(",
"x",
")",
".",
"to_representor_hash",
".",
"to_h",
"}",
"(",
"media",
"[",
"EMBEDDED_KEY",
"... | embedded resources are under '_embedded' in the original document, similarly to links they can
contain an array or a single embedded resource. An embedded resource is a full document so
we create a new HaleDeserializer for each. | [
"embedded",
"resources",
"are",
"under",
"_embedded",
"in",
"the",
"original",
"document",
"similarly",
"to",
"links",
"they",
"can",
"contain",
"an",
"array",
"or",
"a",
"single",
"embedded",
"resource",
".",
"An",
"embedded",
"resource",
"is",
"a",
"full",
... | 319e5c1a42c93ef65a252ddd1e1a21dcc962a0ee | https://github.com/mdsol/representors/blob/319e5c1a42c93ef65a252ddd1e1a21dcc962a0ee/lib/representors/serialization/hale_deserializer.rb#L81-L88 |
17,613 | mdsol/representors | lib/representors/representor_builder.rb | Representors.RepresentorBuilder.add_attribute | def add_attribute(name, value, options={})
new_representor_hash = RepresentorHash.new(deep_dup(@representor_hash.to_h))
new_representor_hash.attributes[name] = options.merge({value: value})
RepresentorBuilder.new(new_representor_hash)
end | ruby | def add_attribute(name, value, options={})
new_representor_hash = RepresentorHash.new(deep_dup(@representor_hash.to_h))
new_representor_hash.attributes[name] = options.merge({value: value})
RepresentorBuilder.new(new_representor_hash)
end | [
"def",
"add_attribute",
"(",
"name",
",",
"value",
",",
"options",
"=",
"{",
"}",
")",
"new_representor_hash",
"=",
"RepresentorHash",
".",
"new",
"(",
"deep_dup",
"(",
"@representor_hash",
".",
"to_h",
")",
")",
"new_representor_hash",
".",
"attributes",
"[",... | Adds an attribute to the Representor. We are creating a hash where the keys are the
names of the attributes | [
"Adds",
"an",
"attribute",
"to",
"the",
"Representor",
".",
"We",
"are",
"creating",
"a",
"hash",
"where",
"the",
"keys",
"are",
"the",
"names",
"of",
"the",
"attributes"
] | 319e5c1a42c93ef65a252ddd1e1a21dcc962a0ee | https://github.com/mdsol/representors/blob/319e5c1a42c93ef65a252ddd1e1a21dcc962a0ee/lib/representors/representor_builder.rb#L27-L31 |
17,614 | mdsol/representors | lib/representors/representor_builder.rb | Representors.RepresentorBuilder.add_transition | def add_transition(rel, href, options={})
new_representor_hash = RepresentorHash.new(deep_dup(@representor_hash.to_h))
options = symbolize_keys(options)
options.delete(:method) if options[:method] == Transition::DEFAULT_METHOD
link_values = options.merge({href: href, rel: rel})
if options... | ruby | def add_transition(rel, href, options={})
new_representor_hash = RepresentorHash.new(deep_dup(@representor_hash.to_h))
options = symbolize_keys(options)
options.delete(:method) if options[:method] == Transition::DEFAULT_METHOD
link_values = options.merge({href: href, rel: rel})
if options... | [
"def",
"add_transition",
"(",
"rel",
",",
"href",
",",
"options",
"=",
"{",
"}",
")",
"new_representor_hash",
"=",
"RepresentorHash",
".",
"new",
"(",
"deep_dup",
"(",
"@representor_hash",
".",
"to_h",
")",
")",
"options",
"=",
"symbolize_keys",
"(",
"option... | Adds a transition to the Representor, each transition is a hash of values
The transition collection is an Array | [
"Adds",
"a",
"transition",
"to",
"the",
"Representor",
"each",
"transition",
"is",
"a",
"hash",
"of",
"values",
"The",
"transition",
"collection",
"is",
"an",
"Array"
] | 319e5c1a42c93ef65a252ddd1e1a21dcc962a0ee | https://github.com/mdsol/representors/blob/319e5c1a42c93ef65a252ddd1e1a21dcc962a0ee/lib/representors/representor_builder.rb#L35-L47 |
17,615 | mdsol/representors | lib/representors/representor_builder.rb | Representors.RepresentorBuilder.add_transition_array | def add_transition_array(rel, array_of_hashes)
array_of_hashes.reduce(RepresentorBuilder.new(@representor_hash)) do |memo, transition|
transition = symbolize_keys(transition)
href = transition.delete(:href)
memo = memo.add_transition(rel, href, transition)
end
end | ruby | def add_transition_array(rel, array_of_hashes)
array_of_hashes.reduce(RepresentorBuilder.new(@representor_hash)) do |memo, transition|
transition = symbolize_keys(transition)
href = transition.delete(:href)
memo = memo.add_transition(rel, href, transition)
end
end | [
"def",
"add_transition_array",
"(",
"rel",
",",
"array_of_hashes",
")",
"array_of_hashes",
".",
"reduce",
"(",
"RepresentorBuilder",
".",
"new",
"(",
"@representor_hash",
")",
")",
"do",
"|",
"memo",
",",
"transition",
"|",
"transition",
"=",
"symbolize_keys",
"... | Adds directly an array to our array of transitions | [
"Adds",
"directly",
"an",
"array",
"to",
"our",
"array",
"of",
"transitions"
] | 319e5c1a42c93ef65a252ddd1e1a21dcc962a0ee | https://github.com/mdsol/representors/blob/319e5c1a42c93ef65a252ddd1e1a21dcc962a0ee/lib/representors/representor_builder.rb#L50-L56 |
17,616 | rsim/oracle-enhanced | lib/active_record/connection_adapters/oracle_enhanced/procedures.rb | ActiveRecord.OracleEnhancedProcedures._create_record | def _create_record
# check if class has custom create method
if self.class.custom_create_method
# run before/after callbacks defined in model
run_callbacks(:create) do
# timestamp
if self.record_timestamps
current_time = current_time_from_proper_... | ruby | def _create_record
# check if class has custom create method
if self.class.custom_create_method
# run before/after callbacks defined in model
run_callbacks(:create) do
# timestamp
if self.record_timestamps
current_time = current_time_from_proper_... | [
"def",
"_create_record",
"# check if class has custom create method",
"if",
"self",
".",
"class",
".",
"custom_create_method",
"# run before/after callbacks defined in model",
"run_callbacks",
"(",
":create",
")",
"do",
"# timestamp",
"if",
"self",
".",
"record_timestamps",
"... | Creates a record with custom create method
and returns its id. | [
"Creates",
"a",
"record",
"with",
"custom",
"create",
"method",
"and",
"returns",
"its",
"id",
"."
] | 03d4c557ceaf613ecce8657c47ebd9e936b31b7d | https://github.com/rsim/oracle-enhanced/blob/03d4c557ceaf613ecce8657c47ebd9e936b31b7d/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb#L103-L124 |
17,617 | rsim/oracle-enhanced | lib/active_record/connection_adapters/oracle_enhanced/procedures.rb | ActiveRecord.OracleEnhancedProcedures._update_record | def _update_record(attribute_names = @attributes.keys)
# check if class has custom update method
if self.class.custom_update_method
# run before/after callbacks defined in model
run_callbacks(:update) do
# timestamp
if should_record_timestamps?
c... | ruby | def _update_record(attribute_names = @attributes.keys)
# check if class has custom update method
if self.class.custom_update_method
# run before/after callbacks defined in model
run_callbacks(:update) do
# timestamp
if should_record_timestamps?
c... | [
"def",
"_update_record",
"(",
"attribute_names",
"=",
"@attributes",
".",
"keys",
")",
"# check if class has custom update method",
"if",
"self",
".",
"class",
".",
"custom_update_method",
"# run before/after callbacks defined in model",
"run_callbacks",
"(",
":update",
")",
... | Updates the associated record with custom update method
Returns the number of affected rows. | [
"Updates",
"the",
"associated",
"record",
"with",
"custom",
"update",
"method",
"Returns",
"the",
"number",
"of",
"affected",
"rows",
"."
] | 03d4c557ceaf613ecce8657c47ebd9e936b31b7d | https://github.com/rsim/oracle-enhanced/blob/03d4c557ceaf613ecce8657c47ebd9e936b31b7d/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb#L138-L165 |
17,618 | recurly/recurly-client-ruby | lib/recurly/coupon.rb | Recurly.Coupon.redeem | def redeem account_or_code, currency = nil, extra_opts={}
return false unless link? :redeem
account_code = if account_or_code.is_a? Account
account_or_code.account_code
else
account_or_code
end
redemption_options = {
:account_code => account_code,
:currenc... | ruby | def redeem account_or_code, currency = nil, extra_opts={}
return false unless link? :redeem
account_code = if account_or_code.is_a? Account
account_or_code.account_code
else
account_or_code
end
redemption_options = {
:account_code => account_code,
:currenc... | [
"def",
"redeem",
"account_or_code",
",",
"currency",
"=",
"nil",
",",
"extra_opts",
"=",
"{",
"}",
"return",
"false",
"unless",
"link?",
":redeem",
"account_code",
"=",
"if",
"account_or_code",
".",
"is_a?",
"Account",
"account_or_code",
".",
"account_code",
"el... | Redeem a coupon with a given account or account code.
@return [true]
@param account_or_code [Account, String]
@param currency [String] Three-letter currency code
@param extra_opts [Hash] extra options that go into the {Redemption}
@example
coupon = Coupon.find(coupon_code)
coupon.redeem(account_code, 'USD',... | [
"Redeem",
"a",
"coupon",
"with",
"a",
"given",
"account",
"or",
"account",
"code",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/coupon.rb#L65-L87 |
17,619 | recurly/recurly-client-ruby | lib/recurly/coupon.rb | Recurly.Coupon.generate | def generate(amount)
builder = XML.new("<coupon/>")
builder.add_element 'number_of_unique_codes', amount
resp = follow_link(:generate,
:body => builder.to_s
)
Pager.new(Recurly::Coupon, uri: resp['location'], parent: self, etag: resp['ETag'])
end | ruby | def generate(amount)
builder = XML.new("<coupon/>")
builder.add_element 'number_of_unique_codes', amount
resp = follow_link(:generate,
:body => builder.to_s
)
Pager.new(Recurly::Coupon, uri: resp['location'], parent: self, etag: resp['ETag'])
end | [
"def",
"generate",
"(",
"amount",
")",
"builder",
"=",
"XML",
".",
"new",
"(",
"\"<coupon/>\"",
")",
"builder",
".",
"add_element",
"'number_of_unique_codes'",
",",
"amount",
"resp",
"=",
"follow_link",
"(",
":generate",
",",
":body",
"=>",
"builder",
".",
"... | Generate unique coupon codes on the server. This is based on the unique_template_code.
@param amount [Integer]
@return [Pager<Coupon>] A pager that yields the coupon-code type Coupons
@example
unique_codes = coupon.generate(10)
unique_codes.each do |c|
puts c.coupon_code
end | [
"Generate",
"unique",
"coupon",
"codes",
"on",
"the",
"server",
".",
"This",
"is",
"based",
"on",
"the",
"unique_template_code",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/coupon.rb#L98-L107 |
17,620 | recurly/recurly-client-ruby | lib/recurly/coupon.rb | Recurly.Coupon.redeem! | def redeem!(account_code, currency = nil)
redemption = redeem(account_code, currency)
raise Invalid.new(self) unless redemption && redemption.persisted?
redemption
end | ruby | def redeem!(account_code, currency = nil)
redemption = redeem(account_code, currency)
raise Invalid.new(self) unless redemption && redemption.persisted?
redemption
end | [
"def",
"redeem!",
"(",
"account_code",
",",
"currency",
"=",
"nil",
")",
"redemption",
"=",
"redeem",
"(",
"account_code",
",",
"currency",
")",
"raise",
"Invalid",
".",
"new",
"(",
"self",
")",
"unless",
"redemption",
"&&",
"redemption",
".",
"persisted?",
... | Redeem a coupon on the given account code
@param account_code [String] Acccount's account code
@param currency [String] Three-letter currency code
@raise [Invalid] If the coupon cannot be redeemed
@return [Redemption] The Coupon Redemption | [
"Redeem",
"a",
"coupon",
"on",
"the",
"given",
"account",
"code"
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/coupon.rb#L115-L119 |
17,621 | recurly/recurly-client-ruby | lib/recurly/resource.rb | Recurly.Resource.read_attribute | def read_attribute(key)
key = key.to_s
if attributes.key? key
value = attributes[key]
elsif links.key?(key) && self.class.reflect_on_association(key)
value = attributes[key] = follow_link key
end
value
end | ruby | def read_attribute(key)
key = key.to_s
if attributes.key? key
value = attributes[key]
elsif links.key?(key) && self.class.reflect_on_association(key)
value = attributes[key] = follow_link key
end
value
end | [
"def",
"read_attribute",
"(",
"key",
")",
"key",
"=",
"key",
".",
"to_s",
"if",
"attributes",
".",
"key?",
"key",
"value",
"=",
"attributes",
"[",
"key",
"]",
"elsif",
"links",
".",
"key?",
"(",
"key",
")",
"&&",
"self",
".",
"class",
".",
"reflect_o... | The value of a specified attribute, lazily fetching any defined
association.
@param key [Symbol, String] The name of the attribute to be fetched.
@example
account.read_attribute :first_name # => "Ted"
account[:last_name] # => "Beneke"
@see #write_attribute | [
"The",
"value",
"of",
"a",
"specified",
"attribute",
"lazily",
"fetching",
"any",
"defined",
"association",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/resource.rb#L722-L730 |
17,622 | recurly/recurly-client-ruby | lib/recurly/resource.rb | Recurly.Resource.write_attribute | def write_attribute(key, value)
if changed_attributes.key?(key = key.to_s)
changed_attributes.delete key if changed_attributes[key] == value
elsif self[key] != value
changed_attributes[key] = self[key]
end
association = self.class.find_association(key)
if association
... | ruby | def write_attribute(key, value)
if changed_attributes.key?(key = key.to_s)
changed_attributes.delete key if changed_attributes[key] == value
elsif self[key] != value
changed_attributes[key] = self[key]
end
association = self.class.find_association(key)
if association
... | [
"def",
"write_attribute",
"(",
"key",
",",
"value",
")",
"if",
"changed_attributes",
".",
"key?",
"(",
"key",
"=",
"key",
".",
"to_s",
")",
"changed_attributes",
".",
"delete",
"key",
"if",
"changed_attributes",
"[",
"key",
"]",
"==",
"value",
"elsif",
"se... | Sets the value of a specified attribute.
@param key [Symbol, String] The name of the attribute to be set.
@param value [Object] The value the attribute will be set to.
@example
account.write_attribute :first_name, 'Gus'
account[:company_name] = 'Los Pollos Hermanos'
@see #read_attribute | [
"Sets",
"the",
"value",
"of",
"a",
"specified",
"attribute",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/resource.rb#L741-L757 |
17,623 | recurly/recurly-client-ruby | lib/recurly/resource.rb | Recurly.Resource.attributes= | def attributes=(attributes = {})
attributes.each_pair { |k, v|
respond_to?(name = "#{k}=") and send(name, v) or self[k] = v
}
end | ruby | def attributes=(attributes = {})
attributes.each_pair { |k, v|
respond_to?(name = "#{k}=") and send(name, v) or self[k] = v
}
end | [
"def",
"attributes",
"=",
"(",
"attributes",
"=",
"{",
"}",
")",
"attributes",
".",
"each_pair",
"{",
"|",
"k",
",",
"v",
"|",
"respond_to?",
"(",
"name",
"=",
"\"#{k}=\"",
")",
"and",
"send",
"(",
"name",
",",
"v",
")",
"or",
"self",
"[",
"k",
"... | Apply a given hash of attributes to a record.
@return [Hash]
@param attributes [Hash] A hash of attributes. | [
"Apply",
"a",
"given",
"hash",
"of",
"attributes",
"to",
"a",
"record",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/resource.rb#L764-L768 |
17,624 | recurly/recurly-client-ruby | lib/recurly/resource.rb | Recurly.Resource.follow_link | def follow_link(key, options = {})
if link = links[key = key.to_s]
response = API.send link[:method], link[:href], options[:body], options
if resource_class = link[:resource_class]
response = resource_class.from_response response
response.attributes[self.class.member_name] = se... | ruby | def follow_link(key, options = {})
if link = links[key = key.to_s]
response = API.send link[:method], link[:href], options[:body], options
if resource_class = link[:resource_class]
response = resource_class.from_response response
response.attributes[self.class.member_name] = se... | [
"def",
"follow_link",
"(",
"key",
",",
"options",
"=",
"{",
"}",
")",
"if",
"link",
"=",
"links",
"[",
"key",
"=",
"key",
".",
"to_s",
"]",
"response",
"=",
"API",
".",
"send",
"link",
"[",
":method",
"]",
",",
"link",
"[",
":href",
"]",
",",
"... | Fetch the value of a link by following the associated href.
@param key [Symbol, String] The name of the link to be followed.
@param options [Hash] A hash of API options.
@example
account.read_link :billing_info # => <Recurly::BillingInfo> | [
"Fetch",
"the",
"value",
"of",
"a",
"link",
"by",
"following",
"the",
"associated",
"href",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/resource.rb#L794-L805 |
17,625 | recurly/recurly-client-ruby | lib/recurly/resource.rb | Recurly.Resource.to_xml | def to_xml(options = {})
builder = options[:builder] || XML.new("<#{self.class.member_name}/>")
xml_keys.each { |key|
value = respond_to?(key) ? send(key) : self[key]
node = builder.add_element key
# Duck-typing here is problematic because of ActiveSupport's #to_xml.
case va... | ruby | def to_xml(options = {})
builder = options[:builder] || XML.new("<#{self.class.member_name}/>")
xml_keys.each { |key|
value = respond_to?(key) ? send(key) : self[key]
node = builder.add_element key
# Duck-typing here is problematic because of ActiveSupport's #to_xml.
case va... | [
"def",
"to_xml",
"(",
"options",
"=",
"{",
"}",
")",
"builder",
"=",
"options",
"[",
":builder",
"]",
"||",
"XML",
".",
"new",
"(",
"\"<#{self.class.member_name}/>\"",
")",
"xml_keys",
".",
"each",
"{",
"|",
"key",
"|",
"value",
"=",
"respond_to?",
"(",
... | Serializes the record to XML.
@return [String] An XML string.
@param options [Hash] A hash of XML options.
@example
Recurly::Account.new(:account_code => 'code').to_xml
# => "<account><account_code>code</account_code></account>" | [
"Serializes",
"the",
"record",
"to",
"XML",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/resource.rb#L814-L843 |
17,626 | recurly/recurly-client-ruby | lib/recurly/resource.rb | Recurly.Resource.save | def save
if new_record? || changed?
clear_errors
@response = API.send(
persisted? ? :put : :post, path, to_xml
)
reload response
persist! true
end
true
rescue API::UnprocessableEntity => e
apply_errors e
Transaction::Error.validate! e, ... | ruby | def save
if new_record? || changed?
clear_errors
@response = API.send(
persisted? ? :put : :post, path, to_xml
)
reload response
persist! true
end
true
rescue API::UnprocessableEntity => e
apply_errors e
Transaction::Error.validate! e, ... | [
"def",
"save",
"if",
"new_record?",
"||",
"changed?",
"clear_errors",
"@response",
"=",
"API",
".",
"send",
"(",
"persisted?",
"?",
":put",
":",
":post",
",",
"path",
",",
"to_xml",
")",
"reload",
"response",
"persist!",
"true",
"end",
"true",
"rescue",
"A... | Attempts to save the record, returning the success of the request.
@return [true, false]
@raise [Transaction::Error] A monetary transaction failed.
@example
account = Recurly::Account.new
account.save # => false
account.account_code = 'account_code'
account.save # => true
@see #save! | [
"Attempts",
"to",
"save",
"the",
"record",
"returning",
"the",
"success",
"of",
"the",
"request",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/resource.rb#L855-L869 |
17,627 | recurly/recurly-client-ruby | lib/recurly/resource.rb | Recurly.Resource.destroy | def destroy
return false unless persisted?
@response = API.delete uri
@destroyed = true
rescue API::NotFound => e
raise NotFound, e.description
end | ruby | def destroy
return false unless persisted?
@response = API.delete uri
@destroyed = true
rescue API::NotFound => e
raise NotFound, e.description
end | [
"def",
"destroy",
"return",
"false",
"unless",
"persisted?",
"@response",
"=",
"API",
".",
"delete",
"uri",
"@destroyed",
"=",
"true",
"rescue",
"API",
"::",
"NotFound",
"=>",
"e",
"raise",
"NotFound",
",",
"e",
".",
"description",
"end"
] | Attempts to destroy the record.
@return [true, false] +true+ if successful, +false+ if unable to destroy
(if the record does not persist on Recurly).
@raise [NotFound] The record cannot be found.
@example
account = Recurly::Account.find account_code
race_condition = Recurly::Account.find account_code
acco... | [
"Attempts",
"to",
"destroy",
"the",
"record",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/resource.rb#L980-L986 |
17,628 | recurly/recurly-client-ruby | lib/recurly/account.rb | Recurly.Account.invoice! | def invoice!(attrs={})
InvoiceCollection.from_response API.post(invoices.uri, attrs.empty? ? nil : Invoice.to_xml(attrs))
rescue Recurly::API::UnprocessableEntity => e
raise Invalid, e.message
end | ruby | def invoice!(attrs={})
InvoiceCollection.from_response API.post(invoices.uri, attrs.empty? ? nil : Invoice.to_xml(attrs))
rescue Recurly::API::UnprocessableEntity => e
raise Invalid, e.message
end | [
"def",
"invoice!",
"(",
"attrs",
"=",
"{",
"}",
")",
"InvoiceCollection",
".",
"from_response",
"API",
".",
"post",
"(",
"invoices",
".",
"uri",
",",
"attrs",
".",
"empty?",
"?",
"nil",
":",
"Invoice",
".",
"to_xml",
"(",
"attrs",
")",
")",
"rescue",
... | Creates an invoice from the pending charges on the account.
Raises an error if it fails.
@return [InvoiceCollection] A newly-created invoice.
@raise [Invalid] Raised if the account cannot be invoiced. | [
"Creates",
"an",
"invoice",
"from",
"the",
"pending",
"charges",
"on",
"the",
"account",
".",
"Raises",
"an",
"error",
"if",
"it",
"fails",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/account.rb#L109-L113 |
17,629 | recurly/recurly-client-ruby | lib/recurly/account.rb | Recurly.Account.build_invoice | def build_invoice
InvoiceCollection.from_response API.post("#{invoices.uri}/preview")
rescue Recurly::API::UnprocessableEntity => e
raise Invalid, e.message
end | ruby | def build_invoice
InvoiceCollection.from_response API.post("#{invoices.uri}/preview")
rescue Recurly::API::UnprocessableEntity => e
raise Invalid, e.message
end | [
"def",
"build_invoice",
"InvoiceCollection",
".",
"from_response",
"API",
".",
"post",
"(",
"\"#{invoices.uri}/preview\"",
")",
"rescue",
"Recurly",
"::",
"API",
"::",
"UnprocessableEntity",
"=>",
"e",
"raise",
"Invalid",
",",
"e",
".",
"message",
"end"
] | Builds an invoice from the pending charges on the account but does not persist the invoice.
Raises an error if it fails.
@return [InvoiceCollection] The newly-built invoice that has not been persisted.
@raise [Invalid] Raised if the account cannot be invoiced. | [
"Builds",
"an",
"invoice",
"from",
"the",
"pending",
"charges",
"on",
"the",
"account",
"but",
"does",
"not",
"persist",
"the",
"invoice",
".",
"Raises",
"an",
"error",
"if",
"it",
"fails",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/account.rb#L120-L124 |
17,630 | recurly/recurly-client-ruby | lib/recurly/account.rb | Recurly.Account.verify_cvv! | def verify_cvv!(verification_value)
bi = BillingInfo.new(verification_value: verification_value)
bi.uri = "#{path}/billing_info/verify_cvv"
bi.save!
bi
end | ruby | def verify_cvv!(verification_value)
bi = BillingInfo.new(verification_value: verification_value)
bi.uri = "#{path}/billing_info/verify_cvv"
bi.save!
bi
end | [
"def",
"verify_cvv!",
"(",
"verification_value",
")",
"bi",
"=",
"BillingInfo",
".",
"new",
"(",
"verification_value",
":",
"verification_value",
")",
"bi",
".",
"uri",
"=",
"\"#{path}/billing_info/verify_cvv\"",
"bi",
".",
"save!",
"bi",
"end"
] | Verify a cvv code for the account's billing info.
@example
acct = Recurly::Account.find('benjamin-du-monde')
begin
# If successful, returned billing_info will contain
# updated billing info details.
billing_info = acct.verify_cvv!("504")
rescue Recurly::API::BadRequest => e
e.message # =>... | [
"Verify",
"a",
"cvv",
"code",
"for",
"the",
"account",
"s",
"billing",
"info",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/account.rb#L163-L168 |
17,631 | recurly/recurly-client-ruby | lib/recurly/invoice.rb | Recurly.Invoice.enter_offline_payment | def enter_offline_payment(attrs={})
Transaction.from_response API.post("#{uri}/transactions", attrs.empty? ? nil : Transaction.to_xml(attrs))
rescue Recurly::API::UnprocessableEntity => e
raise Invalid, e.message
end | ruby | def enter_offline_payment(attrs={})
Transaction.from_response API.post("#{uri}/transactions", attrs.empty? ? nil : Transaction.to_xml(attrs))
rescue Recurly::API::UnprocessableEntity => e
raise Invalid, e.message
end | [
"def",
"enter_offline_payment",
"(",
"attrs",
"=",
"{",
"}",
")",
"Transaction",
".",
"from_response",
"API",
".",
"post",
"(",
"\"#{uri}/transactions\"",
",",
"attrs",
".",
"empty?",
"?",
"nil",
":",
"Transaction",
".",
"to_xml",
"(",
"attrs",
")",
")",
"... | Posts an offline payment on this invoice
@return [Transaction]
@raise [Error] If the transaction fails. | [
"Posts",
"an",
"offline",
"payment",
"on",
"this",
"invoice"
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/invoice.rb#L167-L171 |
17,632 | recurly/recurly-client-ruby | lib/recurly/gift_card.rb | Recurly.GiftCard.preview | def preview
clear_errors
@response = API.send(:post, "#{path}/preview", to_xml)
reload response
rescue API::UnprocessableEntity => e
apply_errors e
end | ruby | def preview
clear_errors
@response = API.send(:post, "#{path}/preview", to_xml)
reload response
rescue API::UnprocessableEntity => e
apply_errors e
end | [
"def",
"preview",
"clear_errors",
"@response",
"=",
"API",
".",
"send",
"(",
":post",
",",
"\"#{path}/preview\"",
",",
"to_xml",
")",
"reload",
"response",
"rescue",
"API",
"::",
"UnprocessableEntity",
"=>",
"e",
"apply_errors",
"e",
"end"
] | Preview the GiftCard. Runs and validates the GiftCard but
does not persist it. Errors are applied to the GiftCard if there
are any errors. | [
"Preview",
"the",
"GiftCard",
".",
"Runs",
"and",
"validates",
"the",
"GiftCard",
"but",
"does",
"not",
"persist",
"it",
".",
"Errors",
"are",
"applied",
"to",
"the",
"GiftCard",
"if",
"there",
"are",
"any",
"errors",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/gift_card.rb#L50-L56 |
17,633 | recurly/recurly-client-ruby | lib/recurly/subscription.rb | Recurly.Subscription.postpone | def postpone next_renewal_date, bulk=false
return false unless link? :postpone
reload follow_link(:postpone,
:params => { :next_renewal_date => next_renewal_date, :bulk => bulk }
)
true
end | ruby | def postpone next_renewal_date, bulk=false
return false unless link? :postpone
reload follow_link(:postpone,
:params => { :next_renewal_date => next_renewal_date, :bulk => bulk }
)
true
end | [
"def",
"postpone",
"next_renewal_date",
",",
"bulk",
"=",
"false",
"return",
"false",
"unless",
"link?",
":postpone",
"reload",
"follow_link",
"(",
":postpone",
",",
":params",
"=>",
"{",
":next_renewal_date",
"=>",
"next_renewal_date",
",",
":bulk",
"=>",
"bulk",... | Postpone a subscription's renewal date.
@return [true, false] +true+ when successful, +false+ when unable to
(e.g., the subscription is not active).
@param next_renewal_date [Time] when the subscription should renew.
@param bulk [boolean] set to true for bulk updates (bypassing 60 second wait). | [
"Postpone",
"a",
"subscription",
"s",
"renewal",
"date",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/subscription.rb#L228-L234 |
17,634 | recurly/recurly-client-ruby | lib/recurly/subscription.rb | Recurly.Subscription.update_notes | def update_notes(notes)
return false unless link? :notes
self.attributes = notes
reload follow_link(:notes, body: to_xml)
true
end | ruby | def update_notes(notes)
return false unless link? :notes
self.attributes = notes
reload follow_link(:notes, body: to_xml)
true
end | [
"def",
"update_notes",
"(",
"notes",
")",
"return",
"false",
"unless",
"link?",
":notes",
"self",
".",
"attributes",
"=",
"notes",
"reload",
"follow_link",
"(",
":notes",
",",
"body",
":",
"to_xml",
")",
"true",
"end"
] | Update the notes sections of the subscription. This endpoint also allows you to
update the custom fields.
@example
subscription.custom_fields.first.value = nil
subscription.update_notes(terms_and_conditions: 'New T&C')
#=>
# <subscription>
# <custom_fields><custom_field><name>food</name><value n... | [
"Update",
"the",
"notes",
"sections",
"of",
"the",
"subscription",
".",
"This",
"endpoint",
"also",
"allows",
"you",
"to",
"update",
"the",
"custom",
"fields",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/subscription.rb#L252-L257 |
17,635 | recurly/recurly-client-ruby | lib/recurly/subscription.rb | Recurly.Subscription.pause | def pause(remaining_pause_cycles)
builder = XML.new("<subscription/>")
builder.add_element('remaining_pause_cycles', remaining_pause_cycles)
reload API.put("#{uri}/pause", builder.to_s)
true
end | ruby | def pause(remaining_pause_cycles)
builder = XML.new("<subscription/>")
builder.add_element('remaining_pause_cycles', remaining_pause_cycles)
reload API.put("#{uri}/pause", builder.to_s)
true
end | [
"def",
"pause",
"(",
"remaining_pause_cycles",
")",
"builder",
"=",
"XML",
".",
"new",
"(",
"\"<subscription/>\"",
")",
"builder",
".",
"add_element",
"(",
"'remaining_pause_cycles'",
",",
"remaining_pause_cycles",
")",
"reload",
"API",
".",
"put",
"(",
"\"#{uri}/... | Pauses a subscription or cancels a scheduled pause.
* For an active subscription without a pause scheduled already,
this will schedule a pause period to begin at the next renewal
date for the specified number of billing cycles (remaining_pause_cycles).
* When a scheduled pause already exists, this will update the ... | [
"Pauses",
"a",
"subscription",
"or",
"cancels",
"a",
"scheduled",
"pause",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/subscription.rb#L273-L278 |
17,636 | recurly/recurly-client-ruby | lib/recurly/xml.rb | Recurly.XML.add_element | def add_element name, value = nil
value = value.respond_to?(:xmlschema) ? value.xmlschema : value.to_s
XML.new super(name, value)
end | ruby | def add_element name, value = nil
value = value.respond_to?(:xmlschema) ? value.xmlschema : value.to_s
XML.new super(name, value)
end | [
"def",
"add_element",
"name",
",",
"value",
"=",
"nil",
"value",
"=",
"value",
".",
"respond_to?",
"(",
":xmlschema",
")",
"?",
"value",
".",
"xmlschema",
":",
"value",
".",
"to_s",
"XML",
".",
"new",
"super",
"(",
"name",
",",
"value",
")",
"end"
] | Adds an element to the root. | [
"Adds",
"an",
"element",
"to",
"the",
"root",
"."
] | 3726114fdf584ba50982e0ee28fd219136043fbc | https://github.com/recurly/recurly-client-ruby/blob/3726114fdf584ba50982e0ee28fd219136043fbc/lib/recurly/xml.rb#L65-L68 |
17,637 | rodjek/rspec-puppet | lib/rspec-puppet/coverage.rb | RSpec::Puppet.Coverage.add_from_catalog | def add_from_catalog(catalog, test_module)
coverable_resources = catalog.to_a.reject { |resource| !test_module.nil? && filter_resource?(resource, test_module) }
coverable_resources.each do |resource|
add(resource)
end
end | ruby | def add_from_catalog(catalog, test_module)
coverable_resources = catalog.to_a.reject { |resource| !test_module.nil? && filter_resource?(resource, test_module) }
coverable_resources.each do |resource|
add(resource)
end
end | [
"def",
"add_from_catalog",
"(",
"catalog",
",",
"test_module",
")",
"coverable_resources",
"=",
"catalog",
".",
"to_a",
".",
"reject",
"{",
"|",
"resource",
"|",
"!",
"test_module",
".",
"nil?",
"&&",
"filter_resource?",
"(",
"resource",
",",
"test_module",
")... | add all resources from catalog declared in module test_module | [
"add",
"all",
"resources",
"from",
"catalog",
"declared",
"in",
"module",
"test_module"
] | 5cc25d0083a4abc352ab13bd48f225f668311a3e | https://github.com/rodjek/rspec-puppet/blob/5cc25d0083a4abc352ab13bd48f225f668311a3e/lib/rspec-puppet/coverage.rb#L102-L107 |
17,638 | rodjek/rspec-puppet | lib/rspec-puppet/coverage.rb | RSpec::Puppet.Coverage.filter_resource? | def filter_resource?(resource, test_module)
if @filters.include?(resource.to_s)
return true
end
if resource.type == 'Class'
module_name = resource.title.split('::').first.downcase
if module_name != test_module
return true
end
end
if resource.file... | ruby | def filter_resource?(resource, test_module)
if @filters.include?(resource.to_s)
return true
end
if resource.type == 'Class'
module_name = resource.title.split('::').first.downcase
if module_name != test_module
return true
end
end
if resource.file... | [
"def",
"filter_resource?",
"(",
"resource",
",",
"test_module",
")",
"if",
"@filters",
".",
"include?",
"(",
"resource",
".",
"to_s",
")",
"return",
"true",
"end",
"if",
"resource",
".",
"type",
"==",
"'Class'",
"module_name",
"=",
"resource",
".",
"title",
... | Should this resource be excluded from coverage reports?
The resource is not included in coverage reports if any of the conditions hold:
* The resource has been explicitly filtered out.
* Examples: autogenerated resources such as 'Stage[main]'
* The resource is a class but does not belong to the module und... | [
"Should",
"this",
"resource",
"be",
"excluded",
"from",
"coverage",
"reports?"
] | 5cc25d0083a4abc352ab13bd48f225f668311a3e | https://github.com/rodjek/rspec-puppet/blob/5cc25d0083a4abc352ab13bd48f225f668311a3e/lib/rspec-puppet/coverage.rb#L217-L237 |
17,639 | rodjek/rspec-puppet | lib/rspec-puppet/coverage.rb | RSpec::Puppet.Coverage.module_paths | def module_paths(test_module)
adapter = RSpec.configuration.adapter
paths = adapter.modulepath.map do |dir|
File.join(dir, test_module, 'manifests')
end
paths << adapter.manifest if adapter.manifest
paths
end | ruby | def module_paths(test_module)
adapter = RSpec.configuration.adapter
paths = adapter.modulepath.map do |dir|
File.join(dir, test_module, 'manifests')
end
paths << adapter.manifest if adapter.manifest
paths
end | [
"def",
"module_paths",
"(",
"test_module",
")",
"adapter",
"=",
"RSpec",
".",
"configuration",
".",
"adapter",
"paths",
"=",
"adapter",
".",
"modulepath",
".",
"map",
"do",
"|",
"dir",
"|",
"File",
".",
"join",
"(",
"dir",
",",
"test_module",
",",
"'mani... | Find all paths that may contain testable resources for a module.
@return [Array<String>] | [
"Find",
"all",
"paths",
"that",
"may",
"contain",
"testable",
"resources",
"for",
"a",
"module",
"."
] | 5cc25d0083a4abc352ab13bd48f225f668311a3e | https://github.com/rodjek/rspec-puppet/blob/5cc25d0083a4abc352ab13bd48f225f668311a3e/lib/rspec-puppet/coverage.rb#L242-L249 |
17,640 | rodjek/rspec-puppet | lib/rspec-puppet/example/function_example_group.rb | RSpec::Puppet.FunctionExampleGroup.build_compiler | def build_compiler
node_name = nodename(:function)
fact_values = facts_hash(node_name)
trusted_values = trusted_facts_hash(node_name)
# Allow different Hiera configurations:
HieraPuppet.instance_variable_set('@hiera', nil) if defined? HieraPuppet
# if we specify a pre_condition, ... | ruby | def build_compiler
node_name = nodename(:function)
fact_values = facts_hash(node_name)
trusted_values = trusted_facts_hash(node_name)
# Allow different Hiera configurations:
HieraPuppet.instance_variable_set('@hiera', nil) if defined? HieraPuppet
# if we specify a pre_condition, ... | [
"def",
"build_compiler",
"node_name",
"=",
"nodename",
"(",
":function",
")",
"fact_values",
"=",
"facts_hash",
"(",
"node_name",
")",
"trusted_values",
"=",
"trusted_facts_hash",
"(",
"node_name",
")",
"# Allow different Hiera configurations:",
"HieraPuppet",
".",
"ins... | get a compiler with an attached compiled catalog | [
"get",
"a",
"compiler",
"with",
"an",
"attached",
"compiled",
"catalog"
] | 5cc25d0083a4abc352ab13bd48f225f668311a3e | https://github.com/rodjek/rspec-puppet/blob/5cc25d0083a4abc352ab13bd48f225f668311a3e/lib/rspec-puppet/example/function_example_group.rb#L132-L177 |
17,641 | ManageIQ/manageiq-smartstate | lib/VolumeManager/LVM/thin/superblock.rb | Lvm2Thin.SuperBlock.device_to_data | def device_to_data(device_id, pos, len)
dev_blk = device_block(pos)
dev_off = device_block_offset(pos)
data_map = data_mapping.map_for(device_id)
total_len = 0
data_blks = []
num_data_blks = (len / data_block_size).to_i + 1
0.upto(num_data_blks - 1) do |i|
current_b... | ruby | def device_to_data(device_id, pos, len)
dev_blk = device_block(pos)
dev_off = device_block_offset(pos)
data_map = data_mapping.map_for(device_id)
total_len = 0
data_blks = []
num_data_blks = (len / data_block_size).to_i + 1
0.upto(num_data_blks - 1) do |i|
current_b... | [
"def",
"device_to_data",
"(",
"device_id",
",",
"pos",
",",
"len",
")",
"dev_blk",
"=",
"device_block",
"(",
"pos",
")",
"dev_off",
"=",
"device_block_offset",
"(",
"pos",
")",
"data_map",
"=",
"data_mapping",
".",
"map_for",
"(",
"device_id",
")",
"total_le... | Return array of tuples device block ids, data block ids, addresses, and lengths to
read from them to read the specified device offset & length.
Note: data blocks may not amount to total requested length (if requesting
data from unallocated space).
@see DataMap#block? | [
"Return",
"array",
"of",
"tuples",
"device",
"block",
"ids",
"data",
"block",
"ids",
"addresses",
"and",
"lengths",
"to",
"read",
"from",
"them",
"to",
"read",
"the",
"specified",
"device",
"offset",
"&",
"length",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/VolumeManager/LVM/thin/superblock.rb#L89-L131 |
17,642 | ManageIQ/manageiq-smartstate | lib/fs/ntfs/attrib_attribute_list.rb | NTFS.AttributeList.loadAttributes | def loadAttributes(attribType)
result = []
# ad is an attribute descriptor.
@list.each do |ad|
next unless ad['attrib_type'] == attribType
# Load referenced attribute and add it to parent.
result += @boot_sector.mftEntry(ad['mft']).loadAttributes(attribType)
end
... | ruby | def loadAttributes(attribType)
result = []
# ad is an attribute descriptor.
@list.each do |ad|
next unless ad['attrib_type'] == attribType
# Load referenced attribute and add it to parent.
result += @boot_sector.mftEntry(ad['mft']).loadAttributes(attribType)
end
... | [
"def",
"loadAttributes",
"(",
"attribType",
")",
"result",
"=",
"[",
"]",
"# ad is an attribute descriptor.",
"@list",
".",
"each",
"do",
"|",
"ad",
"|",
"next",
"unless",
"ad",
"[",
"'attrib_type'",
"]",
"==",
"attribType",
"# Load referenced attribute and add it t... | Load attributes of requested type | [
"Load",
"attributes",
"of",
"requested",
"type"
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/ntfs/attrib_attribute_list.rb#L97-L109 |
17,643 | ManageIQ/manageiq-smartstate | lib/fs/ntfs/attrib_data.rb | NTFS.AttribData.read | def read(bytes = @length)
return nil if @pos >= @length
bytes = @length - @pos if bytes.nil?
bytes = @length - @pos if @pos + bytes > @length
out = @data[@pos, bytes] if @data.kind_of?(String)
out = @data.read(bytes) if @data.kind_of?(NTFS::DataRun)
@pos += out.size
... | ruby | def read(bytes = @length)
return nil if @pos >= @length
bytes = @length - @pos if bytes.nil?
bytes = @length - @pos if @pos + bytes > @length
out = @data[@pos, bytes] if @data.kind_of?(String)
out = @data.read(bytes) if @data.kind_of?(NTFS::DataRun)
@pos += out.size
... | [
"def",
"read",
"(",
"bytes",
"=",
"@length",
")",
"return",
"nil",
"if",
"@pos",
">=",
"@length",
"bytes",
"=",
"@length",
"-",
"@pos",
"if",
"bytes",
".",
"nil?",
"bytes",
"=",
"@length",
"-",
"@pos",
"if",
"@pos",
"+",
"bytes",
">",
"@length",
"out... | This now behaves exactly like a normal read. | [
"This",
"now",
"behaves",
"exactly",
"like",
"a",
"normal",
"read",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/ntfs/attrib_data.rb#L41-L51 |
17,644 | ManageIQ/manageiq-smartstate | lib/fs/fat32/boot_sect.rb | Fat32.BootSect.getNextCluster | def getNextCluster(clus)
nxt = getFatEntry(clus)
return nil if nxt > CC_END_OF_CHAIN
raise "Damaged cluster in cluster chain" if nxt == CC_DAMAGED
[nxt, getCluster(nxt)]
end | ruby | def getNextCluster(clus)
nxt = getFatEntry(clus)
return nil if nxt > CC_END_OF_CHAIN
raise "Damaged cluster in cluster chain" if nxt == CC_DAMAGED
[nxt, getCluster(nxt)]
end | [
"def",
"getNextCluster",
"(",
"clus",
")",
"nxt",
"=",
"getFatEntry",
"(",
"clus",
")",
"return",
"nil",
"if",
"nxt",
">",
"CC_END_OF_CHAIN",
"raise",
"\"Damaged cluster in cluster chain\"",
"if",
"nxt",
"==",
"CC_DAMAGED",
"[",
"nxt",
",",
"getCluster",
"(",
... | Gets data for the next cluster given current, or nil if end. | [
"Gets",
"data",
"for",
"the",
"next",
"cluster",
"given",
"current",
"or",
"nil",
"if",
"end",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/fat32/boot_sect.rb#L183-L188 |
17,645 | ManageIQ/manageiq-smartstate | lib/fs/fat32/boot_sect.rb | Fat32.BootSect.countContigClusters | def countContigClusters(clus)
cur = clus; nxt = 0
loop do
nxt = getFatEntry(cur)
break if nxt != cur + 1
cur = nxt; redo
end
raise "Damaged cluster in cluster chain" if nxt == CC_DAMAGED
cur - clus + 1
end | ruby | def countContigClusters(clus)
cur = clus; nxt = 0
loop do
nxt = getFatEntry(cur)
break if nxt != cur + 1
cur = nxt; redo
end
raise "Damaged cluster in cluster chain" if nxt == CC_DAMAGED
cur - clus + 1
end | [
"def",
"countContigClusters",
"(",
"clus",
")",
"cur",
"=",
"clus",
";",
"nxt",
"=",
"0",
"loop",
"do",
"nxt",
"=",
"getFatEntry",
"(",
"cur",
")",
"break",
"if",
"nxt",
"!=",
"cur",
"+",
"1",
"cur",
"=",
"nxt",
";",
"redo",
"end",
"raise",
"\"Dama... | Count the number of continuous clusters from some beginning cluster. | [
"Count",
"the",
"number",
"of",
"continuous",
"clusters",
"from",
"some",
"beginning",
"cluster",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/fat32/boot_sect.rb#L227-L236 |
17,646 | ManageIQ/manageiq-smartstate | lib/fs/fat32/boot_sect.rb | Fat32.BootSect.wipeChain | def wipeChain(clus)
loop do
nxt = getFatEntry(clus)
putFatEntry(clus, 0)
break if nxt == 0 # A 0 entry means FAT is inconsistent. Chkdsk may report lost clusters.
break if nxt == CC_DAMAGED # This should never happen but if it does allow clusters to become lost.
break if nx... | ruby | def wipeChain(clus)
loop do
nxt = getFatEntry(clus)
putFatEntry(clus, 0)
break if nxt == 0 # A 0 entry means FAT is inconsistent. Chkdsk may report lost clusters.
break if nxt == CC_DAMAGED # This should never happen but if it does allow clusters to become lost.
break if nx... | [
"def",
"wipeChain",
"(",
"clus",
")",
"loop",
"do",
"nxt",
"=",
"getFatEntry",
"(",
"clus",
")",
"putFatEntry",
"(",
"clus",
",",
"0",
")",
"break",
"if",
"nxt",
"==",
"0",
"# A 0 entry means FAT is inconsistent. Chkdsk may report lost clusters.",
"break",
"if",
... | Deallocate all clusters on a chain from a starting cluster number. | [
"Deallocate",
"all",
"clusters",
"on",
"a",
"chain",
"from",
"a",
"starting",
"cluster",
"number",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/fat32/boot_sect.rb#L279-L288 |
17,647 | ManageIQ/manageiq-smartstate | lib/fs/fat32/boot_sect.rb | Fat32.BootSect.writeClusters | def writeClusters(start, buf, len = buf.length)
clus = start; num, leftover = len.divmod(@bytesPerCluster); num += 1 if leftover > 0
0.upto(num - 1) do |offset|
local = buf[offset * @bytesPerCluster, @bytesPerCluster]
if local.length < @bytesPerCluster then local += ("\0" * (@bytesPerCluster... | ruby | def writeClusters(start, buf, len = buf.length)
clus = start; num, leftover = len.divmod(@bytesPerCluster); num += 1 if leftover > 0
0.upto(num - 1) do |offset|
local = buf[offset * @bytesPerCluster, @bytesPerCluster]
if local.length < @bytesPerCluster then local += ("\0" * (@bytesPerCluster... | [
"def",
"writeClusters",
"(",
"start",
",",
"buf",
",",
"len",
"=",
"buf",
".",
"length",
")",
"clus",
"=",
"start",
";",
"num",
",",
"leftover",
"=",
"len",
".",
"divmod",
"(",
"@bytesPerCluster",
")",
";",
"num",
"+=",
"1",
"if",
"leftover",
">",
... | Start from defined cluster number and write data, following allocated cluster chain. | [
"Start",
"from",
"defined",
"cluster",
"number",
"and",
"write",
"data",
"following",
"allocated",
"cluster",
"chain",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/fat32/boot_sect.rb#L291-L303 |
17,648 | ManageIQ/manageiq-smartstate | lib/fs/fat32/boot_sect.rb | Fat32.BootSect.putFatEntry | def putFatEntry(clus, value)
raise "DONT TOUCH THIS CLUSTER: #{clus}" if clus < 3
@stream.seek(@fatBase + FAT_ENTRY_SIZE * clus)
@stream.write([value].pack('L'), FAT_ENTRY_SIZE)
end | ruby | def putFatEntry(clus, value)
raise "DONT TOUCH THIS CLUSTER: #{clus}" if clus < 3
@stream.seek(@fatBase + FAT_ENTRY_SIZE * clus)
@stream.write([value].pack('L'), FAT_ENTRY_SIZE)
end | [
"def",
"putFatEntry",
"(",
"clus",
",",
"value",
")",
"raise",
"\"DONT TOUCH THIS CLUSTER: #{clus}\"",
"if",
"clus",
"<",
"3",
"@stream",
".",
"seek",
"(",
"@fatBase",
"+",
"FAT_ENTRY_SIZE",
"*",
"clus",
")",
"@stream",
".",
"write",
"(",
"[",
"value",
"]",
... | Write a FAT entry for a cluster. | [
"Write",
"a",
"FAT",
"entry",
"for",
"a",
"cluster",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/fat32/boot_sect.rb#L318-L322 |
17,649 | ManageIQ/manageiq-smartstate | lib/fs/ntfs/boot_sect.rb | NTFS.BootSect.clusterInfo | def clusterInfo
return @clusterInfo unless @clusterInfo.nil?
# MFT Entry 6 ==> BITMAP Information
ad = mftEntry(6).attributeData
data = ad.read(ad.length)
ad.rewind
c = data.unpack("b#{data.length * 8}")[0]
nclusters = c.length
on = c.count("1")
uclusters = on
... | ruby | def clusterInfo
return @clusterInfo unless @clusterInfo.nil?
# MFT Entry 6 ==> BITMAP Information
ad = mftEntry(6).attributeData
data = ad.read(ad.length)
ad.rewind
c = data.unpack("b#{data.length * 8}")[0]
nclusters = c.length
on = c.count("1")
uclusters = on
... | [
"def",
"clusterInfo",
"return",
"@clusterInfo",
"unless",
"@clusterInfo",
".",
"nil?",
"# MFT Entry 6 ==> BITMAP Information",
"ad",
"=",
"mftEntry",
"(",
"6",
")",
".",
"attributeData",
"data",
"=",
"ad",
".",
"read",
"(",
"ad",
".",
"length",
")",
"ad",
".",... | From "File System Forensic Analysis" by Brian Carrier
The $Bitmap file, which is located in MFT entry 6, has a $DATA attribute that is used
to manage the allocation status of clusters. The bitmap data are organized into 1-byte
values, and the least significant bit of each byte corresponds to the cluster that follo... | [
"From",
"File",
"System",
"Forensic",
"Analysis",
"by",
"Brian",
"Carrier"
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/ntfs/boot_sect.rb#L135-L150 |
17,650 | ManageIQ/manageiq-smartstate | lib/fs/ntfs/boot_sect.rb | NTFS.BootSect.mftRecToBytePos | def mftRecToBytePos(recno)
# Return start of mft if rec 0 (no point in the rest of this).
return mftLoc if recno == 0
# Find which fragment contains the target mft record.
start = fragTable[0]; last_clusters = 0; target_cluster = recno * @bytesPerFileRec / @bytesPerCluster
if (recno > @by... | ruby | def mftRecToBytePos(recno)
# Return start of mft if rec 0 (no point in the rest of this).
return mftLoc if recno == 0
# Find which fragment contains the target mft record.
start = fragTable[0]; last_clusters = 0; target_cluster = recno * @bytesPerFileRec / @bytesPerCluster
if (recno > @by... | [
"def",
"mftRecToBytePos",
"(",
"recno",
")",
"# Return start of mft if rec 0 (no point in the rest of this).",
"return",
"mftLoc",
"if",
"recno",
"==",
"0",
"# Find which fragment contains the target mft record.",
"start",
"=",
"fragTable",
"[",
"0",
"]",
";",
"last_clusters"... | Use data run to convert mft record number to byte pos. | [
"Use",
"data",
"run",
"to",
"convert",
"mft",
"record",
"number",
"to",
"byte",
"pos",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/ntfs/boot_sect.rb#L230-L251 |
17,651 | ManageIQ/manageiq-smartstate | lib/fs/ntfs/directory_index_node.rb | NTFS.DirectoryIndexNode.dump | def dump
out = "\#<#{self.class}:0x#{'%08x' % object_id}>\n"
out << " Mft Ref : seq #{@refMft[0]}, entry #{@refMft[1]}\n"
out << " Length : #{@length}\n"
out << " Content : #{@contentLen}\n"
out << " Flags : 0x#{'%08x' % @flags}\n"
out << @afn.dump if @contentLen > 0
out... | ruby | def dump
out = "\#<#{self.class}:0x#{'%08x' % object_id}>\n"
out << " Mft Ref : seq #{@refMft[0]}, entry #{@refMft[1]}\n"
out << " Length : #{@length}\n"
out << " Content : #{@contentLen}\n"
out << " Flags : 0x#{'%08x' % @flags}\n"
out << @afn.dump if @contentLen > 0
out... | [
"def",
"dump",
"out",
"=",
"\"\\#<#{self.class}:0x#{'%08x' % object_id}>\\n\"",
"out",
"<<",
"\" Mft Ref : seq #{@refMft[0]}, entry #{@refMft[1]}\\n\"",
"out",
"<<",
"\" Length : #{@length}\\n\"",
"out",
"<<",
"\" Content : #{@contentLen}\\n\"",
"out",
"<<",
"\" Flags : 0x#{'%... | Dumps object. | [
"Dumps",
"object",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/ntfs/directory_index_node.rb#L99-L108 |
17,652 | ManageIQ/manageiq-smartstate | lib/fs/ext4/directory.rb | Ext4.Directory.globEntriesByHashTree | def globEntriesByHashTree
ents_by_name = {}
offset = 0
# Chomp fake '.' and '..' directories first
2.times do
de = DirectoryEntry.new(@data[offset..-1], @sb.isNewDirEnt?)
ents_by_name[de.name] ||= []
ents_by_name[de.name] << de
offset += 12
end
$log.i... | ruby | def globEntriesByHashTree
ents_by_name = {}
offset = 0
# Chomp fake '.' and '..' directories first
2.times do
de = DirectoryEntry.new(@data[offset..-1], @sb.isNewDirEnt?)
ents_by_name[de.name] ||= []
ents_by_name[de.name] << de
offset += 12
end
$log.i... | [
"def",
"globEntriesByHashTree",
"ents_by_name",
"=",
"{",
"}",
"offset",
"=",
"0",
"# Chomp fake '.' and '..' directories first",
"2",
".",
"times",
"do",
"de",
"=",
"DirectoryEntry",
".",
"new",
"(",
"@data",
"[",
"offset",
"..",
"-",
"1",
"]",
",",
"@sb",
... | If the inode has the IF_HASH_INDEX bit set,
then the first directory block is to be interpreted as the root of an HTree index. | [
"If",
"the",
"inode",
"has",
"the",
"IF_HASH_INDEX",
"bit",
"set",
"then",
"the",
"first",
"directory",
"block",
"is",
"to",
"be",
"interpreted",
"as",
"the",
"root",
"of",
"an",
"HTree",
"index",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/ext4/directory.rb#L66-L85 |
17,653 | ManageIQ/manageiq-smartstate | lib/db/MiqBdb/MiqBdbPage.rb | MiqBerkeleyDB.MiqBdbPage.dump | def dump
out = ""
out << "Page #{current}\n"
out << " type: #{MiqBdbPage.type2string(ptype)}\n"
out << " prev: #{prev}\n"
out << " next: #{@header['next_pgno']}\n"
out << " log seq num: file=#{@header['lsn_file']} offset=#{@header['lsn_offse... | ruby | def dump
out = ""
out << "Page #{current}\n"
out << " type: #{MiqBdbPage.type2string(ptype)}\n"
out << " prev: #{prev}\n"
out << " next: #{@header['next_pgno']}\n"
out << " log seq num: file=#{@header['lsn_file']} offset=#{@header['lsn_offse... | [
"def",
"dump",
"out",
"=",
"\"\"",
"out",
"<<",
"\"Page #{current}\\n\"",
"out",
"<<",
"\" type: #{MiqBdbPage.type2string(ptype)}\\n\"",
"out",
"<<",
"\" prev: #{prev}\\n\"",
"out",
"<<",
"\" next: #{@header['next_pgno']}\\n\"",
"out",
"<<",
... | Dump page statistics like db_dump. | [
"Dump",
"page",
"statistics",
"like",
"db_dump",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/db/MiqBdb/MiqBdbPage.rb#L131-L157 |
17,654 | ManageIQ/manageiq-smartstate | lib/fs/ntfs/attrib_index_root.rb | NTFS.IndexRoot.find | def find(name)
log_prefix = "MIQ(NTFS::IndexRoot.find)"
name = name.downcase
$log.debug "#{log_prefix} Searching for [#{name}]" if DEBUG_TRACE_FIND
if @foundEntries.key?(name)
$log.debug "#{log_prefix} Found [#{name}] (cached)" if DEBUG_TRACE_FIND
return @foundEntries[name]
... | ruby | def find(name)
log_prefix = "MIQ(NTFS::IndexRoot.find)"
name = name.downcase
$log.debug "#{log_prefix} Searching for [#{name}]" if DEBUG_TRACE_FIND
if @foundEntries.key?(name)
$log.debug "#{log_prefix} Found [#{name}] (cached)" if DEBUG_TRACE_FIND
return @foundEntries[name]
... | [
"def",
"find",
"(",
"name",
")",
"log_prefix",
"=",
"\"MIQ(NTFS::IndexRoot.find)\"",
"name",
"=",
"name",
".",
"downcase",
"$log",
".",
"debug",
"\"#{log_prefix} Searching for [#{name}]\"",
"if",
"DEBUG_TRACE_FIND",
"if",
"@foundEntries",
".",
"key?",
"(",
"name",
"... | Find a name in this index. | [
"Find",
"a",
"name",
"in",
"this",
"index",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/ntfs/attrib_index_root.rb#L106-L124 |
17,655 | ManageIQ/manageiq-smartstate | lib/fs/ntfs/attrib_index_root.rb | NTFS.IndexRoot.globNames | def globNames
@globNames = globEntries.collect { |e| e.namespace == NTFS::FileName::NS_DOS ? nil : e.name.downcase }.compact if @globNames.nil?
@globNames
end | ruby | def globNames
@globNames = globEntries.collect { |e| e.namespace == NTFS::FileName::NS_DOS ? nil : e.name.downcase }.compact if @globNames.nil?
@globNames
end | [
"def",
"globNames",
"@globNames",
"=",
"globEntries",
".",
"collect",
"{",
"|",
"e",
"|",
"e",
".",
"namespace",
"==",
"NTFS",
"::",
"FileName",
"::",
"NS_DOS",
"?",
"nil",
":",
"e",
".",
"name",
".",
"downcase",
"}",
".",
"compact",
"if",
"@globNames"... | Return all names in this index as a sorted string array. | [
"Return",
"all",
"names",
"in",
"this",
"index",
"as",
"a",
"sorted",
"string",
"array",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/ntfs/attrib_index_root.rb#L127-L130 |
17,656 | ManageIQ/manageiq-smartstate | lib/fs/ReiserFS/block.rb | ReiserFS.Block.getKey | def getKey(k)
return nil if k > @nitems || k <= 0
pos = SIZEOF_BLOCK_HEADER + (SIZEOF_KEY * (k - 1))
keydata = @data[pos, SIZEOF_KEY]
data2key(keydata)
end | ruby | def getKey(k)
return nil if k > @nitems || k <= 0
pos = SIZEOF_BLOCK_HEADER + (SIZEOF_KEY * (k - 1))
keydata = @data[pos, SIZEOF_KEY]
data2key(keydata)
end | [
"def",
"getKey",
"(",
"k",
")",
"return",
"nil",
"if",
"k",
">",
"@nitems",
"||",
"k",
"<=",
"0",
"pos",
"=",
"SIZEOF_BLOCK_HEADER",
"+",
"(",
"SIZEOF_KEY",
"*",
"(",
"k",
"-",
"1",
")",
")",
"keydata",
"=",
"@data",
"[",
"pos",
",",
"SIZEOF_KEY",
... | Keys are 1-based | [
"Keys",
"are",
"1",
"-",
"based"
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/ReiserFS/block.rb#L50-L55 |
17,657 | ManageIQ/manageiq-smartstate | lib/fs/ReiserFS/block.rb | ReiserFS.Block.getPointer | def getPointer(p)
# puts "getPointer >> p=#{p}"
return nil if p > @nitems || p < 0
pos = SIZEOF_BLOCK_HEADER + (SIZEOF_KEY * @nitems) + (SIZEOF_POINTER * p)
ptrdata = @data[pos, SIZEOF_POINTER]
POINTER.decode(ptrdata)
end | ruby | def getPointer(p)
# puts "getPointer >> p=#{p}"
return nil if p > @nitems || p < 0
pos = SIZEOF_BLOCK_HEADER + (SIZEOF_KEY * @nitems) + (SIZEOF_POINTER * p)
ptrdata = @data[pos, SIZEOF_POINTER]
POINTER.decode(ptrdata)
end | [
"def",
"getPointer",
"(",
"p",
")",
"# puts \"getPointer >> p=#{p}\"",
"return",
"nil",
"if",
"p",
">",
"@nitems",
"||",
"p",
"<",
"0",
"pos",
"=",
"SIZEOF_BLOCK_HEADER",
"+",
"(",
"SIZEOF_KEY",
"*",
"@nitems",
")",
"+",
"(",
"SIZEOF_POINTER",
"*",
"p",
")... | Pointers are 0-based | [
"Pointers",
"are",
"0",
"-",
"based"
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/ReiserFS/block.rb#L65-L71 |
17,658 | ManageIQ/manageiq-smartstate | lib/fs/iso9660/boot_sector.rb | Iso9660.BootSector.dump | def dump
out = "\n"
out += "Type : #{@bs['desc_type']}\n"
out += "Record ID : #{@bs['id']}\n"
out += "Version : #{@bs['version']}\n"
out += "System ID : #{@bs['system_id'].strip}\n"
out += "Volume ID : #{@volName}\n"
out += "Vol space size ... | ruby | def dump
out = "\n"
out += "Type : #{@bs['desc_type']}\n"
out += "Record ID : #{@bs['id']}\n"
out += "Version : #{@bs['version']}\n"
out += "System ID : #{@bs['system_id'].strip}\n"
out += "Volume ID : #{@volName}\n"
out += "Vol space size ... | [
"def",
"dump",
"out",
"=",
"\"\\n\"",
"out",
"+=",
"\"Type : #{@bs['desc_type']}\\n\"",
"out",
"+=",
"\"Record ID : #{@bs['id']}\\n\"",
"out",
"+=",
"\"Version : #{@bs['version']}\\n\"",
"out",
"+=",
"\"System ID : #{@bs['system_id'].strip}\\n\"",
"ou... | This is a raw dump with no character set conversion. | [
"This",
"is",
"a",
"raw",
"dump",
"with",
"no",
"character",
"set",
"conversion",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/iso9660/boot_sector.rb#L140-L169 |
17,659 | ManageIQ/manageiq-smartstate | lib/fs/xfs/inode.rb | XFS.Inode.bmap_btree_record_to_block_pointers | def bmap_btree_record_to_block_pointers(record, block_pointers_length)
block_pointers = []
# Fill in the missing blocks with 0-blocks
block_pointers << 0 while (block_pointers_length + block_pointers.length) < record.start_offset
1.upto(record.block_count) { |i| block_pointers << record.start_bl... | ruby | def bmap_btree_record_to_block_pointers(record, block_pointers_length)
block_pointers = []
# Fill in the missing blocks with 0-blocks
block_pointers << 0 while (block_pointers_length + block_pointers.length) < record.start_offset
1.upto(record.block_count) { |i| block_pointers << record.start_bl... | [
"def",
"bmap_btree_record_to_block_pointers",
"(",
"record",
",",
"block_pointers_length",
")",
"block_pointers",
"=",
"[",
"]",
"# Fill in the missing blocks with 0-blocks",
"block_pointers",
"<<",
"0",
"while",
"(",
"block_pointers_length",
"+",
"block_pointers",
".",
"le... | This method is used for both extents and BTree leaf nodes | [
"This",
"method",
"is",
"used",
"for",
"both",
"extents",
"and",
"BTree",
"leaf",
"nodes"
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/fs/xfs/inode.rb#L428-L435 |
17,660 | ManageIQ/manageiq-smartstate | lib/metadata/linux/LinuxPackages.rb | MiqLinux.Packages.procRPM | def procRPM(dbDir)
$log.debug "Processing RPM package database"
rpmp = MiqRpmPackages.new(@fs, File.join(dbDir, "Packages"))
rpmp.each { |p| @packages << p }
rpmp.close
end | ruby | def procRPM(dbDir)
$log.debug "Processing RPM package database"
rpmp = MiqRpmPackages.new(@fs, File.join(dbDir, "Packages"))
rpmp.each { |p| @packages << p }
rpmp.close
end | [
"def",
"procRPM",
"(",
"dbDir",
")",
"$log",
".",
"debug",
"\"Processing RPM package database\"",
"rpmp",
"=",
"MiqRpmPackages",
".",
"new",
"(",
"@fs",
",",
"File",
".",
"join",
"(",
"dbDir",
",",
"\"Packages\"",
")",
")",
"rpmp",
".",
"each",
"{",
"|",
... | Client-side RPM DB processing. | [
"Client",
"-",
"side",
"RPM",
"DB",
"processing",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/metadata/linux/LinuxPackages.rb#L155-L160 |
17,661 | ManageIQ/manageiq-smartstate | lib/metadata/linux/LinuxPackages.rb | MiqLinux.Packages.procConary | def procConary(dbFile)
$log.debug "Processing Conary package database"
rpmp = MiqConaryPackages.new(@fs, dbFile)
rpmp.each { |p| @packages << p }
rpmp.close
end | ruby | def procConary(dbFile)
$log.debug "Processing Conary package database"
rpmp = MiqConaryPackages.new(@fs, dbFile)
rpmp.each { |p| @packages << p }
rpmp.close
end | [
"def",
"procConary",
"(",
"dbFile",
")",
"$log",
".",
"debug",
"\"Processing Conary package database\"",
"rpmp",
"=",
"MiqConaryPackages",
".",
"new",
"(",
"@fs",
",",
"dbFile",
")",
"rpmp",
".",
"each",
"{",
"|",
"p",
"|",
"@packages",
"<<",
"p",
"}",
"rp... | Conary DB processing | [
"Conary",
"DB",
"processing"
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/metadata/linux/LinuxPackages.rb#L165-L170 |
17,662 | ManageIQ/manageiq-smartstate | lib/metadata/util/win32/Win32System.rb | MiqWin32.System.os_product_suite | def os_product_suite(hash)
eid = hash.delete(:edition_id)
ps = hash.delete(:product_suite)
# If edition_id is populated then the edition will already be part of the product_name string
if eid.nil? && !hash[:product_name].nil?
ps = ps.to_s.split("\n")
if ps.length > 1 && !hash[:p... | ruby | def os_product_suite(hash)
eid = hash.delete(:edition_id)
ps = hash.delete(:product_suite)
# If edition_id is populated then the edition will already be part of the product_name string
if eid.nil? && !hash[:product_name].nil?
ps = ps.to_s.split("\n")
if ps.length > 1 && !hash[:p... | [
"def",
"os_product_suite",
"(",
"hash",
")",
"eid",
"=",
"hash",
".",
"delete",
"(",
":edition_id",
")",
"ps",
"=",
"hash",
".",
"delete",
"(",
":product_suite",
")",
"# If edition_id is populated then the edition will already be part of the product_name string",
"if",
... | Parse product edition and append to product_name if needed. | [
"Parse",
"product",
"edition",
"and",
"append",
"to",
"product_name",
"if",
"needed",
"."
] | 88fed6e9e6c0b69e87d71d1912c77aca535f7caa | https://github.com/ManageIQ/manageiq-smartstate/blob/88fed6e9e6c0b69e87d71d1912c77aca535f7caa/lib/metadata/util/win32/Win32System.rb#L237-L248 |
17,663 | leikind/wice_grid | lib/wice/grid_output_buffer.rb | Wice.GridOutputBuffer.add_filter | def add_filter(detach_with_id, filter_code)
raise WiceGridException.new("Detached ID #{detach_with_id} is already used!") if @filters.key? detach_with_id
@filters[detach_with_id] = filter_code
end | ruby | def add_filter(detach_with_id, filter_code)
raise WiceGridException.new("Detached ID #{detach_with_id} is already used!") if @filters.key? detach_with_id
@filters[detach_with_id] = filter_code
end | [
"def",
"add_filter",
"(",
"detach_with_id",
",",
"filter_code",
")",
"raise",
"WiceGridException",
".",
"new",
"(",
"\"Detached ID #{detach_with_id} is already used!\"",
")",
"if",
"@filters",
".",
"key?",
"detach_with_id",
"@filters",
"[",
"detach_with_id",
"]",
"=",
... | stores HTML code for a detached filter | [
"stores",
"HTML",
"code",
"for",
"a",
"detached",
"filter"
] | a8080a7ddeda45c7719132fc634ad3313f77e730 | https://github.com/leikind/wice_grid/blob/a8080a7ddeda45c7719132fc634ad3313f77e730/lib/wice/grid_output_buffer.rb#L21-L24 |
17,664 | leikind/wice_grid | lib/wice/grid_output_buffer.rb | Wice.GridOutputBuffer.filter_for | def filter_for(detach_with_id)
unless @filters.key? detach_with_id
if @return_empty_strings_for_nonexistent_filters
return ''
else
raise WiceGridException.new("No filter with Detached ID '#{detach_with_id}'!")
end
end
unless @filters[detach_with_id]
... | ruby | def filter_for(detach_with_id)
unless @filters.key? detach_with_id
if @return_empty_strings_for_nonexistent_filters
return ''
else
raise WiceGridException.new("No filter with Detached ID '#{detach_with_id}'!")
end
end
unless @filters[detach_with_id]
... | [
"def",
"filter_for",
"(",
"detach_with_id",
")",
"unless",
"@filters",
".",
"key?",
"detach_with_id",
"if",
"@return_empty_strings_for_nonexistent_filters",
"return",
"''",
"else",
"raise",
"WiceGridException",
".",
"new",
"(",
"\"No filter with Detached ID '#{detach_with_id}... | returns HTML code for a detached filter | [
"returns",
"HTML",
"code",
"for",
"a",
"detached",
"filter"
] | a8080a7ddeda45c7719132fc634ad3313f77e730 | https://github.com/leikind/wice_grid/blob/a8080a7ddeda45c7719132fc634ad3313f77e730/lib/wice/grid_output_buffer.rb#L27-L43 |
17,665 | leikind/wice_grid | lib/wice/wice_grid_controller.rb | Wice.Controller.export_grid_if_requested | def export_grid_if_requested(opts = {})
grid = self.wice_grid_instances.detect(&:output_csv?)
if grid
template_name = opts[grid.name] || opts[grid.name.intern]
template_name ||= grid.name + '_grid'
temp_filename = render_to_string(partial: template_name)
temp_filename = temp... | ruby | def export_grid_if_requested(opts = {})
grid = self.wice_grid_instances.detect(&:output_csv?)
if grid
template_name = opts[grid.name] || opts[grid.name.intern]
template_name ||= grid.name + '_grid'
temp_filename = render_to_string(partial: template_name)
temp_filename = temp... | [
"def",
"export_grid_if_requested",
"(",
"opts",
"=",
"{",
"}",
")",
"grid",
"=",
"self",
".",
"wice_grid_instances",
".",
"detect",
"(",
":output_csv?",
")",
"if",
"grid",
"template_name",
"=",
"opts",
"[",
"grid",
".",
"name",
"]",
"||",
"opts",
"[",
"g... | +export_grid_if_requested+ is a controller method which should be called at the end of each action containing grids with enabled
CSV export.
CSV export will only work if each WiceGrid helper is placed in a partial of its own (requiring it from the master template
of course for the usual flow).
+export_grid_if_requ... | [
"+",
"export_grid_if_requested",
"+",
"is",
"a",
"controller",
"method",
"which",
"should",
"be",
"called",
"at",
"the",
"end",
"of",
"each",
"action",
"containing",
"grids",
"with",
"enabled",
"CSV",
"export",
"."
] | a8080a7ddeda45c7719132fc634ad3313f77e730 | https://github.com/leikind/wice_grid/blob/a8080a7ddeda45c7719132fc634ad3313f77e730/lib/wice/wice_grid_controller.rb#L106-L123 |
17,666 | leikind/wice_grid | lib/wice/wice_grid_controller.rb | Wice.Controller.wice_grid_custom_filter_params | def wice_grid_custom_filter_params(opts = {})
options = {
grid_name: 'grid',
attribute: nil,
model: nil,
value: nil
}
options.merge!(opts)
[:attribute, :value].each do |key|
raise ::Wice::WiceGridArgumentError.new("wice_grid_custom_filter_params: ... | ruby | def wice_grid_custom_filter_params(opts = {})
options = {
grid_name: 'grid',
attribute: nil,
model: nil,
value: nil
}
options.merge!(opts)
[:attribute, :value].each do |key|
raise ::Wice::WiceGridArgumentError.new("wice_grid_custom_filter_params: ... | [
"def",
"wice_grid_custom_filter_params",
"(",
"opts",
"=",
"{",
"}",
")",
"options",
"=",
"{",
"grid_name",
":",
"'grid'",
",",
"attribute",
":",
"nil",
",",
"model",
":",
"nil",
",",
"value",
":",
"nil",
"}",
"options",
".",
"merge!",
"(",
"opts",
")"... | +wice_grid_custom_filter_params+ generates HTTP parameters understood by WiceGrid custom filters.
Combined with Rails route helpers it allows to generate links leading to
grids with pre-selected custom filters.
Parameters:
* <tt>:grid_name</tt> - The name of the grid. Just like parameter <tt>:name</tt> of
<tt>i... | [
"+",
"wice_grid_custom_filter_params",
"+",
"generates",
"HTTP",
"parameters",
"understood",
"by",
"WiceGrid",
"custom",
"filters",
".",
"Combined",
"with",
"Rails",
"route",
"helpers",
"it",
"allows",
"to",
"generate",
"links",
"leading",
"to",
"grids",
"with",
"... | a8080a7ddeda45c7719132fc634ad3313f77e730 | https://github.com/leikind/wice_grid/blob/a8080a7ddeda45c7719132fc634ad3313f77e730/lib/wice/wice_grid_controller.rb#L136-L160 |
17,667 | leikind/wice_grid | lib/wice/helpers/wice_grid_misc_view_helpers.rb | Wice.GridViewHelper.dump_filter_parameters_as_hidden_fields | def dump_filter_parameters_as_hidden_fields(grid)
unless grid.is_a? WiceGrid
raise WiceGridArgumentError.new('dump_filter_parameters_as_hidden_fields: the parameter must be a WiceGrid instance.')
end
grid.get_state_as_parameter_value_pairs(true).collect do|param_name, value|
hidden_fi... | ruby | def dump_filter_parameters_as_hidden_fields(grid)
unless grid.is_a? WiceGrid
raise WiceGridArgumentError.new('dump_filter_parameters_as_hidden_fields: the parameter must be a WiceGrid instance.')
end
grid.get_state_as_parameter_value_pairs(true).collect do|param_name, value|
hidden_fi... | [
"def",
"dump_filter_parameters_as_hidden_fields",
"(",
"grid",
")",
"unless",
"grid",
".",
"is_a?",
"WiceGrid",
"raise",
"WiceGridArgumentError",
".",
"new",
"(",
"'dump_filter_parameters_as_hidden_fields: the parameter must be a WiceGrid instance.'",
")",
"end",
"grid",
".",
... | This method dumps all HTTP parameters related to filtering and ordering of a certain grid as hidden form fields.
This might be required if you want to keep the state of a grid while reloading the page using other forms.
The only parameter is a grid object returned by +initialize_grid+ in the controller. | [
"This",
"method",
"dumps",
"all",
"HTTP",
"parameters",
"related",
"to",
"filtering",
"and",
"ordering",
"of",
"a",
"certain",
"grid",
"as",
"hidden",
"form",
"fields",
".",
"This",
"might",
"be",
"required",
"if",
"you",
"want",
"to",
"keep",
"the",
"stat... | a8080a7ddeda45c7719132fc634ad3313f77e730 | https://github.com/leikind/wice_grid/blob/a8080a7ddeda45c7719132fc634ad3313f77e730/lib/wice/helpers/wice_grid_misc_view_helpers.rb#L9-L17 |
17,668 | leikind/wice_grid | lib/wice/helpers/wice_grid_misc_view_helpers.rb | Wice.GridViewHelper.filter_and_order_state_as_hash | def filter_and_order_state_as_hash(grid)
{
grid.name => {
'f' => grid.status[:f],
'order' => grid.status[:order],
'order_direction' => grid.status[:order_direction]
}
}
end | ruby | def filter_and_order_state_as_hash(grid)
{
grid.name => {
'f' => grid.status[:f],
'order' => grid.status[:order],
'order_direction' => grid.status[:order_direction]
}
}
end | [
"def",
"filter_and_order_state_as_hash",
"(",
"grid",
")",
"{",
"grid",
".",
"name",
"=>",
"{",
"'f'",
"=>",
"grid",
".",
"status",
"[",
":f",
"]",
",",
"'order'",
"=>",
"grid",
".",
"status",
"[",
":order",
"]",
",",
"'order_direction'",
"=>",
"grid",
... | This method dumps all HTTP parameters related to filtering and ordering of a certain grid in the form of a hash.
This might be required if you want to keep the state of a grid while reloading the page using Rails routing helpers.
The only parameter is a grid object returned by +initialize_grid+ in the controller. | [
"This",
"method",
"dumps",
"all",
"HTTP",
"parameters",
"related",
"to",
"filtering",
"and",
"ordering",
"of",
"a",
"certain",
"grid",
"in",
"the",
"form",
"of",
"a",
"hash",
".",
"This",
"might",
"be",
"required",
"if",
"you",
"want",
"to",
"keep",
"the... | a8080a7ddeda45c7719132fc634ad3313f77e730 | https://github.com/leikind/wice_grid/blob/a8080a7ddeda45c7719132fc634ad3313f77e730/lib/wice/helpers/wice_grid_misc_view_helpers.rb#L33-L41 |
17,669 | leikind/wice_grid | lib/wice/helpers/wice_grid_misc_view_helpers.rb | Wice.GridViewHelper.scaffolded_grid | def scaffolded_grid(grid_obj, opts = {}) #:nodoc:
unless grid_obj.is_a? WiceGrid
raise WiceGridArgumentError.new('scaffolded_grid: the parameter must be a WiceGrid instance.')
end
# debug grid.klass.column_names
columns = grid_obj.klass.column_names
if opts[:reject_attributes].is_... | ruby | def scaffolded_grid(grid_obj, opts = {}) #:nodoc:
unless grid_obj.is_a? WiceGrid
raise WiceGridArgumentError.new('scaffolded_grid: the parameter must be a WiceGrid instance.')
end
# debug grid.klass.column_names
columns = grid_obj.klass.column_names
if opts[:reject_attributes].is_... | [
"def",
"scaffolded_grid",
"(",
"grid_obj",
",",
"opts",
"=",
"{",
"}",
")",
"#:nodoc:",
"unless",
"grid_obj",
".",
"is_a?",
"WiceGrid",
"raise",
"WiceGridArgumentError",
".",
"new",
"(",
"'scaffolded_grid: the parameter must be a WiceGrid instance.'",
")",
"end",
"# d... | secret but stupid weapon - takes an ActiveRecord and using reflection tries to build all the column clauses by itself.
WiceGrid is not a scaffolding solution, I hate scaffolding and how certain idiots associate scaffolding with Rails,
so I do not document this method to avoid contributing to this misunderstanding. | [
"secret",
"but",
"stupid",
"weapon",
"-",
"takes",
"an",
"ActiveRecord",
"and",
"using",
"reflection",
"tries",
"to",
"build",
"all",
"the",
"column",
"clauses",
"by",
"itself",
".",
"WiceGrid",
"is",
"not",
"a",
"scaffolding",
"solution",
"I",
"hate",
"scaf... | a8080a7ddeda45c7719132fc634ad3313f77e730 | https://github.com/leikind/wice_grid/blob/a8080a7ddeda45c7719132fc634ad3313f77e730/lib/wice/helpers/wice_grid_misc_view_helpers.rb#L51-L72 |
17,670 | leikind/wice_grid | lib/wice/grid_renderer.rb | Wice.GridRenderer.action_column | def action_column(opts = {}, &block)
if @action_column_present
raise Wice::WiceGridException.new('There can be only one action column in a WiceGrid')
end
options = {
param_name: :selected,
html: {},
select_all_buttons: true,
object_prop... | ruby | def action_column(opts = {}, &block)
if @action_column_present
raise Wice::WiceGridException.new('There can be only one action column in a WiceGrid')
end
options = {
param_name: :selected,
html: {},
select_all_buttons: true,
object_prop... | [
"def",
"action_column",
"(",
"opts",
"=",
"{",
"}",
",",
"&",
"block",
")",
"if",
"@action_column_present",
"raise",
"Wice",
"::",
"WiceGridException",
".",
"new",
"(",
"'There can be only one action column in a WiceGrid'",
")",
"end",
"options",
"=",
"{",
"param_... | Adds a column with checkboxes for each record. Useful for actions with multiple records, for example, deleting
selected records. Please note that +action_column+ only creates the checkboxes and the 'Select All' and
'Deselect All' buttons, and the form itelf as well as processing the parameters should be taken care of... | [
"Adds",
"a",
"column",
"with",
"checkboxes",
"for",
"each",
"record",
".",
"Useful",
"for",
"actions",
"with",
"multiple",
"records",
"for",
"example",
"deleting",
"selected",
"records",
".",
"Please",
"note",
"that",
"+",
"action_column",
"+",
"only",
"create... | a8080a7ddeda45c7719132fc634ad3313f77e730 | https://github.com/leikind/wice_grid/blob/a8080a7ddeda45c7719132fc634ad3313f77e730/lib/wice/grid_renderer.rb#L158-L186 |
17,671 | leikind/wice_grid | lib/wice_grid.rb | Wice.WiceGrid.distinct_values_for_column | def distinct_values_for_column(column) #:nodoc:
column.model.select("distinct #{column.name}").order("#{column.name} asc").collect do|ar|
ar[column.name]
end.reject(&:blank?).map { |i| [i, i] }
end | ruby | def distinct_values_for_column(column) #:nodoc:
column.model.select("distinct #{column.name}").order("#{column.name} asc").collect do|ar|
ar[column.name]
end.reject(&:blank?).map { |i| [i, i] }
end | [
"def",
"distinct_values_for_column",
"(",
"column",
")",
"#:nodoc:",
"column",
".",
"model",
".",
"select",
"(",
"\"distinct #{column.name}\"",
")",
".",
"order",
"(",
"\"#{column.name} asc\"",
")",
".",
"collect",
"do",
"|",
"ar",
"|",
"ar",
"[",
"column",
".... | with this variant we get even those values which do not appear in the resultset | [
"with",
"this",
"variant",
"we",
"get",
"even",
"those",
"values",
"which",
"do",
"not",
"appear",
"in",
"the",
"resultset"
] | a8080a7ddeda45c7719132fc634ad3313f77e730 | https://github.com/leikind/wice_grid/blob/a8080a7ddeda45c7719132fc634ad3313f77e730/lib/wice_grid.rb#L466-L470 |
17,672 | leikind/wice_grid | lib/wice/helpers/wice_grid_view_helpers.rb | Wice.GridViewHelper.grid | def grid(grid, opts = {}, &block)
raise WiceGridArgumentError.new('Missing block for the grid helper.' \
' For detached filters use first define_grid with the same API as grid, ' \
'then grid_filter to add filters, and then render_grid to actually show the grid') if block.nil?
define_grid(gr... | ruby | def grid(grid, opts = {}, &block)
raise WiceGridArgumentError.new('Missing block for the grid helper.' \
' For detached filters use first define_grid with the same API as grid, ' \
'then grid_filter to add filters, and then render_grid to actually show the grid') if block.nil?
define_grid(gr... | [
"def",
"grid",
"(",
"grid",
",",
"opts",
"=",
"{",
"}",
",",
"&",
"block",
")",
"raise",
"WiceGridArgumentError",
".",
"new",
"(",
"'Missing block for the grid helper.'",
"' For detached filters use first define_grid with the same API as grid, '",
"'then grid_filter to add fi... | View helper for rendering the grid.
The first parameter is a grid object returned by +initialize_grid+ in the controller.
The second parameter is a hash of options:
* <tt>:html</tt> - a hash of HTML attributes to be included into the <tt>table</tt> tag.
* <tt>:class</tt> - a shortcut for <tt>html: {class: 'css_cl... | [
"View",
"helper",
"for",
"rendering",
"the",
"grid",
"."
] | a8080a7ddeda45c7719132fc634ad3313f77e730 | https://github.com/leikind/wice_grid/blob/a8080a7ddeda45c7719132fc634ad3313f77e730/lib/wice/helpers/wice_grid_view_helpers.rb#L70-L76 |
17,673 | Sology/smart_listing | app/helpers/smart_listing/helper.rb | SmartListing.Helper.smart_listing_for | def smart_listing_for name, *args, &block
raise ArgumentError, "Missing block" unless block_given?
name = name.to_sym
options = args.extract_options!
bare = options.delete(:bare)
builder = Builder.new(name, @smart_listings[name], self, options, block)
output = ""
data = {}
... | ruby | def smart_listing_for name, *args, &block
raise ArgumentError, "Missing block" unless block_given?
name = name.to_sym
options = args.extract_options!
bare = options.delete(:bare)
builder = Builder.new(name, @smart_listings[name], self, options, block)
output = ""
data = {}
... | [
"def",
"smart_listing_for",
"name",
",",
"*",
"args",
",",
"&",
"block",
"raise",
"ArgumentError",
",",
"\"Missing block\"",
"unless",
"block_given?",
"name",
"=",
"name",
".",
"to_sym",
"options",
"=",
"args",
".",
"extract_options!",
"bare",
"=",
"options",
... | Outputs smart list container | [
"Outputs",
"smart",
"list",
"container"
] | 064ba282d0bb6cab9dd03b7fc57c341755903358 | https://github.com/Sology/smart_listing/blob/064ba282d0bb6cab9dd03b7fc57c341755903358/app/helpers/smart_listing/helper.rb#L196-L225 |
17,674 | gocardless/coach | lib/coach/handler.rb | Coach.Handler.build_request_chain | def build_request_chain(sequence, context)
sequence.reverse.reduce(nil) do |successor, item|
item.build_middleware(context, successor)
end
end | ruby | def build_request_chain(sequence, context)
sequence.reverse.reduce(nil) do |successor, item|
item.build_middleware(context, successor)
end
end | [
"def",
"build_request_chain",
"(",
"sequence",
",",
"context",
")",
"sequence",
".",
"reverse",
".",
"reduce",
"(",
"nil",
")",
"do",
"|",
"successor",
",",
"item",
"|",
"item",
".",
"build_middleware",
"(",
"context",
",",
"successor",
")",
"end",
"end"
] | Given a middleware sequence, filter out items not applicable to the
current request, and set up a chain of instantiated middleware objects,
ready to serve a request. | [
"Given",
"a",
"middleware",
"sequence",
"filter",
"out",
"items",
"not",
"applicable",
"to",
"the",
"current",
"request",
"and",
"set",
"up",
"a",
"chain",
"of",
"instantiated",
"middleware",
"objects",
"ready",
"to",
"serve",
"a",
"request",
"."
] | a643771b63953bd9948d783505ae3ca5ac6a7f36 | https://github.com/gocardless/coach/blob/a643771b63953bd9948d783505ae3ca5ac6a7f36/lib/coach/handler.rb#L65-L69 |
17,675 | gocardless/coach | lib/coach/handler.rb | Coach.Handler.dedup_sequence | def dedup_sequence(sequence)
sequence.uniq { |item| [item.class, item.middleware, item.config] }
end | ruby | def dedup_sequence(sequence)
sequence.uniq { |item| [item.class, item.middleware, item.config] }
end | [
"def",
"dedup_sequence",
"(",
"sequence",
")",
"sequence",
".",
"uniq",
"{",
"|",
"item",
"|",
"[",
"item",
".",
"class",
",",
"item",
".",
"middleware",
",",
"item",
".",
"config",
"]",
"}",
"end"
] | Remove middleware that have been included multiple times with the same
config, leaving only the first instance | [
"Remove",
"middleware",
"that",
"have",
"been",
"included",
"multiple",
"times",
"with",
"the",
"same",
"config",
"leaving",
"only",
"the",
"first",
"instance"
] | a643771b63953bd9948d783505ae3ca5ac6a7f36 | https://github.com/gocardless/coach/blob/a643771b63953bd9948d783505ae3ca5ac6a7f36/lib/coach/handler.rb#L79-L81 |
17,676 | gocardless/coach | lib/coach/router.rb | Coach.Router.action_traits | def action_traits(list_of_actions)
*list_of_actions, traits = list_of_actions if list_of_actions.last.is_a?(Hash)
list_of_actions.reduce(traits || {}) do |memo, action|
trait = ACTION_TRAITS.fetch(action) do
raise Errors::RouterUnknownDefaultAction, action
end
memo.merge(... | ruby | def action_traits(list_of_actions)
*list_of_actions, traits = list_of_actions if list_of_actions.last.is_a?(Hash)
list_of_actions.reduce(traits || {}) do |memo, action|
trait = ACTION_TRAITS.fetch(action) do
raise Errors::RouterUnknownDefaultAction, action
end
memo.merge(... | [
"def",
"action_traits",
"(",
"list_of_actions",
")",
"*",
"list_of_actions",
",",
"traits",
"=",
"list_of_actions",
"if",
"list_of_actions",
".",
"last",
".",
"is_a?",
"(",
"Hash",
")",
"list_of_actions",
".",
"reduce",
"(",
"traits",
"||",
"{",
"}",
")",
"d... | Receives an array of symbols that represent actions for which the default traits
should be used, and then lastly an optional trait configuration.
Example is...
[ :index, :show, { refund: { url: ':id/refund', method: 'post' } } ]
...which will load the default route for `show` and `index`, while also configurin... | [
"Receives",
"an",
"array",
"of",
"symbols",
"that",
"represent",
"actions",
"for",
"which",
"the",
"default",
"traits",
"should",
"be",
"used",
"and",
"then",
"lastly",
"an",
"optional",
"trait",
"configuration",
"."
] | a643771b63953bd9948d783505ae3ca5ac6a7f36 | https://github.com/gocardless/coach/blob/a643771b63953bd9948d783505ae3ca5ac6a7f36/lib/coach/router.rb#L47-L57 |
17,677 | gocardless/coach | lib/coach/middleware.rb | Coach.Middleware.provide | def provide(args)
args.each do |name, value|
unless self.class.provides?(name)
raise NameError, "#{self.class} does not provide #{name}"
end
@_context[name] = value
end
end | ruby | def provide(args)
args.each do |name, value|
unless self.class.provides?(name)
raise NameError, "#{self.class} does not provide #{name}"
end
@_context[name] = value
end
end | [
"def",
"provide",
"(",
"args",
")",
"args",
".",
"each",
"do",
"|",
"name",
",",
"value",
"|",
"unless",
"self",
".",
"class",
".",
"provides?",
"(",
"name",
")",
"raise",
"NameError",
",",
"\"#{self.class} does not provide #{name}\"",
"end",
"@_context",
"[... | Make values available to middleware further down the stack. Accepts a
hash of name => value pairs. Names must have been declared by calling
`provides` on the class. | [
"Make",
"values",
"available",
"to",
"middleware",
"further",
"down",
"the",
"stack",
".",
"Accepts",
"a",
"hash",
"of",
"name",
"=",
">",
"value",
"pairs",
".",
"Names",
"must",
"have",
"been",
"declared",
"by",
"calling",
"provides",
"on",
"the",
"class"... | a643771b63953bd9948d783505ae3ca5ac6a7f36 | https://github.com/gocardless/coach/blob/a643771b63953bd9948d783505ae3ca5ac6a7f36/lib/coach/middleware.rb#L63-L71 |
17,678 | gocardless/coach | lib/coach/middleware.rb | Coach.Middleware.instrument | def instrument
proc do
publish_start
if ActiveSupport::Notifications.notifier.listening?("coach.middleware.finish")
instrument_deprecated { call }
else
ActiveSupport::Notifications.
instrument("finish_middleware.coach", middleware_event) { call }
en... | ruby | def instrument
proc do
publish_start
if ActiveSupport::Notifications.notifier.listening?("coach.middleware.finish")
instrument_deprecated { call }
else
ActiveSupport::Notifications.
instrument("finish_middleware.coach", middleware_event) { call }
en... | [
"def",
"instrument",
"proc",
"do",
"publish_start",
"if",
"ActiveSupport",
"::",
"Notifications",
".",
"notifier",
".",
"listening?",
"(",
"\"coach.middleware.finish\"",
")",
"instrument_deprecated",
"{",
"call",
"}",
"else",
"ActiveSupport",
"::",
"Notifications",
".... | Use ActiveSupport to instrument the execution of the subsequent chain. | [
"Use",
"ActiveSupport",
"to",
"instrument",
"the",
"execution",
"of",
"the",
"subsequent",
"chain",
"."
] | a643771b63953bd9948d783505ae3ca5ac6a7f36 | https://github.com/gocardless/coach/blob/a643771b63953bd9948d783505ae3ca5ac6a7f36/lib/coach/middleware.rb#L74-L85 |
17,679 | gocardless/coach | lib/coach/middleware_validator.rb | Coach.MiddlewareValidator.validated_provides! | def validated_provides!
if missing_requirements.any?
raise Coach::Errors::MiddlewareDependencyNotMet.new(
@middleware, @previous_middlewares, missing_requirements
)
end
@middleware.provided + provided_by_chain
end | ruby | def validated_provides!
if missing_requirements.any?
raise Coach::Errors::MiddlewareDependencyNotMet.new(
@middleware, @previous_middlewares, missing_requirements
)
end
@middleware.provided + provided_by_chain
end | [
"def",
"validated_provides!",
"if",
"missing_requirements",
".",
"any?",
"raise",
"Coach",
"::",
"Errors",
"::",
"MiddlewareDependencyNotMet",
".",
"new",
"(",
"@middleware",
",",
"@previous_middlewares",
",",
"missing_requirements",
")",
"end",
"@middleware",
".",
"p... | Aggregates provided keys from the given middleware, and all the middleware it uses.
Can raise at any level assuming a used middleware is missing a required dependency. | [
"Aggregates",
"provided",
"keys",
"from",
"the",
"given",
"middleware",
"and",
"all",
"the",
"middleware",
"it",
"uses",
".",
"Can",
"raise",
"at",
"any",
"level",
"assuming",
"a",
"used",
"middleware",
"is",
"missing",
"a",
"required",
"dependency",
"."
] | a643771b63953bd9948d783505ae3ca5ac6a7f36 | https://github.com/gocardless/coach/blob/a643771b63953bd9948d783505ae3ca5ac6a7f36/lib/coach/middleware_validator.rb#L13-L21 |
17,680 | gocardless/coach | lib/coach/request_benchmark.rb | Coach.RequestBenchmark.stats | def stats
{
endpoint_name: @endpoint_name,
started_at: @start,
duration: format_ms(@duration),
chain: sorted_chain.map do |event|
{ name: event[:name], duration: format_ms(event[:duration]) }
end,
}
end | ruby | def stats
{
endpoint_name: @endpoint_name,
started_at: @start,
duration: format_ms(@duration),
chain: sorted_chain.map do |event|
{ name: event[:name], duration: format_ms(event[:duration]) }
end,
}
end | [
"def",
"stats",
"{",
"endpoint_name",
":",
"@endpoint_name",
",",
"started_at",
":",
"@start",
",",
"duration",
":",
"format_ms",
"(",
"@duration",
")",
",",
"chain",
":",
"sorted_chain",
".",
"map",
"do",
"|",
"event",
"|",
"{",
"name",
":",
"event",
"[... | Serialize the results of the benchmarking | [
"Serialize",
"the",
"results",
"of",
"the",
"benchmarking"
] | a643771b63953bd9948d783505ae3ca5ac6a7f36 | https://github.com/gocardless/coach/blob/a643771b63953bd9948d783505ae3ca5ac6a7f36/lib/coach/request_benchmark.rb#L30-L39 |
17,681 | gocardless/coach | lib/coach/notifications.rb | Coach.Notifications.broadcast | def broadcast(event, benchmark)
serialized = RequestSerializer.new(event[:request]).serialize.
merge(benchmark.stats).
merge(event.slice(:response, :metadata))
if ActiveSupport::Notifications.notifier.listening?("coach.request")
ActiveSupport::Deprecation.warn("The 'coach.request' ev... | ruby | def broadcast(event, benchmark)
serialized = RequestSerializer.new(event[:request]).serialize.
merge(benchmark.stats).
merge(event.slice(:response, :metadata))
if ActiveSupport::Notifications.notifier.listening?("coach.request")
ActiveSupport::Deprecation.warn("The 'coach.request' ev... | [
"def",
"broadcast",
"(",
"event",
",",
"benchmark",
")",
"serialized",
"=",
"RequestSerializer",
".",
"new",
"(",
"event",
"[",
":request",
"]",
")",
".",
"serialize",
".",
"merge",
"(",
"benchmark",
".",
"stats",
")",
".",
"merge",
"(",
"event",
".",
... | Receives a handler.finish event, with processed benchmark. Publishes to
request.coach notification. | [
"Receives",
"a",
"handler",
".",
"finish",
"event",
"with",
"processed",
"benchmark",
".",
"Publishes",
"to",
"request",
".",
"coach",
"notification",
"."
] | a643771b63953bd9948d783505ae3ca5ac6a7f36 | https://github.com/gocardless/coach/blob/a643771b63953bd9948d783505ae3ca5ac6a7f36/lib/coach/notifications.rb#L88-L98 |
17,682 | twitterdev/twitter-ruby-ads-sdk | lib/twitter-ads/campaign/line_item.rb | TwitterAds.LineItem.targeting_criteria | def targeting_criteria(id = nil, opts = {})
id ? TargetingCriteria.load(account, id, opts) : TargetingCriteria.all(account, @id, opts)
end | ruby | def targeting_criteria(id = nil, opts = {})
id ? TargetingCriteria.load(account, id, opts) : TargetingCriteria.all(account, @id, opts)
end | [
"def",
"targeting_criteria",
"(",
"id",
"=",
"nil",
",",
"opts",
"=",
"{",
"}",
")",
"id",
"?",
"TargetingCriteria",
".",
"load",
"(",
"account",
",",
"id",
",",
"opts",
")",
":",
"TargetingCriteria",
".",
"all",
"(",
"account",
",",
"@id",
",",
"opt... | Returns a collection of targeting criteria available to the current line item.
@param id [String] The TargetingCriteria ID value.
@param opts [Hash] A Hash of extended options.
@option opts [Boolean] :with_deleted Indicates if deleted items should be included.
@option opts [String] :sort_by The object param to sor... | [
"Returns",
"a",
"collection",
"of",
"targeting",
"criteria",
"available",
"to",
"the",
"current",
"line",
"item",
"."
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/lib/twitter-ads/campaign/line_item.rb#L97-L99 |
17,683 | twitterdev/twitter-ruby-ads-sdk | lib/twitter-ads/cursor.rb | TwitterAds.Cursor.each | def each(offset = 0)
return to_enum(:each, offset) unless block_given?
@collection[offset..-1].each { |element| yield(element) }
unless exhausted?
offset = [@collection.size, offset].max
fetch_next
each(offset, &Proc.new)
end
self
end | ruby | def each(offset = 0)
return to_enum(:each, offset) unless block_given?
@collection[offset..-1].each { |element| yield(element) }
unless exhausted?
offset = [@collection.size, offset].max
fetch_next
each(offset, &Proc.new)
end
self
end | [
"def",
"each",
"(",
"offset",
"=",
"0",
")",
"return",
"to_enum",
"(",
":each",
",",
"offset",
")",
"unless",
"block_given?",
"@collection",
"[",
"offset",
"..",
"-",
"1",
"]",
".",
"each",
"{",
"|",
"element",
"|",
"yield",
"(",
"element",
")",
"}",... | Method to iterate through all items until the Cursor is exhausted.
@return [Cursor] The current Cursor instance.
@since 0.1.0 | [
"Method",
"to",
"iterate",
"through",
"all",
"items",
"until",
"the",
"Cursor",
"is",
"exhausted",
"."
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/lib/twitter-ads/cursor.rb#L59-L68 |
17,684 | twitterdev/twitter-ruby-ads-sdk | examples/metric_filtering.rb | TwitterAds.Metrics.filter | def filter(*line_items)
result = {}
params = { line_item_ids: line_items.join(','), with_deleted: true }
@account.line_items(nil, params).each do |line_item|
# filter by objective
objective = line_item.objective.downcase.to_sym
metrics = OBJECTIVES[objective].map { |family| M... | ruby | def filter(*line_items)
result = {}
params = { line_item_ids: line_items.join(','), with_deleted: true }
@account.line_items(nil, params).each do |line_item|
# filter by objective
objective = line_item.objective.downcase.to_sym
metrics = OBJECTIVES[objective].map { |family| M... | [
"def",
"filter",
"(",
"*",
"line_items",
")",
"result",
"=",
"{",
"}",
"params",
"=",
"{",
"line_item_ids",
":",
"line_items",
".",
"join",
"(",
"','",
")",
",",
"with_deleted",
":",
"true",
"}",
"@account",
".",
"line_items",
"(",
"nil",
",",
"params"... | Sets up the object with the correct account and client information.
@example
metric_filter = TwitterAds::Metric.new('xyz1')
@param account_id [String] The ID for the account to be used.
@param client [Client] Optional client instance to be used. Will default to ~/.twurlrc info.
@param mact_enabled [Boolean] In... | [
"Sets",
"up",
"the",
"object",
"with",
"the",
"correct",
"account",
"and",
"client",
"information",
"."
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/examples/metric_filtering.rb#L264-L286 |
17,685 | twitterdev/twitter-ruby-ads-sdk | lib/twitter-ads/account.rb | TwitterAds.Account.features | def features
validate_loaded
resource = FEATURES % { id: @id }
response = Request.new(client, :get, resource).perform
response.body[:data]
end | ruby | def features
validate_loaded
resource = FEATURES % { id: @id }
response = Request.new(client, :get, resource).perform
response.body[:data]
end | [
"def",
"features",
"validate_loaded",
"resource",
"=",
"FEATURES",
"%",
"{",
"id",
":",
"@id",
"}",
"response",
"=",
"Request",
".",
"new",
"(",
"client",
",",
":get",
",",
"resource",
")",
".",
"perform",
"response",
".",
"body",
"[",
":data",
"]",
"e... | Returns a collection of features available to the current account.
@return [Array] The list of features enabled for the account.
@since 0.1.0 | [
"Returns",
"a",
"collection",
"of",
"features",
"available",
"to",
"the",
"current",
"account",
"."
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/lib/twitter-ads/account.rb#L90-L95 |
17,686 | twitterdev/twitter-ruby-ads-sdk | lib/twitter-ads/account.rb | TwitterAds.Account.scoped_timeline | def scoped_timeline(ids, opts = {})
ids = ids.join(',') if ids.is_a?(Array)
params = { user_ids: ids }.merge!(opts)
resource = SCOPED_TIMELINE % { id: @id }
request = Request.new(client, :get, resource, params: params)
response = request.perform
response.body[:data]
end | ruby | def scoped_timeline(ids, opts = {})
ids = ids.join(',') if ids.is_a?(Array)
params = { user_ids: ids }.merge!(opts)
resource = SCOPED_TIMELINE % { id: @id }
request = Request.new(client, :get, resource, params: params)
response = request.perform
response.body[:data]
end | [
"def",
"scoped_timeline",
"(",
"ids",
",",
"opts",
"=",
"{",
"}",
")",
"ids",
"=",
"ids",
".",
"join",
"(",
"','",
")",
"if",
"ids",
".",
"is_a?",
"(",
"Array",
")",
"params",
"=",
"{",
"user_ids",
":",
"ids",
"}",
".",
"merge!",
"(",
"opts",
"... | Returns the most recent promotable Tweets created by one or more specified Twitter users.
@param ids [Array] An Array of Twitter user IDs.
@param opts [Hash] A Hash of extended options.
@return [Array] An Array of Tweet objects.
@since 0.2.3 | [
"Returns",
"the",
"most",
"recent",
"promotable",
"Tweets",
"created",
"by",
"one",
"or",
"more",
"specified",
"Twitter",
"users",
"."
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/lib/twitter-ads/account.rb#L259-L266 |
17,687 | twitterdev/twitter-ruby-ads-sdk | lib/twitter-ads/resources/persistence.rb | TwitterAds.Persistence.save | def save
if @id
resource = self.class::RESOURCE % { account_id: account.id, id: id }
response = Request.new(account.client, :put, resource, params: to_params).perform
else
resource = self.class::RESOURCE_COLLECTION % { account_id: account.id }
response = Request.new(account.c... | ruby | def save
if @id
resource = self.class::RESOURCE % { account_id: account.id, id: id }
response = Request.new(account.client, :put, resource, params: to_params).perform
else
resource = self.class::RESOURCE_COLLECTION % { account_id: account.id }
response = Request.new(account.c... | [
"def",
"save",
"if",
"@id",
"resource",
"=",
"self",
".",
"class",
"::",
"RESOURCE",
"%",
"{",
"account_id",
":",
"account",
".",
"id",
",",
"id",
":",
"id",
"}",
"response",
"=",
"Request",
".",
"new",
"(",
"account",
".",
"client",
",",
":put",
"... | Saves or updates the current object instance depending on the presence of `object.id`.
@example
object.save
@return [self] Returns the instance refreshed from the API.
@since 0.1.0 | [
"Saves",
"or",
"updates",
"the",
"current",
"object",
"instance",
"depending",
"on",
"the",
"presence",
"of",
"object",
".",
"id",
"."
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/lib/twitter-ads/resources/persistence.rb#L15-L24 |
17,688 | twitterdev/twitter-ruby-ads-sdk | lib/twitter-ads/resources/persistence.rb | TwitterAds.Persistence.delete! | def delete!
resource = self.class::RESOURCE % { account_id: account.id, id: id }
response = Request.new(account.client, :delete, resource).perform
from_response(response.body[:data])
end | ruby | def delete!
resource = self.class::RESOURCE % { account_id: account.id, id: id }
response = Request.new(account.client, :delete, resource).perform
from_response(response.body[:data])
end | [
"def",
"delete!",
"resource",
"=",
"self",
".",
"class",
"::",
"RESOURCE",
"%",
"{",
"account_id",
":",
"account",
".",
"id",
",",
"id",
":",
"id",
"}",
"response",
"=",
"Request",
".",
"new",
"(",
"account",
".",
"client",
",",
":delete",
",",
"reso... | Deletes the current object instance depending on the presence of `object.id`.
@example
object.delete!
Note: calls to this method are destructive and irreverisble for most API objects.
@return [self] Returns the instance refreshed from the API.
@since 0.1.0 | [
"Deletes",
"the",
"current",
"object",
"instance",
"depending",
"on",
"the",
"presence",
"of",
"object",
".",
"id",
"."
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/lib/twitter-ads/resources/persistence.rb#L36-L40 |
17,689 | twitterdev/twitter-ruby-ads-sdk | lib/twitter-ads/http/ton_upload.rb | TwitterAds.TONUpload.perform | def perform
if @file_size < SINGLE_UPLOAD_MAX
resource = "#{DEFAULT_RESOURCE}#{@bucket}"
response = upload(resource, File.read(@file_path))
response.headers['location'][0]
else
response = init_chunked_upload
bytes_per_chunk_size = response.headers['x-ton-min-chunk-siz... | ruby | def perform
if @file_size < SINGLE_UPLOAD_MAX
resource = "#{DEFAULT_RESOURCE}#{@bucket}"
response = upload(resource, File.read(@file_path))
response.headers['location'][0]
else
response = init_chunked_upload
bytes_per_chunk_size = response.headers['x-ton-min-chunk-siz... | [
"def",
"perform",
"if",
"@file_size",
"<",
"SINGLE_UPLOAD_MAX",
"resource",
"=",
"\"#{DEFAULT_RESOURCE}#{@bucket}\"",
"response",
"=",
"upload",
"(",
"resource",
",",
"File",
".",
"read",
"(",
"@file_path",
")",
")",
"response",
".",
"headers",
"[",
"'location'",
... | Creates a new TONUpload object instance.
@example
request = TONUpload.new(client, '/path/to/file')
@param client [Client] The Client object instance.
@param file_path [String] The path to the file to be uploaded.
@since 0.3.0
@return [TONUpload] The TONUpload request instance.
Executes the current TONUploa... | [
"Creates",
"a",
"new",
"TONUpload",
"object",
"instance",
"."
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/lib/twitter-ads/http/ton_upload.rb#L60-L89 |
17,690 | twitterdev/twitter-ruby-ads-sdk | lib/twitter-ads/http/ton_upload.rb | TwitterAds.TONUpload.upload | def upload(resource, bytes)
headers = {
'x-ton-expires' => DEFAULT_EXPIRE,
'content-length' => @file_size,
'content-type' => content_type
}
TwitterAds::Request.new(
@client, :post, resource, domain: DEFAULT_DOMAIN, headers: headers, body: bytes).perform
end | ruby | def upload(resource, bytes)
headers = {
'x-ton-expires' => DEFAULT_EXPIRE,
'content-length' => @file_size,
'content-type' => content_type
}
TwitterAds::Request.new(
@client, :post, resource, domain: DEFAULT_DOMAIN, headers: headers, body: bytes).perform
end | [
"def",
"upload",
"(",
"resource",
",",
"bytes",
")",
"headers",
"=",
"{",
"'x-ton-expires'",
"=>",
"DEFAULT_EXPIRE",
",",
"'content-length'",
"=>",
"@file_size",
",",
"'content-type'",
"=>",
"content_type",
"}",
"TwitterAds",
"::",
"Request",
".",
"new",
"(",
... | performs a single chunk upload | [
"performs",
"a",
"single",
"chunk",
"upload"
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/lib/twitter-ads/http/ton_upload.rb#L103-L111 |
17,691 | twitterdev/twitter-ruby-ads-sdk | lib/twitter-ads/http/ton_upload.rb | TwitterAds.TONUpload.init_chunked_upload | def init_chunked_upload
headers = {
'x-ton-content-type' => content_type,
'x-ton-content-length' => @file_size,
'x-ton-expires' => DEFAULT_EXPIRE,
'content-length' => 0,
'content-type' => content_type
}
resource = "#{DEFAULT_RESOURCE}#{@bu... | ruby | def init_chunked_upload
headers = {
'x-ton-content-type' => content_type,
'x-ton-content-length' => @file_size,
'x-ton-expires' => DEFAULT_EXPIRE,
'content-length' => 0,
'content-type' => content_type
}
resource = "#{DEFAULT_RESOURCE}#{@bu... | [
"def",
"init_chunked_upload",
"headers",
"=",
"{",
"'x-ton-content-type'",
"=>",
"content_type",
",",
"'x-ton-content-length'",
"=>",
"@file_size",
",",
"'x-ton-expires'",
"=>",
"DEFAULT_EXPIRE",
",",
"'content-length'",
"=>",
"0",
",",
"'content-type'",
"=>",
"content_... | initialization for a multi-chunk upload | [
"initialization",
"for",
"a",
"multi",
"-",
"chunk",
"upload"
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/lib/twitter-ads/http/ton_upload.rb#L114-L125 |
17,692 | twitterdev/twitter-ruby-ads-sdk | lib/twitter-ads/http/ton_upload.rb | TwitterAds.TONUpload.upload_chunk | def upload_chunk(resource, bytes, bytes_start, bytes_read)
headers = {
'content-type' => content_type,
'content-length' => bytes.size,
'content-range' => "bytes #{bytes_start}-#{bytes_read - 1}/#{@file_size}"
}
response = TwitterAds::Request.new(
@client, :put, resou... | ruby | def upload_chunk(resource, bytes, bytes_start, bytes_read)
headers = {
'content-type' => content_type,
'content-length' => bytes.size,
'content-range' => "bytes #{bytes_start}-#{bytes_read - 1}/#{@file_size}"
}
response = TwitterAds::Request.new(
@client, :put, resou... | [
"def",
"upload_chunk",
"(",
"resource",
",",
"bytes",
",",
"bytes_start",
",",
"bytes_read",
")",
"headers",
"=",
"{",
"'content-type'",
"=>",
"content_type",
",",
"'content-length'",
"=>",
"bytes",
".",
"size",
",",
"'content-range'",
"=>",
"\"bytes #{bytes_start... | uploads a single chunk of a multi-chunk upload | [
"uploads",
"a",
"single",
"chunk",
"of",
"a",
"multi",
"-",
"chunk",
"upload"
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/lib/twitter-ads/http/ton_upload.rb#L128-L139 |
17,693 | twitterdev/twitter-ruby-ads-sdk | lib/twitter-ads/audiences/tailored_audience.rb | TwitterAds.TailoredAudience.update | def update(file_path, list_type, operation = 'ADD')
upload = TwitterAds::TONUpload.new(account.client, file_path)
update_audience(self, upload.perform, list_type, operation)
reload!
end | ruby | def update(file_path, list_type, operation = 'ADD')
upload = TwitterAds::TONUpload.new(account.client, file_path)
update_audience(self, upload.perform, list_type, operation)
reload!
end | [
"def",
"update",
"(",
"file_path",
",",
"list_type",
",",
"operation",
"=",
"'ADD'",
")",
"upload",
"=",
"TwitterAds",
"::",
"TONUpload",
".",
"new",
"(",
"account",
".",
"client",
",",
"file_path",
")",
"update_audience",
"(",
"self",
",",
"upload",
".",
... | Updates the current tailored audience instance.
@example
audience = account.tailored_audiences('xyz')
audience.update('/path/to/file', 'EMAIL', 'REPLACE')
@param file_path [String] The path to the file to be uploaded.
@param list_type [String] The tailored audience list type.
@param operation [String] The u... | [
"Updates",
"the",
"current",
"tailored",
"audience",
"instance",
"."
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/lib/twitter-ads/audiences/tailored_audience.rb#L146-L150 |
17,694 | twitterdev/twitter-ruby-ads-sdk | lib/twitter-ads/audiences/tailored_audience.rb | TwitterAds.TailoredAudience.status | def status
return nil unless id
resource = RESOURCE_UPDATE % { account_id: account.id }
request = Request.new(account.client, :get, resource, params: to_params)
Cursor.new(nil, request).to_a.select { |change| change[:tailored_audience_id] == id }
end | ruby | def status
return nil unless id
resource = RESOURCE_UPDATE % { account_id: account.id }
request = Request.new(account.client, :get, resource, params: to_params)
Cursor.new(nil, request).to_a.select { |change| change[:tailored_audience_id] == id }
end | [
"def",
"status",
"return",
"nil",
"unless",
"id",
"resource",
"=",
"RESOURCE_UPDATE",
"%",
"{",
"account_id",
":",
"account",
".",
"id",
"}",
"request",
"=",
"Request",
".",
"new",
"(",
"account",
".",
"client",
",",
":get",
",",
"resource",
",",
"params... | Returns the status of all changes for the current tailored audience instance.
@example
audience.status
@since 0.3.0
@return [Hash] Returns a hash object representing the tailored audience status. | [
"Returns",
"the",
"status",
"of",
"all",
"changes",
"for",
"the",
"current",
"tailored",
"audience",
"instance",
"."
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/lib/twitter-ads/audiences/tailored_audience.rb#L176-L181 |
17,695 | twitterdev/twitter-ruby-ads-sdk | lib/twitter-ads/audiences/tailored_audience.rb | TwitterAds.TailoredAudience.users | def users(params)
resource = RESOURCE_USERS % { account_id: account.id, id: id }
headers = { 'Content-Type' => 'application/json' }
response = TwitterAds::Request.new(account.client,
:post,
resource,
... | ruby | def users(params)
resource = RESOURCE_USERS % { account_id: account.id, id: id }
headers = { 'Content-Type' => 'application/json' }
response = TwitterAds::Request.new(account.client,
:post,
resource,
... | [
"def",
"users",
"(",
"params",
")",
"resource",
"=",
"RESOURCE_USERS",
"%",
"{",
"account_id",
":",
"account",
".",
"id",
",",
"id",
":",
"id",
"}",
"headers",
"=",
"{",
"'Content-Type'",
"=>",
"'application/json'",
"}",
"response",
"=",
"TwitterAds",
"::"... | This is a private API and requires whitelisting from Twitter.
This endpoint will allow partners to add, update and remove users from a given
tailored_audience_id.
The endpoint will also accept multiple user identifier types per user as well.
@example
tailored_audience.users(
account,
[
{
... | [
"This",
"is",
"a",
"private",
"API",
"and",
"requires",
"whitelisting",
"from",
"Twitter",
"."
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/lib/twitter-ads/audiences/tailored_audience.rb#L249-L261 |
17,696 | twitterdev/twitter-ruby-ads-sdk | lib/twitter-ads/client.rb | TwitterAds.Client.accounts | def accounts(id = nil, opts = {})
id ? Account.load(self, id) : Account.all(self, opts)
end | ruby | def accounts(id = nil, opts = {})
id ? Account.load(self, id) : Account.all(self, opts)
end | [
"def",
"accounts",
"(",
"id",
"=",
"nil",
",",
"opts",
"=",
"{",
"}",
")",
"id",
"?",
"Account",
".",
"load",
"(",
"self",
",",
"id",
")",
":",
"Account",
".",
"all",
"(",
"self",
",",
"opts",
")",
"end"
] | Returns a collection of advertiser Accounts available to the current access token.
@example
client.accounts
client.accounts('3ofs6l')
client.accounts('3ofs6l', with_deleted: true)
@param id=nil [String] The account ID string.
@param opts={} [Hash] Hash of optional values.
@option opts [String] :with_del... | [
"Returns",
"a",
"collection",
"of",
"advertiser",
"Accounts",
"available",
"to",
"the",
"current",
"access",
"token",
"."
] | 93f35714890a81d533f45281e792403bb3a07112 | https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/93f35714890a81d533f45281e792403bb3a07112/lib/twitter-ads/client.rb#L81-L83 |
17,697 | activerecord-hackery/meta_search | lib/meta_search/method.rb | MetaSearch.Method.evaluate | def evaluate(relation, param)
if splat_param?
relation.send(name, *format_param(param))
else
relation.send(name, format_param(param))
end
end | ruby | def evaluate(relation, param)
if splat_param?
relation.send(name, *format_param(param))
else
relation.send(name, format_param(param))
end
end | [
"def",
"evaluate",
"(",
"relation",
",",
"param",
")",
"if",
"splat_param?",
"relation",
".",
"send",
"(",
"name",
",",
"format_param",
"(",
"param",
")",
")",
"else",
"relation",
".",
"send",
"(",
"name",
",",
"format_param",
"(",
"param",
")",
")",
"... | Evaluate the method in the context of the supplied relation and parameter | [
"Evaluate",
"the",
"method",
"in",
"the",
"context",
"of",
"the",
"supplied",
"relation",
"and",
"parameter"
] | c7f084412c483456830b8ec26514991e17da94c7 | https://github.com/activerecord-hackery/meta_search/blob/c7f084412c483456830b8ec26514991e17da94c7/lib/meta_search/method.rb#L107-L113 |
17,698 | brynary/webrat | lib/webrat/core/scope.rb | Webrat.Scope.fill_in | def fill_in(field_locator, options = {})
field = locate_field(field_locator, TextField, TextareaField, PasswordField)
field.raise_error_if_disabled
field.set(options[:with])
end | ruby | def fill_in(field_locator, options = {})
field = locate_field(field_locator, TextField, TextareaField, PasswordField)
field.raise_error_if_disabled
field.set(options[:with])
end | [
"def",
"fill_in",
"(",
"field_locator",
",",
"options",
"=",
"{",
"}",
")",
"field",
"=",
"locate_field",
"(",
"field_locator",
",",
"TextField",
",",
"TextareaField",
",",
"PasswordField",
")",
"field",
".",
"raise_error_if_disabled",
"field",
".",
"set",
"("... | Verifies an input field or textarea exists on the current page, and stores a value for
it which will be sent when the form is submitted.
Examples:
fill_in "Email", :with => "user@example.com"
fill_in "user[email]", :with => "user@example.com"
The field value is required, and must be specified in <tt>options[... | [
"Verifies",
"an",
"input",
"field",
"or",
"textarea",
"exists",
"on",
"the",
"current",
"page",
"and",
"stores",
"a",
"value",
"for",
"it",
"which",
"will",
"be",
"sent",
"when",
"the",
"form",
"is",
"submitted",
"."
] | 1263639e24ce0f5e2eeeae614f10f900f498d92a | https://github.com/brynary/webrat/blob/1263639e24ce0f5e2eeeae614f10f900f498d92a/lib/webrat/core/scope.rb#L50-L54 |
17,699 | brynary/webrat | lib/webrat/core/matchers/have_content.rb | Webrat.Matchers.assert_contain | def assert_contain(content)
hc = HasContent.new(content)
assert hc.matches?(current_dom), hc.failure_message
end | ruby | def assert_contain(content)
hc = HasContent.new(content)
assert hc.matches?(current_dom), hc.failure_message
end | [
"def",
"assert_contain",
"(",
"content",
")",
"hc",
"=",
"HasContent",
".",
"new",
"(",
"content",
")",
"assert",
"hc",
".",
"matches?",
"(",
"current_dom",
")",
",",
"hc",
".",
"failure_message",
"end"
] | Asserts that the body of the response contain
the supplied string or regexp | [
"Asserts",
"that",
"the",
"body",
"of",
"the",
"response",
"contain",
"the",
"supplied",
"string",
"or",
"regexp"
] | 1263639e24ce0f5e2eeeae614f10f900f498d92a | https://github.com/brynary/webrat/blob/1263639e24ce0f5e2eeeae614f10f900f498d92a/lib/webrat/core/matchers/have_content.rb#L55-L58 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.