_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 66 10.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q2900 | Faalis.User.join_guests | train | def join_guests
#::Faalis::Group.find_by(role: 'guest')
if groups.empty?
guest_group = ::Faalis::Group.find_or_create_by(name: 'Guest',
role: 'guest')
self.groups << guest_group
end
end | ruby | {
"resource": ""
} |
q2901 | Faalis::Dashboard::DSL.Base.attributes | train | def attributes(*fields_name, **options, &block)
if options.include? :except
@fields = resolve_model_reflections.reject do |field|
options[:except].include? field.to_sym
end
elsif options.include? :append
@fields += options[:append]
else
# Check for valid fie... | ruby | {
"resource": ""
} |
q2902 | Faalis::Dashboard::DSL.Base.resolve_model_reflections | train | def resolve_model_reflections
# TODO: cach the result using and instance_var or something
reflections = model.reflections
columns = Set.new model.column_names
new_fields = Set.new
fields_to_remove = Set.new
reflections.each do |name, column|
has_many = ActiveRecord::Ref... | ruby | {
"resource": ""
} |
q2903 | Ajax.Application.rails? | train | def rails?(*args)
version, comparator = args.pop, (args.pop || :==)
result =
if version.nil?
defined?(::Rails)
elsif defined?(::Rails)
if ::Rails.respond_to?(:version)
rails_version = Rails.version.to_f
rails_version = rails_version.floor if versio... | ruby | {
"resource": ""
} |
q2904 | Ajax.Application.init | train | def init
return unless rails?
if rails?(:>=, 3)
require 'ajax/railtie'
else
require 'ajax/action_controller'
require 'ajax/action_view'
Ajax.logger = ::Rails.logger
# Customize rendering. Include custom headers and don't render the layout for AJAX.
::... | ruby | {
"resource": ""
} |
q2905 | Opulent.Compiler.evaluate | train | def evaluate(node, indent)
# Check if this is a substructure of a control block and remove the last
# end evaluation if it is
if node[@value] =~ Settings::END_REMOVAL
@template.pop if @template[-1] == [:eval, 'end']
end
# Check for explicit end node
if node[@value] =~ Settin... | ruby | {
"resource": ""
} |
q2906 | Faalis.RouteHelpers.localized_scope | train | def localized_scope
langs = ::I18n.available_locales.join('|')
scope '(:locale)', locale: Regexp.new(langs) do
yield
end
end | ruby | {
"resource": ""
} |
q2907 | Faalis.RouteHelpers.api_routes | train | def api_routes(version: :v1)
# TODO: Add a dynamic solution for formats
namespace :api, defaults: { format: :json } do
namespace version do
# Call user given block to define user routes
# inside this namespace
yield if block_given?
end
end
scope 'mo... | ruby | {
"resource": ""
} |
q2908 | Configurations.Configuration.to_h | train | def to_h
@data.reduce({}) do |h, (k, v)|
h[k] = v.is_a?(__class__) ? v.to_h : v
h
end
end | ruby | {
"resource": ""
} |
q2909 | Configurations.Configuration.from_h | train | def from_h(h)
@key_ambiguity_validator.validate!(h)
h.each do |property, value|
p = property.to_sym
if value.is_a?(::Hash) && __nested?(p)
@data[p].from_h(value)
elsif __configurable?(p)
__assign!(p, value)
end
end
self
end | ruby | {
"resource": ""
} |
q2910 | Opulent.Compiler.if_node | train | def if_node(node, indent)
# Check if we have any condition met, or an else branch
node[@value].each_with_index do |value, index|
# If we have a branch that meets the condition, generate code for the
# children related to that specific branch
case value
when node[@value].first... | ruby | {
"resource": ""
} |
q2911 | Opulent.Compiler.unless_node | train | def unless_node(node, indent)
# Check if we have any condition met, or an else branch
node[@value].each_with_index do |value, index|
# If we have a branch that meets the condition, generate code for the
# children related to that specific branch
case value
when node[@value].f... | ruby | {
"resource": ""
} |
q2912 | Opulent.Compiler.case_node | train | def case_node(node, indent)
# Evaluate the switching condition
buffer_eval "case #{node[@options][:condition]}"
# Check if we have any condition met, or an else branch
node[@value].each_with_index do |value, index|
# If we have a branch that meets the condition, generate code for the
... | ruby | {
"resource": ""
} |
q2913 | Representative.Nokogiri.comment | train | def comment(text)
comment_node = ::Nokogiri::XML::Comment.new(doc, " #{text} ")
current_element.add_child(comment_node)
end | ruby | {
"resource": ""
} |
q2914 | Opulent.Parser.node | train | def node(parent, indent = nil)
return unless (name = lookahead(:node_lookahead) ||
lookahead(:shorthand_lookahead))
# Skip node if it's a reserved keyword
return nil if KEYWORDS.include? name[0].to_sym
# Accept either explicit node_name or implicit :div node_name
... | ruby | {
"resource": ""
} |
q2915 | Opulent.Parser.shorthand_attributes | train | def shorthand_attributes(atts = {})
while (key = accept :shorthand)
key = Settings::SHORTHAND[key.to_sym]
# Check whether the value is escaped or unescaped
escaped = accept(:unescaped_value) ? false : true
# Get the attribute value and process it
if (value = accept(:short... | ruby | {
"resource": ""
} |
q2916 | Opulent.Parser.attributes | train | def attributes(atts = {}, for_definition = false)
wrapped_attributes atts, for_definition
attributes_assignments atts, false, for_definition
atts
end | ruby | {
"resource": ""
} |
q2917 | Opulent.Parser.wrapped_attributes | train | def wrapped_attributes(list = {}, for_definition = false)
return unless (bracket = accept :brackets)
accept_newline
attributes_assignments list, true, for_definition
accept_newline
accept_stripped bracket.to_sym, :*
list
end | ruby | {
"resource": ""
} |
q2918 | Opulent.Parser.attributes_assignments | train | def attributes_assignments(list, wrapped = true, for_definition = false)
if wrapped && lookahead(:exp_identifier_stripped_lookahead).nil? ||
!wrapped && lookahead(:assignment_lookahead).nil?
return list
end
return unless (argument = accept_stripped :node)
argument = argument.t... | ruby | {
"resource": ""
} |
q2919 | Opulent.Parser.extend_attributes | train | def extend_attributes
return unless accept :extend_attributes
unescaped = accept :unescaped_value
extension = expression(false, false, false)
extension[@options][:escaped] = !unescaped
extension
end | ruby | {
"resource": ""
} |
q2920 | Opulent.Parser.root | train | def root(parent = @root, min_indent = -1)
while (@line = @code[(@i += 1)])
# Reset character position cursor
@j = 0
# Skip to next iteration if we have a blank line
next if @line =~ /\A\s*\Z/
# Reset the line offset
@offset = 0
# Parse the current line by... | ruby | {
"resource": ""
} |
q2921 | Opulent.Compiler.define | train | def define(node)
# Write out def method_name
definition = "def _opulent_definition_#{node[@value].to_s.tr '-', '_'}"
# Node attributes
parameters = []
node[@options][:parameters].each do |key, value|
parameters << "#{key} = #{value[@value]}"
end
parameters << 'attribut... | ruby | {
"resource": ""
} |
q2922 | Configurations.Arbitrary.respond_to_missing? | train | def respond_to_missing?(method, include_private = false)
__respond_to_writer?(method) ||
__respond_to_method_for_read?(method, *args, &block) ||
__respond_to_method_for_write?(method) ||
super
end | ruby | {
"resource": ""
} |
q2923 | Opulent.Parser.apply_definitions | train | def apply_definitions(node)
# Apply definition check to all of the node's children
process_definitions = proc do |children|
children.each do |child|
# Check if we have a definition
is_definition = if child[@value] == @current_def
child[@options][:recur... | ruby | {
"resource": ""
} |
q2924 | Opulent.Parser.accept | train | def accept(token, required = false, strip = false)
# Consume leading whitespace if we want to ignore it
accept :whitespace if strip
# We reached the end of the parsing process and there are no more lines
# left to parse
return nil unless @line
# Match the token to the current line.... | ruby | {
"resource": ""
} |
q2925 | Opulent.Parser.indent_lines | train | def indent_lines(text, indent)
text ||= ''
text.lines.map { |line| indent + line }.join
end | ruby | {
"resource": ""
} |
q2926 | RedboothRuby.Client.perform! | train | def perform!(resource_name, action, options = {})
ClientOperations::Perform.new(resource_name, action, session, options).perform!
end | ruby | {
"resource": ""
} |
q2927 | Faalis.Concerns::User::AuthDefinitions.password_required? | train | def password_required?
# TODO: nil? is not suitable for here we should use empty? or blink?
if Devise.omniauth_configs.any?
return (provider.nil? || password.nil?) && super
else
password.nil? && super
end
end | ruby | {
"resource": ""
} |
q2928 | RedboothRuby.File.download | train | def download(style='original', path=nil)
options = { session: session }
options[:download_path] = path unless path.nil?
request = RedboothRuby.request(:download, nil, "files/#{id}/download/#{style}/#{name}", {}, options)
request.body
end | ruby | {
"resource": ""
} |
q2929 | Opulent.Engine.render | train | def render(scope = Object.new, locals = {}, &block)
# Get opulent buffer value
if scope.instance_variable_defined?(:@_opulent_buffer)
initial_buffer = scope.instance_variable_get(:@_opulent_buffer)
else
initial_buffer = []
end
# If a layout is set, get the specific layout,... | ruby | {
"resource": ""
} |
q2930 | Opulent.Engine.read | train | def read(input)
if input.is_a? Symbol
@file = File.expand_path get_eval_file input
File.read @file
else
@file = File.expand_path __FILE__
input
end
end | ruby | {
"resource": ""
} |
q2931 | Opulent.Engine.get_eval_file | train | def get_eval_file(input)
input = input.to_s
unless File.extname(input) == Settings::FILE_EXTENSION
input += Settings::FILE_EXTENSION
end
input
end | ruby | {
"resource": ""
} |
q2932 | Opulent.Compiler.buffer_attributes_to_hash | train | def buffer_attributes_to_hash(attributes)
'{' + attributes.inject([]) do |extend_map, (key, attribute)|
extend_map << (
":\"#{key}\" => " + if key == :class
'[' + attribute.map do |exp|
exp[@value]
... | ruby | {
"resource": ""
} |
q2933 | Opulent.Compiler.buffer_attributes | train | def buffer_attributes(attributes, extension)
# Proc for setting class attribute extension, used as DRY closure
#
buffer_class_attribute_type_check = proc do |variable, escape = true|
class_variable = buffer_set_variable :local, variable
# Check if we need to add the class attribute
... | ruby | {
"resource": ""
} |
q2934 | Opulent.Compiler.buffer_split_by_interpolation | train | def buffer_split_by_interpolation(string, escape = true)
# Interpolate variables in text (#{variable}).
# Split the text into multiple dynamic and static parts.
begin
case string
when /\A\\\#\{/
# Escaped interpolation
buffer_freeze '#{'
string = $'
... | ruby | {
"resource": ""
} |
q2935 | Configurations.Strict.__evaluate_configurable! | train | def __evaluate_configurable!
entries = @properties.entries_at(@path)
entries.each do |property, value|
if value.is_a?(Maps::Properties::Entry)
__install_property__(property)
else
__install_nested_getter__(property)
end
end
end | ruby | {
"resource": ""
} |
q2936 | Configurations.Strict.__assign! | train | def __assign!(property, value)
@types.test!(@path.add(property), value)
v = @blocks.evaluate!(@path.add(property), value)
value = v unless v.nil?
super(property, value)
end | ruby | {
"resource": ""
} |
q2937 | Representative.AbstractXml.element | train | def element(name, *args, &block)
metadata = @inspector.get_metadata(current_subject, name)
attributes = args.extract_options!.merge(metadata)
subject_of_element = if args.empty?
@inspector.get_value(current_subject, name)
else
args.shift
end
raise ArgumentError, "t... | ruby | {
"resource": ""
} |
q2938 | Representative.AbstractXml.list_of | train | def list_of(name, *args, &block)
options = args.extract_options!
list_subject = args.empty? ? name : args.shift
raise ArgumentError, "too many arguments" unless args.empty?
list_attributes = options[:list_attributes] || {}
item_name = options[:item_name] || name.to_s.singularize
it... | ruby | {
"resource": ""
} |
q2939 | Opulent.Parser.expression | train | def expression(allow_assignments = true, wrapped = true, whitespace = true)
buffer = ''
# Build a ruby expression out of accepted literals
while (term = (whitespace ? accept(:whitespace) : nil) ||
modifier ||
identifier ||
method_call ||
... | ruby | {
"resource": ""
} |
q2940 | Opulent.Parser.array_elements | train | def array_elements(buffer = '')
if (term = expression)
buffer += term[@value]
# If there is an array_terminator ",", recursively gather the next
# array element into the buffer
if (terminator = accept_stripped :comma)
accept_newline
buffer += array_elements term... | ruby | {
"resource": ""
} |
q2941 | Opulent.Parser.method_call | train | def method_call
method_code = ''
while (method_start = accept(:exp_method_call))
method_code += method_start
argument = call
method_code += argument if argument
end
method_code == '' ? nil : method_code
end | ruby | {
"resource": ""
} |
q2942 | Opulent.Parser.call_elements | train | def call_elements(buffer = '')
# Accept both shorthand and default ruby hash style. Following DRY
# principles, a Proc is used to assign the value to the current key
#
# key: value
# :key => value
# value
if (symbol = accept_stripped :hash_symbol)
buffer += symbol
... | ruby | {
"resource": ""
} |
q2943 | Opulent.Parser.symbol | train | def symbol
return unless (colon = accept :colon)
return undo colon if lookahead(:whitespace)
if (exp = expression).nil?
error :symbol
else
colon + exp[@value]
end
end | ruby | {
"resource": ""
} |
q2944 | Opulent.Parser.ternary_operator | train | def ternary_operator(allow_assignments, wrapped)
if (buffer = accept :exp_ternary)
buffer += expression(allow_assignments, wrapped)[@value]
if (else_branch = accept :exp_ternary_else)
buffer += else_branch
buffer += expression(allow_assignments, wrapped)[@value]
end
... | ruby | {
"resource": ""
} |
q2945 | Ajax.ActionController.serialize_ajax_info | train | def serialize_ajax_info
layout_name =
if Ajax.app.rails?(3)
if @_rendered_layout.is_a?(String)
@_rendered_layout =~ /.*\/([^\/]*)/ ? $1 : @_rendered_layout
elsif @_rendered_layout
@_rendered_layout.variable_name
end
else
active_layout... | ruby | {
"resource": ""
} |
q2946 | Ajax.ActionController._layout_for_ajax | train | def _layout_for_ajax(default) #:nodoc:
ajax_layout = self.class.read_inheritable_attribute(:ajax_layout)
ajax_layout = if ajax_layout.nil? && default.nil?
nil
elsif ajax_layout.nil? && !default.nil? # look for one with the default name in layouts/ajax
if default =~ /^layouts\/aja... | ruby | {
"resource": ""
} |
q2947 | Opulent.Parser.filter | train | def filter(parent, indent)
return unless (filter_name = accept :filter)
# Get element attributes
atts = attributes(shorthand_attributes) || {}
# Accept inline text or multiline text feed as first child
error :fiter unless accept(:line_feed).strip.empty?
# Get everything under the ... | ruby | {
"resource": ""
} |
q2948 | Opulent.Compiler.plain | train | def plain(node, indent)
# Text value
value = node[@options][:value]
# Pretty print
if @settings[:pretty]
indentation = ' ' * indent
inline = @sibling_stack[-1][-1] &&
@sibling_stack[-1][-1][0] == :node &&
Settings::INLINE_NODE.include?(@sibling... | ruby | {
"resource": ""
} |
q2949 | Opulent.Parser.include_file | train | def include_file(_parent, indent)
return unless accept :include
# Process data
name = accept :line_feed || ''
name.strip!
# Check if there is any string after the include input
Logger.error :parse, @code, @i, @j, :include_end if name.empty?
# Get the complete file path based... | ruby | {
"resource": ""
} |
q2950 | RedboothRuby.Base.parse_timestamps | train | def parse_timestamps
@created_time = created_time.to_i if created_time.is_a? String
@created_time = Time.at(created_time) if created_time
end | ruby | {
"resource": ""
} |
q2951 | Opulent.Compiler.node | train | def node(node, indent)
# Pretty print
if @settings[:pretty]
indentation = ' ' * indent
inline = Settings::INLINE_NODE.include? node[@value]
indentate = proc do
if @in_definition
buffer "' ' * (indent + #{indent})"
else
buffer_freeze indent... | ruby | {
"resource": ""
} |
q2952 | FlexColumns.HasFlexColumns._flex_columns_before_save! | train | def _flex_columns_before_save!
self.class._all_flex_column_names.each do |flex_column_name|
klass = self.class._flex_column_class_for(flex_column_name)
if klass.requires_serialization_on_save?(self)
_flex_column_object_for(flex_column_name).before_save!
end
end
end | ruby | {
"resource": ""
} |
q2953 | FlexColumns.HasFlexColumns._flex_column_owned_object_for | train | def _flex_column_owned_object_for(column_name, create_if_needed = true)
column_name = self.class._flex_column_normalize_name(column_name)
out = _flex_column_objects[column_name]
if (! out) && create_if_needed
out = _flex_column_objects[column_name] = self.class._flex_column_class_for(column_n... | ruby | {
"resource": ""
} |
q2954 | Opulent.Parser.define | train | def define(parent, indent)
return unless accept(:def)
# Definition parent check
Logger.error :parse, @code, @i, @j, :definition if parent[@type] != :root
# Process data
name = accept(:node, :*).to_sym
# Create node
definition = [
:def,
name,
{ paramet... | ruby | {
"resource": ""
} |
q2955 | Rack.Ajax.encode_env | train | def encode_env(env)
env = env.dup
env.keep_if { |k, v| k =~ /[A-Z]/ }
env.to_yaml(:Encoding => :Utf8)
end | ruby | {
"resource": ""
} |
q2956 | Repack.Helper.webpack_asset_paths | train | def webpack_asset_paths(source, extension: nil)
return "" unless source.present?
paths = Repack::Manifest.asset_paths(source)
paths = paths.select {|p| p.ends_with? ".#{extension}" } if extension
host = ::Rails.configuration.repack.dev_server.host
port = ::Rails.configuration.repack.dev_... | ruby | {
"resource": ""
} |
q2957 | ChefHelpers.HasSource.has_source? | train | def has_source?(source, segment, cookbook=nil)
cookbook ||= cookbook_name
begin
run_context.cookbook_collection[cookbook].
send(:find_preferred_manifest_record, run_context.node, segment, source)
rescue Chef::Exceptions::FileNotFound
nil
end
end | ruby | {
"resource": ""
} |
q2958 | Tribe.Actable.process_events | train | def process_events
while (event = @_actable.mailbox.obtain_and_shift)
event_handler(event)
end
rescue Exception => exception
cleanup_handler(exception)
exception_handler(exception)
ensure
@_actable.mailbox.release do
process_events
end
nil
end | ruby | {
"resource": ""
} |
q2959 | Opulent.Context.evaluate | train | def evaluate(code, &block)
begin
eval code, @binding, &block
rescue NameError => variable
Compiler.error :binding, variable, code
end
end | ruby | {
"resource": ""
} |
q2960 | Opulent.Context.extend_locals | train | def extend_locals(locals)
# Create new local variables from the input hash
locals.each do |key, value|
begin
@binding.local_variable_set key.to_sym, value
rescue NameError => variable
Compiler.error :variable_name, variable, key
end
end
end | ruby | {
"resource": ""
} |
q2961 | Opulent.Context.extend_nonlocals | train | def extend_nonlocals(bind)
bind.eval('instance_variables').each do |var|
@binding.eval('self').instance_variable_set var, bind.eval(var.to_s)
end
bind.eval('self.class.class_variables').each do |var|
@binding.eval('self').class_variable_set var, bind.eval(var.to_s)
end
end | ruby | {
"resource": ""
} |
q2962 | Faalis::Dashboard::DSL.Index.attributes | train | def attributes(*fields_name, **options, &block)
if options.include? :except
@fields = resolve_model_reflections.reject do |field|
options[:except].include? field.to_sym
end
elsif options.include? :append
@fields += options[:append]
else
# set new value for fi... | ruby | {
"resource": ""
} |
q2963 | Faalis::Dashboard::Sections.ResourcesIndex.fetch_index_objects | train | def fetch_index_objects
scope = index_properties.default_scope
puts "<<<<<<<" * 100, scope
if !scope.nil?
# If user provided an scope for `index` section.
if scope.respond_to? :call
# If scope provided by a block
scope = scope.call
else
... | ruby | {
"resource": ""
} |
q2964 | Sanitize::Rails::Matchers.SanitizeFieldsMatcher.matches? | train | def matches?(instance)
self.instance = instance
# assign invalid value to each field
fields.each { |field| instance.send("#{field}=", invalid_value) }
# sanitize the object calling the method
instance.send(sanitizer) rescue nil
# check expectation on results
fields.all? { |fiel... | ruby | {
"resource": ""
} |
q2965 | Opulent.Parser.control | train | def control(parent, indent)
# Accept eval or multiline eval syntax and return a new node,
return unless (structure = accept(:control))
structure = structure.to_sym
# Handle each and the other control structures
condition = accept(:line_feed).strip
# Process each control structure c... | ruby | {
"resource": ""
} |
q2966 | Polipus.Robotex.delay! | train | def delay!(uri)
delay = delay(uri)
sleep delay - (Time.now - @last_accessed) if delay
@last_accessed = Time.now
end | ruby | {
"resource": ""
} |
q2967 | Faalis.DashboardHelper.get_url | train | def get_url(route_name, id = nil, engine = Rails.application)
return route_name.call if id.nil?
return route_name.call(id) unless id.nil?
end | ruby | {
"resource": ""
} |
q2968 | WardenStrategies.Simple.authenticate! | train | def authenticate!
if u = user_class.send(config[:authenticate_method], *required_param_values)
success!(u)
else
fail!(config[:error_message])
end
end | ruby | {
"resource": ""
} |
q2969 | Charging.Invoice.create! | train | def create!
super do
raise 'can not create without a domain' if invalid_domain?
raise 'can not create wihtout a charge account' if invalid_charge_account?
Invoice.post_charge_accounts_invoices(domain, charge_account, attributes)
end
reload_attributes!(Helpers.ex... | ruby | {
"resource": ""
} |
q2970 | Charging.Invoice.payments | train | def payments
reset_errors!
response = Http.get("/invoices/#{uuid}/payments/", domain.token)
return [] if response.code != 200
MultiJson.decode(response.body)
end | ruby | {
"resource": ""
} |
q2971 | Charging.Invoice.billet_url | train | def billet_url
return if unpersisted?
response = Http.get("/invoices/#{uuid}/billet/", domain.token)
return if response.code != 200
MultiJson.decode(response.body)["billet"]
rescue
nil
end | ruby | {
"resource": ""
} |
q2972 | Rexpense::Resources.Participant.participants | train | def participants(resource_id)
http.get(participants_endpoint(resource_id)) do |response|
Rexpense::Entities::UserCollection.build response
end
end | ruby | {
"resource": ""
} |
q2973 | Charging.ChargeAccount.update_attribute! | train | def update_attribute!(attribute, value, should_reload_attributes = true)
execute_and_capture_raises_at_errors(204) do
@last_response = Http.patch("/charge-accounts/#{uuid}/", domain.token, etag, attribute => value)
end
reload_attributes! if should_reload_attributes
end | ruby | {
"resource": ""
} |
q2974 | Rexpense::Resources.Membership.memberships | train | def memberships(organization_id)
http.get(membership_endpoint(organization_id)) do |response|
Rexpense::Entities::MembershipCollection.build response
end
end | ruby | {
"resource": ""
} |
q2975 | Rexpense::Resources.Membership.create_membership | train | def create_membership(organization_id, params)
http.post(membership_endpoint(organization_id), body: params) do |response|
response.parsed_body
end
end | ruby | {
"resource": ""
} |
q2976 | Rexpense::Resources.Membership.update_membership | train | def update_membership(organization_id, membership_id, params)
http.put("#{membership_endpoint(organization_id)}/#{membership_id}", body: params) do |response|
Rexpense::Entities::Membership.new response.parsed_body
end
end | ruby | {
"resource": ""
} |
q2977 | Rexpense::Resources.Attachment.attachments | train | def attachments(resource_id)
http.get(attachment_endpoint(resource_id)) do |response|
Rexpense::Entities::AttachmentCollection.build response
end
end | ruby | {
"resource": ""
} |
q2978 | Rexpense::Resources.Attachment.find_attachment | train | def find_attachment(resource_id, attachment_id)
http.get("#{attachment_endpoint(resource_id)}/#{attachment_id}") do |response|
Rexpense::Entities::Attachment.new response.parsed_body
end
end | ruby | {
"resource": ""
} |
q2979 | Rexpense::Resources.Comment.comments | train | def comments(resource_id)
http.get(comment_endpoint(resource_id)) do |response|
Rexpense::Entities::CommentCollection.build response
end
end | ruby | {
"resource": ""
} |
q2980 | Rexpense::Resources.Comment.find_comment | train | def find_comment(resource_id, comment_id)
http.get("#{comment_endpoint(resource_id)}/#{comment_id}") do |response|
Rexpense::Entities::Comment.new response.parsed_body
end
end | ruby | {
"resource": ""
} |
q2981 | Rexpense::Resources.Comment.create_comment | train | def create_comment(resource_id, params)
http.post(comment_endpoint(resource_id), body: params) do |response|
Rexpense::Entities::Comment.new response.parsed_body
end
end | ruby | {
"resource": ""
} |
q2982 | Rexpense::Resources.Comment.update_comment | train | def update_comment(resource_id, comment_id, params)
http.put("#{comment_endpoint(resource_id)}/#{comment_id}", body: params) do |response|
Rexpense::Entities::Comment.new response.parsed_body
end
end | ruby | {
"resource": ""
} |
q2983 | Enom.Domain.sync_auth_info | train | def sync_auth_info(options = {})
opts = {
"RunSynchAutoInfo" => 'True',
"EmailEPP" => 'True'
}
opts["EmailEPP"] = 'True' if options[:email]
Client.request({"Command" => "SynchAuthInfo", "SLD" => sld, "TLD" => tld}.merge(opts))
return self
end | ruby | {
"resource": ""
} |
q2984 | Enom.Domain.get_extended_domain_attributes | train | def get_extended_domain_attributes
sld, tld = name.split(".")
attributes = Client.request("Command" => "GetDomainInfo", "SLD" => sld, "TLD" => tld)["interface_response"]["GetDomainInfo"]
set_extended_domain_attributes(attributes)
end | ruby | {
"resource": ""
} |
q2985 | ActsAsRevisionable.RevisionRecord.restore | train | def restore
restore_class = self.revisionable_type.constantize
# Check if we have a type field, if yes, assume single table inheritance and restore the actual class instead of the stored base class
sti_type = self.revision_attributes[restore_class.inheritance_column]
if sti_type
begin
... | ruby | {
"resource": ""
} |
q2986 | ActsAsRevisionable.RevisionRecord.restore_record | train | def restore_record(record, attributes)
primary_key = record.class.primary_key
primary_key = [primary_key].compact unless primary_key.is_a?(Array)
primary_key.each do |key|
record.send("#{key.to_s}=", attributes[key.to_s])
end
attrs, association_attrs = attributes_and_associations(... | ruby | {
"resource": ""
} |
q2987 | ShipCompliant.SearchSalesOrdersResult.parse! | train | def parse!
unless raw.has_key?(:sales_orders)
raw[:sales_orders] = {}
end
# force orders to be an array
orders = raw[:sales_orders].fetch(:sales_order_summary, {})
unless orders.kind_of?(Array)
raw[:sales_orders][:sales_order_summary] = [orders]
end
# typecast... | ruby | {
"resource": ""
} |
q2988 | ShipCompliant.Client.call | train | def call(operation, locals = {})
locals['Security'] = ShipCompliant.configuration.credentials
response = savon_call(operation, message: {
'Request' => locals
})
get_result_from_response(operation, response)
end | ruby | {
"resource": ""
} |
q2989 | Elasticrawl.Job.confirm_message | train | def confirm_message
cluster = Cluster.new
case self.type
when 'Elasticrawl::ParseJob'
message = segment_list
else
message = []
end
message.push('Job configuration')
message.push(self.job_desc)
message.push('')
message.push(cluster.cluster_desc)
... | ruby | {
"resource": ""
} |
q2990 | Elasticrawl.Job.run_job_flow | train | def run_job_flow(emr_config)
cluster = Cluster.new
job_flow = cluster.create_job_flow(self, emr_config)
job_steps.each do |step|
job_flow.add_step(step.job_flow_step(job_config))
end
begin
job_flow.run
rescue StandardError => e
raise ElasticMapReduceAccessE... | ruby | {
"resource": ""
} |
q2991 | Scruffy::Layers.Scatter.draw | train | def draw(svg, coords, options={})
options.merge!(@options)
if options[:shadow]
svg.g(:class => 'shadow', :transform => "translate(#{relative(0.5)}, #{relative(0.5)})") {
coords.each { |coord| svg.circle( :cx => coord.first, :cy => coord.last + relative(0.9), :r => relative(2)... | ruby | {
"resource": ""
} |
q2992 | Scruffy::Layers.Area.draw | train | def draw(svg, coords, options={})
# svg.polygon wants a long string of coords.
points_value = "0,#{height} #{stringify_coords(coords).join(' ')} #{width},#{height}"
# Experimental, for later user.
# This was supposed to add some fun filters, 3d effects and whatnot.
# Neither ImageMagick ... | ruby | {
"resource": ""
} |
q2993 | LandingPage.UsersController.create | train | def create
params.require(:user).permit!
user = User.new(params[:user])
if user.valid?
user.save
flash.now[:success] = t('landing_page.subscribed')
render :create
else
@user = user
render :new
end
end | ruby | {
"resource": ""
} |
q2994 | Travish.EnvironmentParser.build_environment_hash | train | def build_environment_hash
parsed_variables = {}
@env.each do |env_row|
# Each row can potentially contain multiple environment
# variables
variables = extract_variables(env_row)
variables.each do |variables_with_values|
variables_with_values.each do |key, value|
... | ruby | {
"resource": ""
} |
q2995 | Travish.EnvironmentParser.extract_variables | train | def extract_variables(variable)
return [variable] if variable.is_a? Hash
return extract_variables_from_string(variable) if variable.is_a? String
[]
end | ruby | {
"resource": ""
} |
q2996 | Travish.EnvironmentParser.extract_variables_from_string | train | def extract_variables_from_string(string)
string.split(/ /).map do |defintion|
match = defintion.match STRING_REG_EX
next nil unless match
{ match[1] => match[2] }
end.reject(&:nil?)
end | ruby | {
"resource": ""
} |
q2997 | PoiseProfiler.Base._monkey_patch_old_chef! | train | def _monkey_patch_old_chef!
require 'chef/event_dispatch/dispatcher'
instance = self
orig_method = Chef::EventDispatch::Dispatcher.instance_method(:library_file_loaded)
Chef::EventDispatch::Dispatcher.send(:define_method, :library_file_loaded) do |filename|
instance.events = self
... | ruby | {
"resource": ""
} |
q2998 | Rango.Controller.rescue_http_error | train | def rescue_http_error(exception)
# we need to call it before we assign the variables
body = self.render_http_error(exception)
[exception.status, exception.headers, body]
end | ruby | {
"resource": ""
} |
q2999 | Tsuga::Service.Clusterer._build_clusters | train | def _build_clusters(tile)
used_ids = []
clusters = []
_adapter.in_tile(*tile.children).find_each do |child|
cluster = _adapter.build_from(tile.depth, child)
clusters << cluster
used_ids << child.id
end
return [used_ids, clusters]
end | ruby | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.