query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Builds the audit configuration as a hash | def build
{ audit: @config }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_config_audit(eh)\n if controller_name == \"ops\" && @sb[:active_tab] == \"settings_server\"\n server = MiqServer.find(@sb[:selected_server_id])\n message = \"Server [#{server.name}] (#{server.id}) in Zone [#{server.my_zone}] VMDB config updated\"\n else\n message = \"VMDB config upda... | [
"0.65356696",
"0.63442874",
"0.62737966",
"0.62154245",
"0.615035",
"0.6049359",
"0.6049359",
"0.6045917",
"0.600022",
"0.600022",
"0.5992351",
"0.5975883",
"0.5943585",
"0.58664787",
"0.58277136",
"0.5798916",
"0.576725",
"0.57396424",
"0.57336843",
"0.5659829",
"0.558553",
... | 0.8067966 | 0 |
Initializes a new parser instance with given log format. | def initialize(format)
@regexp = nil
@names = []
@format = parse_format(format)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(log, time_format=\"%Y-%m-%d %H:%M:%S\")\n @log = log\n @time_format = time_format\n end",
"def initialize(format)\n @regexp = nil\n @names = []\n @format = parse_format(format)\n end",
"def initialize( logger, format=HTML_LOG_FORMAT ) # :notnew:\n\t\t\t@logger... | [
"0.7170875",
"0.7076628",
"0.6831184",
"0.64820826",
"0.6418098",
"0.6329344",
"0.63275045",
"0.619786",
"0.608086",
"0.6065458",
"0.60419685",
"0.60283697",
"0.60096717",
"0.59981817",
"0.5991251",
"0.59633297",
"0.5961695",
"0.5938126",
"0.58910626",
"0.5880602",
"0.5869023... | 0.70526594 | 2 |
Parses line according to current log format and returns an hash of log field => value on success. Returns nil if line doesn't match current log format. | def parse(line)
row = line.to_s
row.chomp!
row.strip!
return unless match = regexp.match(row)
data = {}
names.each_with_index { |field, index| data[field] = match[index + 1] } # [0] == line
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_logline(line) \n line.strip!\n split_line = line.split(/\\|/)\n addr = split_line[0].split(',').last.strip\n\n unless (addr =~ /[\\s|\\-]+/) \n @dns_map.synchronize do\n addr = @dns_map[addr] if @dns_map.include? addr\n end\n details = {}\n ... | [
"0.7272941",
"0.6927233",
"0.68746567",
"0.66892266",
"0.6687989",
"0.66836727",
"0.654533",
"0.6504401",
"0.6448429",
"0.63262045",
"0.62551224",
"0.6179464",
"0.61556685",
"0.60570973",
"0.6013876",
"0.5992747",
"0.59810877",
"0.59615934",
"0.59511036",
"0.5940239",
"0.5886... | 0.60574394 | 13 |
Overwrite this method if you want to use some humanreadable name for log fields. This method is called only once at parse_format time. | def rename_this_name(name)
name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_format\n self.name.gsub!(/[^0-9a-z\\-_ ]/i, '_') unless self.name.nil?\n self.name.gsub!(/\\s+/, '-') unless self.name.nil?\n self.name = self.name.downcase unless self.name.nil?\n end",
"def name_format\n self.name.gsub!(/[^0-9a-z\\-_ ]/i, '_') unless self.name.nil?\n self.name.gsub!(/\... | [
"0.6288333",
"0.6288054",
"0.62814194",
"0.6247554",
"0.6212916",
"0.6185795",
"0.6135804",
"0.61193115",
"0.61130023",
"0.6069614",
"0.6020953",
"0.59954834",
"0.5993604",
"0.59858114",
"0.59818935",
"0.59571743",
"0.59559774",
"0.59559774",
"0.5946609",
"0.593987",
"0.59312... | 0.0 | -1 |
Parse log format into a suitable Regexp instance. | def parse_format(format)
format = format.to_s
format.chomp! # remove carriage return
format.strip! # remove leading and trailing space
format.gsub!(/[ \t]+/, ' ') # replace tabulations or spaces with a space
strip_quotes = proc { |string| string.gsub(/^\\"/, '').gsub(/\\"$/, '') }
find_quotes = proc { |string| string =~ /^\\"/ }
find_percent = proc { |string| string =~ /^%.*t$/ }
find_referrer_or_useragent = proc { |string| string =~ /Referer|User-Agent/ }
pattern = format.split(' ').map do |element|
has_quotes = !!find_quotes.call(element)
element = strip_quotes.call(element) if has_quotes
self.names << rename_this_name(element)
case
when has_quotes
if element == '%r' or find_referrer_or_useragent.call(element)
/"([^"\\]*(?:\\.[^"\\]*)*)"/
else
'\"([^\"]*)\"'
end
when find_percent.call(element)
'(\[[^\]]+\])'
when element == '%U'
'(.+?)'
else
'(\S*)'
end
end.join(' ')
@regexp = Regexp.new("^#{pattern}$")
format
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_entry(log_entry)\n @column = {}; i = 1;\n if attributes = log_entry.match(regexp)\n @args.each {|f| @column[f] = attributes[i]; i += 1}\n parse_datetime! if @column[:time]\n parse_request! if @column[:request]\n end\n @column\n end",
"def parse_format(format)\n format... | [
"0.64167714",
"0.6319797",
"0.601778",
"0.5882583",
"0.5825373",
"0.5782248",
"0.57726985",
"0.57099605",
"0.5661816",
"0.56097394",
"0.5558915",
"0.55182856",
"0.55079406",
"0.5492829",
"0.5492829",
"0.54644716",
"0.54644716",
"0.5458618",
"0.54085565",
"0.53458816",
"0.5328... | 0.5866498 | 4 |
POST /questions POST /questions.json | def create
@question = Question.new(question_params)
respond_to do |format|
if @question.save
format.html { redirect_to @question, notice: NoticeMessages::SUCCESS_CREATE_QUESTION }
format.json { render :show, status: :created, location: @question }
else
format.html { render :new }
format.json { render json: @question.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @question = Question.new(question_params)\n\n if @question.save\n render json: @question\n else\n render status: 400, nothing: true\n end\n end",
"def create\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index ... | [
"0.7366109",
"0.72979563",
"0.7059195",
"0.7000753",
"0.6956294",
"0.68727475",
"0.67733675",
"0.6729471",
"0.67116046",
"0.6706642",
"0.6705714",
"0.6689426",
"0.6647686",
"0.6635359",
"0.662669",
"0.662669",
"0.662669",
"0.662669",
"0.662669",
"0.662669",
"0.662669",
"0.6... | 0.658238 | 27 |
PATCH/PUT /questions/1 PATCH/PUT /questions/1.json | def update
check_delete_flg
respond_to do |format|
if @question.update_attributes(question_params)
format.html { redirect_to @question, notice: 'Question was successfully updated.' }
format.json { render :show, status: :ok, location: @question }
else
format.html { render :edit }
format.json { render json: @question.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to api_v1_question_path(@question), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n ... | [
"0.7183178",
"0.70807135",
"0.695786",
"0.6922571",
"0.6889465",
"0.6880434",
"0.6878839",
"0.6821033",
"0.6821033",
"0.6821033",
"0.6821033",
"0.6821033",
"0.68146294",
"0.6812733",
"0.68119365",
"0.6737482",
"0.6735343",
"0.6730865",
"0.67231053",
"0.6695253",
"0.6678821",
... | 0.6273291 | 80 |
DELETE /questions/1 DELETE /questions/1.json | def destroy
@question.destroy
respond_to do |format|
format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @v1_question.destroy\n render json: {'message': 'Deleted questio... | [
"0.7801243",
"0.77760345",
"0.762556",
"0.76092136",
"0.76092136",
"0.75923663",
"0.7591492",
"0.7591492",
"0.7591492",
"0.7591492",
"0.7591492",
"0.7591492",
"0.75907475",
"0.7587306",
"0.75842667",
"0.75842667",
"0.75842667",
"0.75842667",
"0.75842667",
"0.75842667",
"0.752... | 0.72688025 | 62 |
Use callbacks to share common setup or constraints between actions. | def set_question
@question = Question.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def question_params
params[:question][:selects_attributes].each do |key,select|
if action_name == 'create' && select[:desc] == '' && key.to_i >= 2 then
params[:question][:selects_attributes].delete(key)
end
end
params.require(:question).permit(:title, :desc, :limit_at, :delete_flg, selects_attributes: [:id, :desc], question_tags_attributes: [:id, :tag_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
Tests for release 0: | def test_array
assert_equal("Alex", @students[0].first_name, "The first student's name is not Alex.")
assert_equal(5, @students[0].scores.length, "The first student does not have exactly 5 scores.")
assert_not_equal(@students[0].scores[0], @students[0].scores[4], "The first student's first and third score aren't different.")
assert_equal(88, @students[0].scores[3], "The first student's forth score is not 88")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_prerelease?(_)\n false\n end",
"def test_method_release\n value_ = ::Versionomy.create(:major => 1, :minor => 9, :tiny => 2, :release_type => :alpha, :alpha_version => 4)\n value2_ = value_.release\n assert_equal([1, 9, 2, 0, :final, 0, 0], value2_.values_array)\n ... | [
"0.73116446",
"0.6761532",
"0.6675936",
"0.6674659",
"0.6583833",
"0.65824",
"0.6520728",
"0.65156156",
"0.64847535",
"0.6470528",
"0.6348684",
"0.63402945",
"0.6338741",
"0.62960804",
"0.6291086",
"0.6269317",
"0.6175935",
"0.6173145",
"0.6150502",
"0.6147146",
"0.6104929",
... | 0.0 | -1 |
Tests for release 1: | def test_average
assert_equal(90, @students[0].average, "The first student's average score is not 90")
assert_equal("A", @students[0].letter_grade, "The first student's letter grade is not an A.")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_prerelease?(_)\n false\n end",
"def prerelease_specs; end",
"def test_method_release\n value_ = ::Versionomy.create(:major => 1, :minor => 9, :tiny => 2, :release_type => :alpha, :alpha_version => 4)\n value2_ = value_.release\n assert_equal([1, 9, 2, 0, :final, 0, 0],... | [
"0.7133334",
"0.6801476",
"0.6784073",
"0.6770783",
"0.6739839",
"0.66585684",
"0.6618336",
"0.6535496",
"0.6533273",
"0.6486486",
"0.6486486",
"0.6486486",
"0.6486486",
"0.6486486",
"0.6486486",
"0.6486486",
"0.6474132",
"0.647095",
"0.647095",
"0.647095",
"0.647095",
"0.6... | 0.0 | -1 |
Tests for release 2: | def test_linear_search
ls_sample = @students
assert_equal(0, linear_search(ls_sample, "Alex"), "Alex is not the first student.")
assert_equal(-1, linear_search(ls_sample, "NOT A STUDENT"), "Oddly, NOT A STUDENT, is the name of a student!")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_version\n skip\n assert_equal 2, BookKeeping::VERSION\n end",
"def test_method_release\n value_ = ::Versionomy.create(:major => 1, :minor => 9, :tiny => 2, :release_type => :alpha, :alpha_version => 4)\n value2_ = value_.release\n assert_equal([1, 9, 2, 0, :final, 0, 0], valu... | [
"0.6921893",
"0.66968125",
"0.6682701",
"0.6682701",
"0.6682701",
"0.6682701",
"0.6682701",
"0.6682701",
"0.66439456",
"0.6642064",
"0.6597606",
"0.65617037",
"0.65609646",
"0.65239817",
"0.6505215",
"0.6505215",
"0.64898753",
"0.64898753",
"0.64898753",
"0.64898753",
"0.6489... | 0.0 | -1 |
GET /keeps GET /keeps.json | def index
@keeps = current_user.keeps
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @keep.destroy\n respond_to do |format|\n format.html { redirect_to keeps_url, notice: 'Keep was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def keep\n __flag__ :keep\n end",
"def create\n @keep = current_user.keeps.new(keep_params)\n... | [
"0.61826485",
"0.5939061",
"0.578585",
"0.5736232",
"0.5604894",
"0.55700713",
"0.55409604",
"0.5297712",
"0.5288494",
"0.52320296",
"0.514387",
"0.5052219",
"0.5008525",
"0.4967727",
"0.495026",
"0.4914129",
"0.48160097",
"0.48013148",
"0.47971484",
"0.47622234",
"0.47618657... | 0.6799335 | 0 |
GET /keeps/1 GET /keeps/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @keeps = current_user.keeps\n end",
"def create\n @keep = current_user.keeps.new(keep_params)\n\n respond_to do |format|\n if @keep.save\n format.html { redirect_to @keep, notice: 'Keep was successfully created.' }\n format.json { render :show, status: :created, location:... | [
"0.6873941",
"0.658599",
"0.63782775",
"0.61993",
"0.5789544",
"0.5743574",
"0.56037194",
"0.52863",
"0.51477486",
"0.5034365",
"0.5027886",
"0.50084805",
"0.49749145",
"0.49549726",
"0.49467292",
"0.49303037",
"0.49227002",
"0.49106556",
"0.48972327",
"0.4857236",
"0.482522"... | 0.0 | -1 |
POST /keeps POST /keeps.json | def create
@keep = current_user.keeps.new(keep_params)
respond_to do |format|
if @keep.save
format.html { redirect_to @keep, notice: 'Keep was successfully created.' }
format.json { render :show, status: :created, location: @keep }
else
format.html { render :new }
format.json { render json: @keep.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keep_params\n params.require(:keep).permit(:name, :note)\n end",
"def destroy\n @keep.destroy\n respond_to do |format|\n format.html { redirect_to keeps_url, notice: 'Keep was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @keeps = cu... | [
"0.63878644",
"0.6159866",
"0.6089544",
"0.59637654",
"0.5772348",
"0.5732716",
"0.5611234",
"0.54059875",
"0.5142877",
"0.5059239",
"0.5031172",
"0.502622",
"0.4993139",
"0.49844244",
"0.49567896",
"0.49027336",
"0.48594236",
"0.48133045",
"0.47660825",
"0.47459084",
"0.4713... | 0.65362144 | 0 |
PATCH/PUT /keeps/1 PATCH/PUT /keeps/1.json | def update
respond_to do |format|
if @keep.update(keep_params)
format.html { redirect_to @keep, notice: 'Keep was successfully updated.' }
format.json { render :show, status: :ok, location: @keep }
else
format.html { render :edit }
format.json { render json: @keep.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keep_params\n params.require(:keep).permit(:name, :note)\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n if @bookkeeping.update(bookkeeping_params)\n ... | [
"0.6169629",
"0.5838606",
"0.58272153",
"0.5804568",
"0.56894994",
"0.56139165",
"0.5543352",
"0.5519432",
"0.5514486",
"0.5481023",
"0.5462124",
"0.5448219",
"0.5445128",
"0.5445128",
"0.53900695",
"0.5244469",
"0.52325255",
"0.522228",
"0.52157545",
"0.51975554",
"0.5197555... | 0.6775914 | 0 |
DELETE /keeps/1 DELETE /keeps/1.json | def destroy
@keep.destroy
respond_to do |format|
format.html { redirect_to keeps_url, notice: 'Keep was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete path\n make_request(p... | [
"0.6477453",
"0.63981193",
"0.6344374",
"0.63188684",
"0.62339234",
"0.6199888",
"0.6199843",
"0.61940086",
"0.6188869",
"0.6167954",
"0.6146313",
"0.61321557",
"0.61170363",
"0.61096305",
"0.6093699",
"0.6093699",
"0.6093699",
"0.6093699",
"0.6093699",
"0.6093699",
"0.609369... | 0.7112117 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_keep
@keep = current_user.keeps.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def keep_params
params.require(:keep).permit(:name, :note)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Gets (or sets if not existing) ZMQ context used by M2R to create sockets. | def zmq_context(zmq_io_threads = 1)
Thread.exclusive do
@zmq_context ||= ZMQ::Context.new(zmq_io_threads)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def context\n @context ||= ::ZMQ::Context.new\n end",
"def zmq_context\n @zmq_context ||= create_zmq_context\n end",
"def context(worker_threads = 1)\n return @context if @context\n @context = ::ZMQ::Context.new(worker_threads)\n end",
"def context\n @context... | [
"0.80110765",
"0.77416795",
"0.7644047",
"0.7222548",
"0.70305806",
"0.6727173",
"0.6614803",
"0.6547695",
"0.6252111",
"0.5859823",
"0.57611305",
"0.5709235",
"0.55524844",
"0.55137044",
"0.54587895",
"0.54320097",
"0.5410488",
"0.53804314",
"0.53791654",
"0.5347228",
"0.534... | 0.72608227 | 3 |
GET /evaluations GET /evaluations.json | def index
if params[:query]
@evaluations = Evaluation.text_search(params[:query]).paginate(page: params[:page]).
order(date: :asc).per_page(10)
flash[:notice] = 'Ningún resultado' if @evaluations.empty?
else
@evaluations = Evaluation.paginate(page: params[:page]).order(date: :asc).per_page(10)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student.evaluations.find(params[:eval_id])\n\t\trender json: @evaluation\n\tend",
"def index\n @score_evaluations = ScoreEvaluation.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.j... | [
"0.76482457",
"0.72792095",
"0.7244273",
"0.7142984",
"0.71408343",
"0.70979303",
"0.7047793",
"0.70243746",
"0.70243746",
"0.70243746",
"0.70243746",
"0.70243746",
"0.6987093",
"0.68509597",
"0.6796471",
"0.6765452",
"0.6702309",
"0.6669017",
"0.66395843",
"0.66221195",
"0.6... | 0.5647331 | 70 |
GET /evaluations/1 GET /evaluations/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student.evaluations.find(params[:eval_id])\n\t\trender json: @evaluation\n\tend",
"def show\n @evaluations = Evaluation.find(params[:id])\n end",
"def evaluations(id)\n connection.get do |req|\n req.url \"job... | [
"0.77651966",
"0.6981567",
"0.69376636",
"0.68618554",
"0.68131685",
"0.673956",
"0.6719614",
"0.66970426",
"0.6682116",
"0.6674504",
"0.6674504",
"0.6674504",
"0.6674504",
"0.6674504",
"0.6662183",
"0.6624913",
"0.6612468",
"0.6604192",
"0.6585361",
"0.6463337",
"0.6439866",... | 0.0 | -1 |
POST /evaluations POST /evaluations.json | def create
@evaluation = Evaluation.new(evaluation_params)
@evaluation.image.attach(params[:evaluation][:image])
if @evaluation.save
flash[:success] = 'Guardado correctamente'
redirect_to new_evaluation_path
else
flash[:danger] = 'Ocurrió un error'
render :new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @evaluations = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n ... | [
"0.7273974",
"0.70637333",
"0.69349927",
"0.6858234",
"0.6858234",
"0.6789653",
"0.67693055",
"0.6732888",
"0.6721708",
"0.66040987",
"0.6552739",
"0.6520129",
"0.64986",
"0.6492909",
"0.64158195",
"0.6408603",
"0.63761246",
"0.6324832",
"0.63137615",
"0.63137615",
"0.6295575... | 0.0 | -1 |
PATCH/PUT /evaluations/1 PATCH/PUT /evaluations/1.json | def update
if @evaluation.update(evaluation_params)
flash[:success] = 'Actualizado correctamente'
redirect_to evaluations_url
else
flash[:danger] = 'Ocurrió un error'
render :edit
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render ... | [
"0.6757246",
"0.6757246",
"0.6750583",
"0.6687858",
"0.6585219",
"0.6557403",
"0.65512615",
"0.65512615",
"0.65512615",
"0.651603",
"0.65159357",
"0.64533395",
"0.64481455",
"0.6440528",
"0.6433122",
"0.64252967",
"0.63648576",
"0.63292396",
"0.63099295",
"0.62969625",
"0.628... | 0.6026098 | 40 |
DELETE /evaluations/1 DELETE /evaluations/1.json | def destroy
@evaluation.destroy
flash[:success] = 'Eliminado correctamente'
redirect_to evaluations_url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url }\n format.json { h... | [
"0.7424398",
"0.7424398",
"0.74239624",
"0.7418971",
"0.71991944",
"0.71984005",
"0.7196096",
"0.7196096",
"0.7196096",
"0.7196096",
"0.7196096",
"0.7196096",
"0.7175757",
"0.71084785",
"0.707799",
"0.70726866",
"0.70726866",
"0.70583737",
"0.7045507",
"0.7034911",
"0.7001618... | 0.66127187 | 47 |
Use callbacks to share common setup or constraints between actions. | def set_evaluation
@evaluation = Evaluation.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def evaluation_params
params.require(:evaluation).permit(:employee_id, :task_id, :result, :comment, :image, :date)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
create new array create counter start while loop that goes on while counter is less than length of array inside loop shovel the squared element into new array you created above increment counter return your new array at end of method end | def square_array(array)
squared = []
count = 0
while count < array.size do
squared << (array[count] ** 2)
count = count + 1
end
squared
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def square_array(array)\n new_array =[]\n\n counter = 0\n\nend",
"def square_array(array)\nnew_array = []\n array.length.times do |squared|\n new_array.push(array[squared]**2)\nend\n new_array\nend",
"def square_array(array)\n squared = []\n counter = 0\n while array[counter] do\n squared.push( arra... | [
"0.78806686",
"0.7704985",
"0.766338",
"0.760552",
"0.75770915",
"0.7572463",
"0.75372106",
"0.74659985",
"0.7316115",
"0.7306933",
"0.72722244",
"0.72264975",
"0.71411866",
"0.71235555",
"0.7055188",
"0.7005721",
"0.700134",
"0.6968619",
"0.69492733",
"0.6904648",
"0.6890036... | 0.7265993 | 12 |
Alyssa noticed that this will fail if the input is 0, or a negative number, and asked Alan to change the loop. How can you change the loop construct (instead of using begin/end/until) to make this work? Note that we're not looking to find the factors for 0 or negative numbers, but we just want to handle it gracefully instead of raising an exception or going into an infinite loop. Correct answer | def factors(number)
dividend = number
divisors = []
while dividend > 0 do
divisors << number / dividend if number % dividend == 0
dividend -= 1
end
divisors
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factors(number)\n return \"number must be greatr than zero\" if (number == 0 || number < 0 )\n \n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n dividend = number\... | [
"0.76306397",
"0.7435003",
"0.740309",
"0.72838336",
"0.72518027",
"0.7232551",
"0.7080079",
"0.70794725",
"0.70794725",
"0.70794725",
"0.70794725",
"0.7078107",
"0.7075073",
"0.706096",
"0.69839674",
"0.6976663",
"0.6959994",
"0.69444776",
"0.69351053",
"0.6918714",
"0.69125... | 0.6492147 | 80 |
To publish an unpublished post! | def publish!
return false unless published_at.nil?
update_column :published_at, Time.zone.now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unpublish\n self.published = false\n end",
"def published_post\n if self.published && self.published_at.nil?\n self.published_at = Time.now\n end\n end",
"def publish_now!\n puts 'publish noew...'\n self.status = Post::PUBLISHED\n self.published_at = self.publish_at\n save!\n e... | [
"0.7406649",
"0.7263694",
"0.72541285",
"0.7223113",
"0.71972275",
"0.71782094",
"0.7161214",
"0.7159091",
"0.71373683",
"0.71267724",
"0.71267724",
"0.7094058",
"0.70638865",
"0.7050111",
"0.70419884",
"0.70189637",
"0.70066524",
"0.7000333",
"0.69820297",
"0.6974708",
"0.69... | 0.66427946 | 45 |
To archive an published post! | def archive!
return false if published_at.nil?
update_column :published_at, nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publish\n @options['date'] ||= read_draft_date || Time.now.iso8601\n\n post_options = {\n 'title' => read_draft_title,\n 'date' => @options['date'],\n 'slug' => publish_slug,\n 'content' => read_draft_content,\n 'dir' => @options['dir'],\n 'type' ... | [
"0.7297874",
"0.72712755",
"0.70562774",
"0.67503256",
"0.6705305",
"0.6694305",
"0.66251767",
"0.65788305",
"0.6553341",
"0.654689",
"0.6536898",
"0.6536898",
"0.6536898",
"0.65101534",
"0.6469682",
"0.6405118",
"0.6375614",
"0.63722783",
"0.63638103",
"0.63638103",
"0.63622... | 0.68940467 | 3 |
GET /admin/seasons GET /admin/seasons.json | def index
@admin_seasons = Season.order(:id).page params[:page]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seasons(season = nil)\n @server.make_json_request('show.seasons', tvdbid: @tvdbid, season: season)['data']\n end",
"def index\n @seasons = Season.all\n end",
"def index\n @seasons = Season.all\n end",
"def index\n @seasons = Season.all\n end",
"def index\n @seasons = Season.all\n... | [
"0.8196942",
"0.7891486",
"0.7891486",
"0.7891486",
"0.7738101",
"0.76770204",
"0.7667941",
"0.7503564",
"0.74072254",
"0.7363416",
"0.73052025",
"0.7289331",
"0.72162664",
"0.7134791",
"0.7009921",
"0.69439167",
"0.69180185",
"0.69180185",
"0.69180185",
"0.69180185",
"0.6905... | 0.78801215 | 4 |
GET /admin/seasons/1 GET /admin/seasons/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @admin_seasons = Season.order(:id).page params[:page]\n end",
"def set_admin_season\n @admin_season = Season.find(params[:id])\n end",
"def index\n @seasons = Season.all\n end",
"def index\n @seasons = Season.all\n end",
"def index\n @seasons = Season.all\n end",
"def ... | [
"0.7799653",
"0.77242374",
"0.7644971",
"0.7644971",
"0.7644971",
"0.76306987",
"0.7597699",
"0.7596639",
"0.74972177",
"0.74609745",
"0.72930014",
"0.71832204",
"0.70913225",
"0.70664793",
"0.70366323",
"0.7016701",
"0.70062596",
"0.6957691",
"0.6957691",
"0.6957691",
"0.695... | 0.0 | -1 |
POST /admin/seasons POST /admin/seasons.json | def create
@admin_season = Season.new(admin_season_params)
respond_to do |format|
if @admin_season.save
format.html { redirect_to @admin_season, success: 'Season was successfully created.' }
format.json { render :show, status: :created, location: @admin_season }
else
format.html { render :new }
format.json { render json: @admin_season.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @season = Season.new(season_params)\n\n if @season.save\n render :show, status: :created\n else\n render json: @season.errors, status: :unprocessable_entity\n end\n end",
"def create\n @season = Season.new(season_params)\n\n respond_to do |format|\n if @season.save\... | [
"0.76837736",
"0.7523077",
"0.7463524",
"0.7298656",
"0.7272153",
"0.7209834",
"0.7198521",
"0.7117333",
"0.7105351",
"0.70489275",
"0.7010434",
"0.7005163",
"0.6982686",
"0.69234407",
"0.69234407",
"0.69234407",
"0.689465",
"0.6885727",
"0.6819873",
"0.6817382",
"0.681178",
... | 0.7867362 | 0 |
PATCH/PUT /admin/seasons/1 PATCH/PUT /admin/seasons/1.json | def update
respond_to do |format|
if @admin_season.update(admin_season_params)
format.html { redirect_to @admin_season, success: 'Season was successfully updated.' }
format.json { render :show, status: :ok, location: @admin_season }
else
format.html { render :edit }
format.json { render json: @admin_season.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @season.update(season_params)\n render :show, status: :ok\n else\n render json: @season.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_with @season.update(season_params)\n end",
"def update\n respond_to do |format|\n if @season.upda... | [
"0.72138053",
"0.71359223",
"0.70761573",
"0.7051942",
"0.6991588",
"0.6871768",
"0.6759073",
"0.6624852",
"0.63472354",
"0.6291078",
"0.6265505",
"0.6259548",
"0.6250065",
"0.6246902",
"0.62152296",
"0.6158318",
"0.6158318",
"0.6158318",
"0.6158318",
"0.6152593",
"0.6124393"... | 0.7618151 | 0 |
DELETE /admin/seasons/1 DELETE /admin/seasons/1.json | def destroy
@admin_season.destroy
respond_to do |format|
format.html { redirect_to admin_seasons_url, success: 'Season was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n # @season = Season.find(params[:id])\n # @season.destroy\n\n respond_to do |format|\n format.html { redirect_to seasons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @season = Season.find(params[:id])\n @season.destroy\n\n respond_to do |forma... | [
"0.7915161",
"0.7884197",
"0.7858903",
"0.7802964",
"0.7740253",
"0.76941186",
"0.7636819",
"0.75907576",
"0.73634756",
"0.7242498",
"0.70923734",
"0.7075628",
"0.70716405",
"0.7067745",
"0.70570636",
"0.7053149",
"0.70393634",
"0.70211005",
"0.70117146",
"0.6993472",
"0.6988... | 0.8084412 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_admin_season
@admin_season = Season.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def admin_season_params
params.require(:season).permit(:id, :league_id, :year, :day, :start_date, :number_of_weeks, :roll_off_weeks, :dates_off, :handicap_base, :handicap_percent, :location, :practice_length, :starts_at)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Update the visibility of the work to match the correct state of the embargo, then clear the embargo date, etc. Saves the embargo and the work | def destroy
case work
when Valkyrie::Resource
embargo_manager = Hyrax::EmbargoManager.new(resource: work)
return if embargo_manager.embargo.embargo_release_date.blank?
embargo_manager.deactivate!
work.embargo = Hyrax.persister.save(resource: embargo_manager.embargo)
Hyrax::AccessControlList(work).save
else
work.embargo_visibility! # If the embargo has lapsed, update the current visibility.
work.deactivate_embargo!
work.embargo.save!
work.save!
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deactivate_embargo!\n return if embargo.nil?\n # embargo.deactivate! whipes out work.visibility_after_embargo before it can be applied, so save it and apply it\n vis_after = visibility_after_embargo\n vis_after = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATE... | [
"0.5976257",
"0.59403116",
"0.5825746",
"0.56778425",
"0.5637207",
"0.56207114",
"0.5617127",
"0.5612085",
"0.54693437",
"0.5466499",
"0.54524815",
"0.5413655",
"0.5394189",
"0.5387808",
"0.537591",
"0.5370347",
"0.5364161",
"0.5341061",
"0.53320587",
"0.53238064",
"0.5314773... | 0.6435617 | 0 |
lesende Methoden def x() | def oben()
return @fahrbahn.obere_linke_ecke().y()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x\n end",
"def x\n end",
"def x\n end",
"def x; end",
"def x; end",
"def x; end",
"def x; end",
"def x; end",
"def x() @x end",
"def x \n @x \n end",
"def x #getter method\n\t\t@x\n\tend",
"def x\n @x\n end",
"def get_x; \t\t@x \t\t\tend",
"def x; 1; end",
"def getX... | [
"0.8510884",
"0.83706814",
"0.83706814",
"0.786324",
"0.786324",
"0.786324",
"0.786324",
"0.786324",
"0.77257115",
"0.73334944",
"0.72962934",
"0.7136934",
"0.704187",
"0.68973565",
"0.68889916",
"0.66692376",
"0.6666214",
"0.6652548",
"0.66471565",
"0.6534988",
"0.6534988",
... | 0.0 | -1 |
TODO: Optimize to not calculate on every read. Cache total expenses and update on add | def total_expenses
expenses.sum(:amount) || 0.0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_expenses\n self.expenses.sum(\"amount\")\n end",
"def expenses\n @expenses ||= Harvest::API::Expenses.new(credentials)\n end",
"def expense_total\n self.expenses.sum(:amount).to_f\n end",
"def calc_sum_of_exp(expenses)\n prices = []\n expenses.each do |num|\n prices << num['pri... | [
"0.73743963",
"0.7148933",
"0.69950455",
"0.6750977",
"0.67007786",
"0.66225916",
"0.64900327",
"0.63648957",
"0.6335158",
"0.6327137",
"0.6282385",
"0.6282385",
"0.6282385",
"0.61668694",
"0.61641157",
"0.61548376",
"0.6149582",
"0.6143987",
"0.61340106",
"0.61119473",
"0.61... | 0.7099819 | 2 |
GET /breweries GET /breweries.json | def index
@last5ratings = Rating.last5
@ratings = Rating.includes(:beer, :user).all
TestJob.perform_async
#Rails.cache.write('brewery top 3', Brewery.top(3), expires_in: 15.minutes)
@top_breweries = brewery.top(3)
#Rails.cache.write('beers top 3', Beer.top(3), expires_in: 15.minutes)
@top_beers = beer.top(3)
#Rails.cache.write('style top 3', Style.top(3), expires_in: 15.minutes)
@top_styles = style.top(3)
@most_active = User.most_active(3)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @active_breweries = Brewery.active\n\t\t@retired_breweries = Brewery.retired\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @breweries }\n end\n end",
"def state_breweries\n render json: BreweryDb::ShowBreweries.new('state', params[:state... | [
"0.77884763",
"0.7670918",
"0.7586876",
"0.75477356",
"0.6680661",
"0.642776",
"0.6395458",
"0.63518757",
"0.61870176",
"0.61443573",
"0.61317825",
"0.60553575",
"0.6040625",
"0.6007967",
"0.5992113",
"0.59805167",
"0.5946019",
"0.594275",
"0.59425575",
"0.5938999",
"0.593345... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_rating
@rating = Rating.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def rating_params
params.require(:rating).permit(:score, :beer_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980629",
"0.67819995",
"0.67467666",
"0.67419875",
"0.67347664",
"0.65928614",
"0.6504013",
"0.6498014",
"0.64819515",
"0.64797956",
"0.64562726",
"0.64400834",
"0.6380117",
"0.6377456",
"0.63656694",
"0.6320543",
"0.63002014",
"0.62997127",
"0.629425",
"0.6293866",
"0.62... | 0.0 | -1 |
Returns all helper classes under the Hyde::Helpers module. | def get_helpers
Hyde::Helpers.constants.inject([Hyde::Helpers]) do |a, constant|
mod = Hyde::Helpers.const_get(constant)
a << mod if mod.is_a? Module
a
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_app_helper_classes\n klasses = []\n expression = \"#{Jets.root}app/helpers/**/*\"\n Dir.glob(expression).each do |path|\n next unless File.file?(path)\n class_name = path.sub(\"#{Jets.root}app/helpers/\",\"\").sub(/\\.rb/,'')\n unless class_name == \"applica... | [
"0.8000439",
"0.7471334",
"0.7220933",
"0.71666306",
"0.7035728",
"0.6984757",
"0.6959735",
"0.6859301",
"0.67870086",
"0.67782754",
"0.6773248",
"0.6769744",
"0.6736882",
"0.6736882",
"0.6736882",
"0.6736882",
"0.6625418",
"0.6603668",
"0.6567974",
"0.65569323",
"0.65351605"... | 0.8618396 | 0 |
Add an other attribute to the class list | def eav_attribute name, type = String
name = name.to_s if !name.is_a? String
self.class_eav_attributes[name] = type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_class(current_attributes, new_attributes)\n current_attributes ||= ''\n current_attributes.split(' ').push(new_attributes).join(' ')\n end",
"def append_class! klass\n return if already_marked? klass\n if has_class_attribute?\n add_class_to_attribute klass\n else\n add_class_and... | [
"0.65757895",
"0.64962447",
"0.64871544",
"0.6478442",
"0.6456498",
"0.6345784",
"0.61744887",
"0.60497695",
"0.6031806",
"0.59720886",
"0.5936943",
"0.5936943",
"0.5936943",
"0.591825",
"0.5908023",
"0.5903104",
"0.5894154",
"0.5884344",
"0.5871898",
"0.5870103",
"0.5865091"... | 0.0 | -1 |
class accessor when the superclass != AR::Base asume we are in STI mode | def class_eav_attributes # :nodoc:
if superclass != ActiveRecord::Base
if superclass.class_eav_attributes.nil?
@eav_attributes
else
@eav_attributes.nil? ? superclass.class_eav_attributes : superclass.class_eav_attributes.merge(@eav_attributes)
end
else
@eav_attributes
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_class\n S::Model\n end",
"def subclass_from_attributes(attrs)\n active_authorizer[:default].deny?(inheritance_column) ? nil : super\n end",
"def subclass_from_attrs(attrs)\n active_authorizer[:default].deny?(inheritance_column) ? nil : super\n end",
"def s... | [
"0.6882637",
"0.66980875",
"0.6634569",
"0.6632972",
"0.6632972",
"0.6532066",
"0.6491501",
"0.6488903",
"0.6456936",
"0.64501745",
"0.64501745",
"0.64480627",
"0.64428705",
"0.6394114",
"0.6393843",
"0.6393843",
"0.63448036",
"0.63448036",
"0.62826717",
"0.62527287",
"0.6245... | 0.0 | -1 |
class accessor when the superclass != AR::Base asume we are in STI mode | def eav_class # :nodoc:
if superclass != ActiveRecord::Base
@eav_class ? @eav_class : superclass.eav_class
else
@eav_class
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_class\n S::Model\n end",
"def subclass_from_attributes(attrs)\n active_authorizer[:default].deny?(inheritance_column) ? nil : super\n end",
"def subclass_from_attrs(attrs)\n active_authorizer[:default].deny?(inheritance_column) ? nil : super\n end",
"def s... | [
"0.6883738",
"0.6696335",
"0.6632882",
"0.6631841",
"0.6631841",
"0.6531633",
"0.64903426",
"0.6488659",
"0.6456729",
"0.6448828",
"0.6448828",
"0.64467263",
"0.6443674",
"0.63933545",
"0.6393048",
"0.6393048",
"0.6344293",
"0.6344293",
"0.6283801",
"0.6251904",
"0.62458587",... | 0.61714816 | 25 |
get the class eav attributes | def class_eav_attributes
self.class.class_eav_attributes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_attributes; end",
"def attrs\n self.class.attrs\n end",
"def attributes\n self.class::ATTRIBUTES\n end",
"def class_attributes\n @__class_attributes\n end",
"def attributes\n self.class.class_variable_get(:@@attributes)\n end",
"def attr_info; end",
... | [
"0.78152573",
"0.74947804",
"0.74825466",
"0.7437369",
"0.7332412",
"0.7282562",
"0.7260009",
"0.7175514",
"0.7144768",
"0.7137381",
"0.7137381",
"0.709971",
"0.709194",
"0.70870787",
"0.70865947",
"0.707456",
"0.7071141",
"0.7063033",
"0.7062979",
"0.7024419",
"0.7016693",
... | 0.8413792 | 0 |
Override this to get some usable attributes Cowardly refusing to adhere to all | def instance_eav_attributes
[]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes\n end",
"def attribu... | [
"0.7786013",
"0.7786013",
"0.7786013",
"0.7786013",
"0.7786013",
"0.7786013",
"0.7786013",
"0.7786013",
"0.7786013",
"0.7786013",
"0.7786013",
"0.74917036",
"0.7422734",
"0.74148524",
"0.7285061",
"0.7225994",
"0.718594",
"0.7170905",
"0.7168279",
"0.7099865",
"0.7087319",
... | 0.0 | -1 |
get all the eav attribute instances available for this model instance eg: if you model says 'has_eav :through => :post_attribute' these are all PostAttribute's | def eav_attributes
@eav_attributes ||= eav_class.all(
:conditions => { self_key => self.id }
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eav_attributes_list # :nodoc:\n (\n self.instance_eav_attributes + self.class_eav_attributes.keys\n ).collect { |attribute| attribute.to_s }.uniq\n end",
"def instance_eav_attributes\n []\n end",
"def class_eav_attributes\n self.class.class_eav_a... | [
"0.7160483",
"0.71404773",
"0.6560422",
"0.62237036",
"0.6057279",
"0.6022066",
"0.6004467",
"0.5991975",
"0.5979192",
"0.5960487",
"0.5939792",
"0.58464634",
"0.58055544",
"0.57552516",
"0.5714781",
"0.57125956",
"0.5695753",
"0.56900287",
"0.56176496",
"0.5597341",
"0.55913... | 0.72051424 | 0 |
save the list of eav_attribute back to the database | def save_eav_attributes # :nodoc:
eav_attributes.select { |a| a.changed? }.each do |a|
if a.new_record?
a.send( :write_attribute, self_key, self.id )
end
a.save!
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_save_list\n save_list.each do |obj|\n obj.save!\n end\n end",
"def store_values\n self.parent.write_attribute(self.field_name, self.ids)\n end",
"def save_flex_attributes\n @save_flex_attr ||= []\n attribute_class = self.flex_options[:class_name].constantize\n... | [
"0.6415177",
"0.6237235",
"0.61945754",
"0.6173415",
"0.6088706",
"0.6061614",
"0.5941664",
"0.5883169",
"0.58692884",
"0.5864993",
"0.5863809",
"0.57627577",
"0.5724682",
"0.5711941",
"0.56883806",
"0.5686315",
"0.5654714",
"0.5646488",
"0.5631958",
"0.5616012",
"0.55745417"... | 0.7276086 | 0 |
destroy eav_attributes from database | def destroy_eav_attributes # :nodoc:
eav_class.send :delete_all, "#{self_key} = #{self.id}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n row.delete_attribute(attr_name)\n row.save\n end",
"def destroy\n @exp_attribute.destroy\n end",
"def destroy\n @image_attrib.destroy\n end",
"def destroy\n @attr_val = AttrVal.find(params[:id])\n @attr_val.destroy\n \n respond_to do |format|\n format... | [
"0.7304668",
"0.72847164",
"0.71885896",
"0.7016078",
"0.68958515",
"0.6863548",
"0.67528373",
"0.66602373",
"0.66602373",
"0.66602373",
"0.66602373",
"0.6653157",
"0.66492736",
"0.6625578",
"0.66135097",
"0.6468355",
"0.64663786",
"0.64618444",
"0.6456652",
"0.64319843",
"0.... | 0.83372605 | 0 |
override changed if any of the eav_attributes has changed, the object has changed. | def changed?
eav_attributes.each do |attribute|
return true if ( attribute.changed? || attribute.new_record? )
end
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_eav_attributes # :nodoc:\n eav_attributes.select { |a| a.changed? }.each do |a|\n if a.new_record?\n a.send( :write_attribute, self_key, self.id )\n end\n\n a.save!\n end\n end",
"def changed_attributes\n @_hr_changed.select{|k,... | [
"0.68536747",
"0.64793795",
"0.64159346",
"0.63754934",
"0.6277467",
"0.6277467",
"0.6178014",
"0.6160696",
"0.61295795",
"0.6078641",
"0.60720426",
"0.5986306",
"0.5982237",
"0.5976874",
"0.5960141",
"0.59529346",
"0.5917471",
"0.59070575",
"0.5902903",
"0.58974177",
"0.5877... | 0.72777396 | 0 |
get a complete list of eav_attributes (class + instance) | def eav_attributes_list # :nodoc:
(
self.instance_eav_attributes + self.class_eav_attributes.keys
).collect { |attribute| attribute.to_s }.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instance_eav_attributes\n []\n end",
"def class_eav_attributes\n self.class.class_eav_attributes\n end",
"def eav_attributes\n @eav_attributes ||= eav_class.all(\n :conditions => { self_key => self.id }\n )\n end",
"def attributes\n ... | [
"0.8126298",
"0.79447365",
"0.768488",
"0.71056926",
"0.6892443",
"0.67610013",
"0.6665689",
"0.6635092",
"0.6618549",
"0.6616941",
"0.66059387",
"0.6604837",
"0.6596148",
"0.6564673",
"0.6551039",
"0.64977753",
"0.6489918",
"0.64826006",
"0.64826006",
"0.6474307",
"0.6459152... | 0.84049815 | 0 |
get the key to my <3 | def self_key # :nodoc:
klass = self.class
if klass.superclass != ActiveRecord::Base
if klass.superclass.eav_class == klass.eav_class
klass = klass.superclass
end
end
"#{klass.name.underscore}_id".to_sym
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_key; end",
"def key2\n self.key('key2')\n end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; en... | [
"0.7160324",
"0.70946294",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",
"0.70882124",... | 0.0 | -1 |
make sure EAV is included in as_json, to_json and to_xml | def serializable_hash options=nil
hash = super
eav_attributes_list.each do |attribute|
hash[attribute] = self.send(attribute)
end
hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attributes_before_type_cast\n json_attributes_before_type_cast\n end",
"def serializer; end",
"def e(object)\n require 'json'\n object.respond_to?(:to_json) ? object.to_json : object.to_s.to_json\n end",
"def json_serialize\n end",
"def to_serialized_json\n # @sighting.to_json(:i... | [
"0.6028282",
"0.6010551",
"0.58420783",
"0.57404816",
"0.56961584",
"0.56824327",
"0.56650573",
"0.5637409",
"0.55957013",
"0.55818194",
"0.55818194",
"0.5560551",
"0.55250984",
"0.5514573",
"0.55105966",
"0.5488464",
"0.5474449",
"0.5472394",
"0.54710424",
"0.54426444",
"0.5... | 0.0 | -1 |
cast an eav value to it's desired class | def cast_eav_value value, attribute # :nodoc:
attributes = self.class_eav_attributes.stringify_keys
return value unless attributes.keys.include?(attribute)
return value if attributes[attribute] == String # no need for casting
begin
# for core types [eg: Integer '12']
eval("#{attributes[attribute]} '#{value}'")
rescue
begin
# for BigDecimal [eg: BigDecimal.new("123.45")]
eval("#{attributes[attribute]}.new('#{value}')")
rescue
begin
# for date/time classes [eg: Date.parse("2011-03-20")]
eval("#{attributes[attribute]}.parse('#{value}')")
rescue
value
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cast_value(value)\n case value\n when String then decode_and_initialize(value)\n when Hash then extract_model_klass(value).new(value)\n when nil then value\n else\n raise_cast_error(value) unless value.class.ancestors.include?(StoreModel::Model)\n\n value\n ... | [
"0.7295181",
"0.7224626",
"0.720881",
"0.7150351",
"0.7137998",
"0.6998941",
"0.6989034",
"0.69835377",
"0.6951463",
"0.68612784",
"0.6808247",
"0.675752",
"0.6708058",
"0.6697641",
"0.6695794",
"0.6665635",
"0.6645443",
"0.6633784",
"0.65911055",
"0.65722615",
"0.6547955",
... | 0.8019697 | 0 |
Validate that the URIs I'm trying to connect belongs to the resource owner | def validate_owner(record, attribute, uris)
klass = Device
ids = find_ids(uris)
real = klass.in(id: ids).where(resource_owner_id: record.resource_owner_id)
expected = klass.in(id: ids)
not_owned_ids = expected.map(&:id) - real.map(&:id)
record.errors.add(attribute, "not owned with IDs #{not_owned_ids.join(',')}") if not real.count == expected.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate\n unless self.uri.blank?\n self.uri = \"http://#{self.uri}\" unless URI.parse(self.uri).absolute? \n end\n rescue\n errors.add(:uri, \"malformed uri -- please check it\")\n end",
"def valid_uri?\n !self.contentable.blank? || !self.uri_path.blank?\n end",
"def is_resourc... | [
"0.6278455",
"0.6152992",
"0.5973217",
"0.5937367",
"0.5909034",
"0.58995324",
"0.589311",
"0.58857423",
"0.58768547",
"0.5851981",
"0.57891494",
"0.5778032",
"0.5773554",
"0.57326454",
"0.5732363",
"0.572513",
"0.57185817",
"0.57079214",
"0.5681624",
"0.56678855",
"0.5664241... | 0.68442744 | 0 |
process does all the heavy lifting adds any uncoded values discovered to the (global) uncoded_values_hash returns a hash with stats on coding | def process(uncoded_values_hash)
@uncoded = uncoded_values_hash
uncoded_encounters = find_uncoded_encounters()
uncoded_products = find_uncoded_products()
uncoded_problems = find_uncoded_problems()
uncoded_vital_results = find_uncoded_results("VitalSigns")
uncoded_test_results = find_uncoded_results("Results")
uncoded_alerts = find_uncoded_alerts()
# perfect = uncoded_encounters.size > 0 && uncoded_products.size > 0 && uncoded_problems.size > 0 && uncoded_vital_results.size > 0 && uncoded_test_results.size > 0 && uncoded_alerts.size > 0
# if perfect
# STDERR.puts "***PERFECT***"
# end
# STDERR.puts "e: #{uncoded_encounters.size} prod: #{uncoded_products.size} prob: #{uncoded_problems.size} v: #{uncoded_vital_results.size} t: #{uncoded_test_results.size} a: #{uncoded_alerts.size}"
# end
@summaryfp.puts JSON.pretty_generate(@summary)
@summaryfp.close
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def analysis\n hash = {}\n @array.each do |item|\n chars = item.chars.to_a - @used_chars\n\n chars.each do |char|\n if hash[char] == nil\n hash[char] = 1\n else\n hash[char] += 1\n end\n end\n end\n\n hash.sort_by { |_, v| -v... | [
"0.55653584",
"0.5561838",
"0.5543264",
"0.5535405",
"0.54895025",
"0.5467511",
"0.53762823",
"0.53375405",
"0.53164434",
"0.5315674",
"0.5291511",
"0.5252317",
"0.52290654",
"0.52205414",
"0.5196489",
"0.5189786",
"0.51835316",
"0.5161801",
"0.5158579",
"0.5117099",
"0.51115... | 0.7689453 | 0 |
normalize_coding_system attempts to simplify analysis of the XML doc by normalizing the names of the coding systems Input is a single "Code" node in the tree, and the side effect is to edit the CodingSystem subnode. | def normalize_coding_system(code)
lookup = {
"lnc" => "LOINC",
"loinc" => "LOINC",
"cpt" => "CPT",
"cpt-4" => "CPT",
"snomedct" => "SNOMEDCT",
"snomed-ct" => "SNOMEDCT",
"rxnorm" => "Rxnorm",
"icd9-cm" => "ICD9",
"icd9" => "ICD9"
}
codingsystem = lookup[code.xpath('./CodingSystem')[0].content.downcase]
if(codingsystem)
code.xpath('./CodingSystem')[0].content = codingsystem
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_coding_system(code)\n lookup = {\n \"lnc\" => \"LOINC\",\n \"loinc\" => \"LOINC\",\n \"cpt\" => \"CPT\",\n \"cpt-4\" => \"CPT\",\n \"snomedct\" => \"SNOMED-CT\",\n \"snomed-ct\" => \"SNOMED-CT\",\n \"rxnorm\" ... | [
"0.8122562",
"0.8055236",
"0.57877356",
"0.56129503",
"0.55055535",
"0.526807",
"0.5252389",
"0.52132136",
"0.5210268",
"0.52040267",
"0.51133806",
"0.5072879",
"0.5031887",
"0.4955023",
"0.490896",
"0.48868224",
"0.48181015",
"0.4808359",
"0.4806806",
"0.47753274",
"0.476268... | 0.8026242 | 2 |
Get Ship The user is prompted about the type of ship they want to pilot The user then names their ship and is given a rundown of it | def get_ship(ship_class_arg = nil, ship_name_arg=nil)
unless ship_class_arg && ship_name_arg
printf "FIRST MATE: Captain #{self.name}, what kind of ship is this?\n"
while self.ship == nil
printf "-- Please choose a class of ship from the following options.\n"
puts "| " + Ship.subclasses.join(' | ') + " |"
ship_class = gets.chomp
#Ruby will throw a NameError if we try to call const_get on a bad string
begin
#We still need to check that the name is indeed a type of ship
if Ship.subclasses.include? Object.const_get(ship_class)
self.ship = Object.const_get(ship_class).new
self.ship.captain = self
else
puts "-- Sorry, that class of ship was not found."
end
rescue NameError
puts "-- Sorry, that class of ship was not found."
end
end
#Get the name of the ship
self.ship.get_name
self.ship.report_status
else
self.ship = Object.const_get(ship_class_arg).new
self.ship.captain = self
self.ship.name = ship_name_arg
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_input_to_place(ship)\n\t\tputs \"\"\n\t\tputs \"Place your #{ship.name} (length: #{ship.length})...\"\n\t\tx, y = get_coordinate\n\t\tdirection = get_direction\n\t\treturn [{x: x, y: y}, direction]\n\tend",
"def get_ship_by_ship_id(ship_id_user)\n return UserShip.find_by(:ship_id => ship_id_user).ship... | [
"0.68076473",
"0.6481056",
"0.624608",
"0.61633563",
"0.6144363",
"0.60923386",
"0.60923386",
"0.60432434",
"0.58957744",
"0.5857203",
"0.58281213",
"0.5805428",
"0.57868016",
"0.57836396",
"0.5740101",
"0.5732825",
"0.57216907",
"0.5715721",
"0.56909066",
"0.5690762",
"0.565... | 0.7224335 | 0 |
GET /vicarages GET /vicarages.json | def index
@vicarages = Vicarage.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vitals\n raise UserNotAuthenticated unless access_token\n\n get('records/vitals')\n end",
"def index\n @cages = current_user.cages\n\n respond_to do |format|\n format.json { render json: @cages }\n end\n end",
"def index\n @vacancies = Vacancy.all_vacancies# current_user.vacanc... | [
"0.66836536",
"0.66616005",
"0.66490215",
"0.66050225",
"0.6453333",
"0.6431618",
"0.6334092",
"0.6291732",
"0.6291732",
"0.6287622",
"0.6238363",
"0.6232576",
"0.62299657",
"0.6198003",
"0.6190004",
"0.6184687",
"0.6144711",
"0.6120845",
"0.6109469",
"0.6091756",
"0.608947",... | 0.7630078 | 0 |
GET /vicarages/1 GET /vicarages/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @vicarages = Vicarage.all\n end",
"def vitals\n raise UserNotAuthenticated unless access_token\n\n get('records/vitals')\n end",
"def set_vicarage\n @vicarage = Vicarage.find(params[:id])\n end",
"def index\n @cages = current_user.cages\n\n respond_to do |format|\n f... | [
"0.753827",
"0.6628052",
"0.66049147",
"0.6587223",
"0.65848595",
"0.6577855",
"0.6530069",
"0.65048856",
"0.6491649",
"0.6326059",
"0.62982863",
"0.6288869",
"0.6288869",
"0.62678385",
"0.6250612",
"0.6235334",
"0.6211283",
"0.6204159",
"0.6195074",
"0.6171884",
"0.61647594"... | 0.0 | -1 |
POST /vicarages POST /vicarages.json | def create
@vicarage = Vicarage.new(vicarage_params)
respond_to do |format|
if @vicarage.save
format.html { redirect_to @vicarage, success: 'La Vicaría fue <strong>registrada</strong> exitosamente.' }
format.json { render :show, status: :created, location: @vicarage }
else
format.html { render :new }
format.json { render json: @vicarage.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @vicarages = Vicarage.all\n end",
"def vicarage_params\n params.require(:vicarage).permit(:Name, :managers_id)\n end",
"def create\n @vestimentum = Vestimentum.new(vestimentum_params)\n\n respond_to do |format|\n if @vestimentum.save\n format.html { redirect_to @vestim... | [
"0.6139481",
"0.5851167",
"0.58339053",
"0.57551336",
"0.57540375",
"0.5737517",
"0.5734332",
"0.5733984",
"0.5679506",
"0.566419",
"0.56398666",
"0.5639556",
"0.5611052",
"0.56105006",
"0.5599188",
"0.5586084",
"0.5573076",
"0.55480474",
"0.55351573",
"0.5515732",
"0.551317"... | 0.6324902 | 0 |
PATCH/PUT /vicarages/1 PATCH/PUT /vicarages/1.json | def update
respond_to do |format|
if @vicarage.update(vicarage_params)
format.html { redirect_to @vicarage, success: 'La Vicaría fue <strong>modificada</strong> exitosamente.' }
format.json { render :show, status: :ok, location: @vicarage }
else
format.html { render :edit }
format.json { render json: @vicarage.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n @api_v1_post_vote = PostVote.find(params[:id])\n\n res... | [
"0.62974554",
"0.62444955",
"0.6187228",
"0.618165",
"0.6171038",
"0.61633855",
"0.6161867",
"0.6106517",
"0.6105012",
"0.609331",
"0.609331",
"0.60928583",
"0.60643804",
"0.6047581",
"0.60459626",
"0.6043728",
"0.60352486",
"0.6026001",
"0.60226023",
"0.6021671",
"0.6006367"... | 0.6584362 | 0 |
DELETE /vicarages/1 DELETE /vicarages/1.json | def destroy
@vicarage.destroy
respond_to do |format|
format.html { redirect_to vicarages_url, success: 'La Vicaría fue <strong>eliminada</strong> exitosamente.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @vacancy = Vacancy.find(params[:id])\n @vacancy.destroy\n\n respond_to do |format|\n format.html { redirect_to vacancies_url }\n format.json { head :no_content }\n end\n en... | [
"0.7114967",
"0.7102818",
"0.705227",
"0.69948196",
"0.69650114",
"0.69585997",
"0.6944309",
"0.69412225",
"0.6922085",
"0.69157434",
"0.69112563",
"0.6898171",
"0.6897058",
"0.6892828",
"0.6892304",
"0.6879796",
"0.6879796",
"0.6879539",
"0.68690777",
"0.6853215",
"0.6847646... | 0.7098011 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_vicarage
@vicarage = Vicarage.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def vicarage_params
params.require(:vicarage).permit(:Name, :managers_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
Creates or updates a resource. | def save
update({})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_resource object\n object.save\n end",
"def create_resource(object)\n object.save\n end",
"def update_resource(resource, attributes)\n resource.attributes = attributes\n resource.save\n resource\n end",
"def save_resource\n resource.save\n end",
"def add(... | [
"0.7610451",
"0.73622066",
"0.72340345",
"0.71839917",
"0.7148188",
"0.69271713",
"0.6923017",
"0.6867716",
"0.68367285",
"0.6762359",
"0.6752489",
"0.6667134",
"0.66656023",
"0.66349393",
"0.6631788",
"0.659067",
"0.6585874",
"0.65452224",
"0.6541691",
"0.65357554",
"0.65316... | 0.0 | -1 |
Returns true for resources that behave like an array | def array?
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array?\n false\n end",
"def returns_array?\n true\n end",
"def returns_array?\n true\n end",
"def returns_array?\n false\n end",
"def returns_array?\n false\n end",
"def returns_array?\n false\n end",
"def array?(item)\n ite... | [
"0.7287177",
"0.7043768",
"0.69712514",
"0.6965632",
"0.6965632",
"0.6913455",
"0.6846586",
"0.68010783",
"0.67592716",
"0.6724545",
"0.65788335",
"0.6558414",
"0.6540023",
"0.653822",
"0.6529569",
"0.65236795",
"0.643524",
"0.6390467",
"0.63739914",
"0.6365299",
"0.6315364",... | 0.7255584 | 1 |
By default, fields come flattened in the current locale. This is different for syncs | def nested_locale_fields?
# rubocop:disable Style/DoubleNegation
!!@nested_locale_fields
# rubocop:enable Style/DoubleNegation
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fields_for_query\n self.class.fields_coercions.keys.each_with_object({}) do |field_name, results|\n results[field_name] = @fields.each_with_object({}) do |(locale, fields), field_results|\n field_results[locale] = get_value_from(fields, field_name)\n end\n end\n ... | [
"0.6206649",
"0.6206649",
"0.610423",
"0.5944875",
"0.59296626",
"0.59296626",
"0.57988274",
"0.57988274",
"0.57988274",
"0.57168967",
"0.5714177",
"0.5679722",
"0.5661977",
"0.56419057",
"0.56054455",
"0.5594809",
"0.5578505",
"0.55685985",
"0.5568057",
"0.55503464",
"0.5546... | 0.53607416 | 38 |
Resources that don't include SystemProperties return nil for sys | def sys
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expected_local_properties\n {\n 'enabled' => 'true',\n 'async-replication' => 'true',\n 'availability-enabled' => 'true',\n 'directory-deployed' => 'true',\n 'context-root' => '/myapp',\n 'location' => \"file:#{self.location_as_dir}/\",\n 'property.defaultAppName' => 'myap... | [
"0.58703196",
"0.575957",
"0.5530705",
"0.545154",
"0.5379882",
"0.5362566",
"0.53424984",
"0.5329514",
"0.5315813",
"0.5294226",
"0.52655923",
"0.52228814",
"0.5217513",
"0.5209448",
"0.5209448",
"0.51672536",
"0.51565117",
"0.5144707",
"0.51439273",
"0.51333153",
"0.5127393... | 0.5421696 | 4 |
Resources that don't include Fields or AssetFields return nil for fields | def fields
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_field_deserializers()\n return super.merge({\n \"resourceId\" => lambda {|n| @resource_id = n.get_string_value() },\n \"resourceName\" => lambda {|n| @resource_name = n.get_string_value() },\n \"resourceType\" => lambda {|n| @resource_... | [
"0.63337797",
"0.5906204",
"0.58706826",
"0.58599544",
"0.584018",
"0.5734528",
"0.5726361",
"0.5713535",
"0.5702535",
"0.5652184",
"0.5614438",
"0.5600042",
"0.5597079",
"0.55841076",
"0.55790764",
"0.5576986",
"0.5568455",
"0.5553374",
"0.5512703",
"0.5495264",
"0.5472933",... | 0.64128834 | 0 |
Shared instance of the API client | def client
Contentful::Management::Client.shared_instance
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client\r\n @client ||= APIController.new config\r\n end",
"def api_client\n self.class.api_client\n end",
"def client\n @client ||= Client.new(configuration)\n end",
"def instance\n @instance ||= Artsy::Client::Instance.new(options)\n end",
"def api_c... | [
"0.8125511",
"0.8014103",
"0.7446526",
"0.74139553",
"0.73478997",
"0.73442525",
"0.7337053",
"0.7319985",
"0.7284285",
"0.72401106",
"0.72299707",
"0.7155619",
"0.714666",
"0.71432656",
"0.71432656",
"0.7126933",
"0.711525",
"0.70991236",
"0.7073043",
"0.7070854",
"0.7061037... | 0.65489644 | 72 |
Returns the Environment ID | def environment_id
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def environment_id\n id\n end",
"def get_environment_id(client, name)\n\n self.info(\"Getting environment id from name '#{name}'\")\n \n message = { \"username\" => @resource[:connection]['username'], \"password\" => @resource[:connection]['password'], \"mainType\" => \"Environment\", ... | [
"0.88774675",
"0.7477829",
"0.70253795",
"0.6537735",
"0.65218514",
"0.6492551",
"0.6437663",
"0.63625264",
"0.6329534",
"0.6322968",
"0.62675273",
"0.6249405",
"0.6212033",
"0.6166963",
"0.61639905",
"0.6163196",
"0.6132946",
"0.60559934",
"0.60352176",
"0.60234153",
"0.5925... | 0.78839684 | 1 |
Get default_locale from client | def default_locale
client.default_locale
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_locale\n FastGettext.available_locales.first\n end",
"def default_locale\n @default_locale ||= self.languages.get_default.code.to_sym\n end",
"def default_locale\n return nil unless localized?\n u_lc = I18n.locale.to_sym\n available_locales.include?(u_lc) ? u_lc : avail... | [
"0.83433855",
"0.8173862",
"0.8166773",
"0.8095743",
"0.7869589",
"0.78432095",
"0.77822816",
"0.7604532",
"0.74338615",
"0.7410458",
"0.7392186",
"0.7349439",
"0.73442006",
"0.73125035",
"0.71855545",
"0.71363467",
"0.7124969",
"0.70983094",
"0.70591426",
"0.7023105",
"0.700... | 0.8771306 | 0 |
Gets a collection of resources. | def all(client, space_id, environment_id = nil, parameters = {}, organization_id = nil)
ResourceRequester.new(client, self).all(
{ space_id: space_id, environment_id: environment_id, organization_id: organization_id }, parameters
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collection\n resource_class.all\n end",
"def resources\n return @resources\n end",
"def resources\n return @resources\n end",
"def resources\n return @resources\n end",
"def resources\n nodeset = query_r... | [
"0.78397506",
"0.76850986",
"0.76850986",
"0.76850986",
"0.76769733",
"0.76571435",
"0.7531514",
"0.7418125",
"0.7414193",
"0.7375839",
"0.71700495",
"0.7143491",
"0.71262515",
"0.7115362",
"0.70980287",
"0.70672417",
"0.7055526",
"0.69822836",
"0.6971924",
"0.6957113",
"0.69... | 0.0 | -1 |
Gets a specific resource. | def find(client, space_id, environment_id = nil, resource_id = nil, organization_id = nil)
ResourceRequester.new(client, self).find(space_id: space_id, environment_id: environment_id,
resource_id: resource_id, organization_id: organization_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_resource\n execute(resource_path, method: :get)\n end",
"def find_resource\n get params[:resource_path]\n end",
"def resource\n klass, param = resource_class\n klass&.find(params[param.to_sym])\n end",
"def get(resource, id)\n Api.new.get(resource, id)\n end... | [
"0.8621642",
"0.8021446",
"0.7726461",
"0.7589102",
"0.7496325",
"0.7455254",
"0.7437639",
"0.7437639",
"0.74322623",
"0.74322623",
"0.74322623",
"0.74223286",
"0.7352895",
"0.7344348",
"0.73429024",
"0.73429024",
"0.73119676",
"0.7305421",
"0.7294014",
"0.7272717",
"0.723649... | 0.0 | -1 |
By default, fields come flattened in the current locale. This is different for sync | def nested_locale_fields?
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fields_for_query\n self.class.fields_coercions.keys.each_with_object({}) do |field_name, results|\n results[field_name] = @fields.each_with_object({}) do |(locale, fields), field_results|\n field_results[locale] = get_value_from(fields, field_name)\n end\n end\n ... | [
"0.6290221",
"0.6290221",
"0.6155563",
"0.6048918",
"0.6048918",
"0.59363073",
"0.59363073",
"0.59363073",
"0.5773722",
"0.5760829",
"0.57599807",
"0.5757715",
"0.5743455",
"0.56845134",
"0.56750476",
"0.56325203",
"0.56025636",
"0.5602253",
"0.55998",
"0.559405",
"0.5555716"... | 0.6006492 | 5 |
Defines which properties of a resource your class expects Define them in :camelCase, they will be available as snake_cased methods You can pass in a second "type" argument: If it is a class, it will be initialized for the property Symbols are looked up in the COERCION constant for a lambda that defines a type conversion to apply Note: This second argument is not meant for contentful subresources, but for structured objects (like locales in a space) Subresources are handled by the resource builder | def property(name, property_class = nil)
property_coercions[name.to_sym] = property_class
accessor_name = Contentful::Management::Support.snakify(name)
define_method accessor_name do
properties[name.to_sym]
end
define_method "#{accessor_name}=" do |value|
properties[name.to_sym] = value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mk_resource_methods\n [resource_type.validproperties, resource_type.parameters].flatten.each do |attr|\n attr = symbolize(attr)\n\n # Generate attr_reader\n define_method(attr) do\n if @property_hash[attr]\n @property_hash[attr]\n elsif defined? @resource\... | [
"0.6480117",
"0.6390359",
"0.61742175",
"0.5983105",
"0.58316755",
"0.58135504",
"0.5789066",
"0.57500446",
"0.5738464",
"0.57084864",
"0.5703486",
"0.56794393",
"0.56597924",
"0.5652623",
"0.56136465",
"0.55804104",
"0.5569616",
"0.55457276",
"0.549106",
"0.5489655",
"0.5483... | 0.0 | -1 |
Ensure inherited classes pick up coercions | def update_coercions!
return if @coercions_updated
if superclass.respond_to? :property_coercions
@property_coercions = superclass.property_coercions.dup.merge(@property_coercions || {})
end
if superclass.respond_to? :sys_coercions
@sys_coercions = superclass.sys_coercions.dup.merge(@sys_coercions || {})
end
if superclass.respond_to? :fields_coercions
@fields_coercions = superclass.fields_coercions.dup.merge(@fields_coercions || {})
end
@coercions_updated = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coerce(other); end",
"def convert\n raise \"The convert method must be implemented by subclass!\"\n end",
"def strict_value_coercions; end",
"def inherited(klass); end",
"def inherited(klass); end",
"def inherited(subclass); end",
"def inherited(base); end",
"def inherited(subclass)\n... | [
"0.65102464",
"0.644977",
"0.6322858",
"0.6184876",
"0.6184876",
"0.6145347",
"0.6097982",
"0.59096855",
"0.5883548",
"0.5812501",
"0.5751588",
"0.5737549",
"0.5687527",
"0.56507003",
"0.56200624",
"0.5611901",
"0.56023496",
"0.56023496",
"0.55925745",
"0.5589005",
"0.5573787... | 0.6694255 | 0 |
Determine stack state based on last operation information | def determine_state(operation)
prefix = case operation[:operationType]
when 'insert'
'create'
when 'update'
'update'
when 'delete'
'delete'
end
suffix = case operation[:status]
when 'RUNNING', 'PENDING'
'in_progress'
when 'DONE'
'complete'
end
if(operation[:error])
suffix = 'failed'
end
if(prefix.nil? || suffix.nil?)
:unknown
else
"#{prefix}_#{suffix}".to_sym
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore\r\n @status = @stack.shift if @stack.size > 0\r\n end",
"def __stack\n @stack\n end",
"def peek_current_state\n peek_state.last || @current_state\n end",
"def stack_status\n data[:stack_status]\n end",
"def stack\n @stack\n end",
"def po... | [
"0.6681733",
"0.6413173",
"0.6393771",
"0.6384595",
"0.6365936",
"0.6310897",
"0.6307616",
"0.6307616",
"0.6288879",
"0.6288879",
"0.6230169",
"0.6177825",
"0.6147348",
"0.6147348",
"0.6145721",
"0.61402655",
"0.61260456",
"0.610707",
"0.6079533",
"0.6071195",
"0.6063665",
... | 0.5721521 | 60 |
Create stack data hash from information | def basic_stack_data_format(info)
info = info.to_smash
Smash.new(
:id => info[:id],
:created => Time.parse(info[:insertTime]),
:updated => Time.parse(info.fetch(:operation, :endTime, info.fetch(:operation, :startTime, info[:insertTime]))),
:description => info[:description],
:name => info[:name],
:state => determine_state(info.fetch(:operation, {})),
:status => determine_state(info.fetch(:operation, {})).to_s.split('_').map(&:capitalize).join(' '),
:custom => info
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash\n stack.inject { |h, layer| Util.deep_merge h, layer }\n end",
"def hash\n [domain, message, stack, type].hash\n end",
"def hash_stacks(arr)\n return Hash[arr.map { |x| [x.stack_name, x] }]\n end",
"def hash\n shasum.hash\n end",
"def hash\n shasum.hash\... | [
"0.67521703",
"0.64674425",
"0.6383291",
"0.6177991",
"0.6177991",
"0.6177991",
"0.6048297",
"0.60006744",
"0.59786034",
"0.5933204",
"0.5914581",
"0.5839315",
"0.57952595",
"0.5750576",
"0.57385886",
"0.57385886",
"0.57385886",
"0.57385886",
"0.57385886",
"0.57385886",
"0.57... | 0.6073098 | 6 |
Fetch the stack template | def stack_template_load(stack)
if(stack.persisted?)
result = request(
:endpoint => stack.custom.fetch(:manifest, stack.custom.get(:update, :manifest))
)
cache_template = stack.template = template_data_format(result[:body])
stack.custom = stack.custom.merge(result[:body])
if(stack.custom['expandedConfig'])
stack.custom['expandedConfig'] = YAML.load(stack.custom['expandedConfig']).to_smash
end
if(stack.custom['layout'])
stack.custom['layout'] = YAML.load(stack.custom['layout']).to_smash
end
stack.valid_state
cache_template
else
Smash.new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_template(template); end",
"def get_template\n @template\n end",
"def fetch_template\n template_body = fetch_template_from_local_cache\n template_body ||= fetch_template_from_redis\n template_body ||= fetch_remote_template_and_store\n template_body ||= store_template_to_local_cache( self... | [
"0.7101934",
"0.70465076",
"0.68973947",
"0.6755051",
"0.6571939",
"0.655169",
"0.65463096",
"0.6540473",
"0.6535762",
"0.65352464",
"0.64819604",
"0.6416082",
"0.64151996",
"0.6405743",
"0.6394707",
"0.63887113",
"0.63826925",
"0.63473773",
"0.6345992",
"0.63356036",
"0.6303... | 0.73864704 | 0 |
Pack template data for shipping to API | def template_data_unformat(data)
Hash.new.tap do |result|
if(v = data.to_smash.get(:config, :content))
result[:config] = {
:content => yamlize(v)
}
end
if(data[:imports])
result[:imports] = data[:imports].map do |item|
Smash.new(
:name => item['name'],
:content => yamlize(item['content'])
)
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pack_template\n selfclass.pack_template\n end",
"def pack(generate = false)\n self.class.template.pack(self, generate)\n end",
"def pack\n end",
"def pack_template\n if self.to_s =~ /^.*<(.*):0x.*/\n clsname = $1\n else\n clsname = self.to_s\n ... | [
"0.700584",
"0.66302973",
"0.6198071",
"0.60476583",
"0.58784616",
"0.58773434",
"0.5842849",
"0.5734649",
"0.569787",
"0.56565857",
"0.5563788",
"0.55553824",
"0.55528766",
"0.554485",
"0.5512602",
"0.55092084",
"0.54714894",
"0.54681224",
"0.5465646",
"0.5441295",
"0.542447... | 0.57666487 | 7 |
Convert value to YAML if not string | def yamlize(value)
unless(value.is_a?(String))
if(value.is_a?(Hash) && value.respond_to?(:to_hash))
value = value.to_hash
end
value.to_yaml(:header => true)
else
value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode(value)\n value.to_yaml\n end",
"def encode(value)\n value.to_yaml\n end",
"def convert_value\n # Do nothing if value has not changed\n return true unless value_changed?\n # Cast the value and return success\n return parse_string_value(@uncast_value) if @uncast_value.is_a? String\... | [
"0.7177733",
"0.7177733",
"0.6996034",
"0.68543994",
"0.66615325",
"0.64646274",
"0.6410558",
"0.64088476",
"0.6400503",
"0.6400503",
"0.62958807",
"0.6258902",
"0.6179016",
"0.6161546",
"0.6064578",
"0.6059684",
"0.6043071",
"0.6043071",
"0.60403097",
"0.60242605",
"0.600048... | 0.72765696 | 0 |
Unpack received template data for local model instance | def template_data_format(data)
data = data.to_smash
Smash.new.tap do |result|
result[:config] = data.fetch(:config, Smash.new)
result[:imports] = data.fetch(:imports, []).map do |item|
begin
Smash.new(
:name => item[:name],
:content => YAML.load(item[:content])
)
rescue
item
end
end
if(result.get(:config, :content))
result[:config][:content] = YAML.load(result[:config][:content]) || Smash.new
else
result[:config][:content] = Smash.new
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def template_data_unformat(data)\n Hash.new.tap do |result|\n if(v = data.to_smash.get(:config, :content))\n result[:config] = {\n :content => yamlize(v)\n }\n end\n if(data[:imports])\n result[:imports] = data[:imports... | [
"0.5973272",
"0.58152825",
"0.5778815",
"0.5770314",
"0.5763712",
"0.55779016",
"0.5568618",
"0.5549425",
"0.54952604",
"0.54679984",
"0.54392934",
"0.5435606",
"0.5424163",
"0.54198754",
"0.5418419",
"0.54007417",
"0.5376892",
"0.53504",
"0.5336779",
"0.5322911",
"0.532271",... | 0.52890575 | 21 |
Reload the stack data | def stack_reload(stack)
if(stack.persisted?)
result = request(
:path => "global/deployments/#{stack.name}"
)
deploy = result[:body]
stack.load_data(basic_stack_data_format(deploy)).valid_state
stack_template_load(stack)
set_outputs_if_available(stack)
end
stack
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stack_reload(stack)\n if(stack.persisted?)\n result = request(\n :method => :get,\n :path => \"/stacks/#{stack.name}/#{stack.id}\",\n :expects => 200\n )\n stk = result.get(:body, :stack)\n stack.load_data(\n ... | [
"0.7895699",
"0.782925",
"0.7727556",
"0.76066",
"0.72927064",
"0.716917",
"0.6816599",
"0.670095",
"0.6670017",
"0.6572085",
"0.6552504",
"0.65264034",
"0.6504444",
"0.6504444",
"0.6504444",
"0.6504444",
"0.6504444",
"0.6504444",
"0.6504444",
"0.6478038",
"0.6468303",
"0.6... | 0.73778516 | 4 |
Set outputs into stack instance | def set_outputs_if_available(stack)
outputs = extract_outputs(stack.custom.fetch(:layout, {}))
unless(outputs.empty?)
stack.outputs = outputs
stack.valid_state
true
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def outputs\n @stack.outputs\n end",
"def _stack_output(stack_name, output_name)\n __t_stringish(stack_name)\n __t_stringish(output_name)\n _ref(stack_name)._set(output_name)\n end",
"def initialize\n @in_stack = []\n @out_stack = []\n end",
"def outputs\n... | [
"0.6914096",
"0.6784802",
"0.6387974",
"0.5888659",
"0.58617836",
"0.58280265",
"0.5801298",
"0.5799265",
"0.57409495",
"0.5721926",
"0.56699175",
"0.56632257",
"0.56632257",
"0.5657702",
"0.5631712",
"0.55783576",
"0.5575174",
"0.55239403",
"0.5501004",
"0.54891175",
"0.5462... | 0.6232666 | 3 |
Extract outputs from stack hash | def extract_outputs(stack_hash)
outputs = []
if(stack_hash[:outputs])
outputs += stack_hash[:outputs].map do |output|
Smash.new(:key => output[:name], :value => output[:finalValue])
end
end
stack_hash.fetch(:resources, []).each do |resource|
outputs += extract_outputs(resource)
end
outputs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_stack_outputs(name)\n list = client.describe_stacks stack_name: name\n raise StandardError, \"stack: '#{name}' does not exist\" if list.stacks.empty?\n\n outputs = {}\n list.stacks.first.outputs.each do |x|\n outputs[x.output_key] = x.output_value\n end\n\n ... | [
"0.6308744",
"0.627303",
"0.6010338",
"0.59049094",
"0.5800646",
"0.5702913",
"0.5597827",
"0.55602944",
"0.5459044",
"0.5459044",
"0.5459044",
"0.54110825",
"0.5343382",
"0.5333893",
"0.5331919",
"0.5319655",
"0.53183067",
"0.5294882",
"0.5281151",
"0.52662575",
"0.5262031",... | 0.81391597 | 0 |
Fetch all stack resources | def resource_all(stack)
request(
:path => "global/deployments/#{stack.name}/resources"
).fetch('body', 'resources', []).map do |resource|
Stack::Resource.new(stack,
:id => resource[:id],
:type => resource[:type],
:name => resource[:name],
:logical_id => resource[:name],
:created => Time.parse(resource[:insertTime]),
:updated => resource[:updateTime] ? Time.parse(resource[:updateTime]) : nil,
:state => :create_complete,
:status => 'OK',
:status_reason => resource.fetch(:warnings, []).map{|w| w[:message]}.join(' ')
).valid_state
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_all(stack)\n result = request(\n :method => :get,\n :path => \"/stacks/#{stack.name}/#{stack.id}/resources\",\n :expects => 200\n )\n result.fetch(:body, :resources, []).map do |resource|\n Stack::Resource.new(\n stack... | [
"0.795353",
"0.78062457",
"0.75701094",
"0.71294576",
"0.6813014",
"0.65862066",
"0.6554737",
"0.6542657",
"0.64352626",
"0.6412328",
"0.639027",
"0.6345106",
"0.6345106",
"0.6345106",
"0.6318146",
"0.6285333",
"0.62513447",
"0.6229829",
"0.6191969",
"0.6177501",
"0.6159829",... | 0.7636058 | 2 |
Returns a resized image for display. | def display_image
image.variant(resize_to_limit: [500, 500])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_resized_image\n create_image do |xfrm|\n if size\n MiniMagick::Tool::Convert.new do |cmd|\n cmd << xfrm.path # input\n cmd.flatten\n cmd.resize(size)\n cmd << xfrm.path # output\n end\n end\n end\n ... | [
"0.74281555",
"0.7337605",
"0.7276508",
"0.72498614",
"0.71668667",
"0.6908238",
"0.6732925",
"0.67188084",
"0.66568625",
"0.66387683",
"0.65469444",
"0.6546263",
"0.65405697",
"0.6535587",
"0.6528795",
"0.6500281",
"0.6499397",
"0.6488022",
"0.6481025",
"0.6469561",
"0.64159... | 0.7291966 | 7 |
check if the collection accepts a given mime type; watch out for wildcards | def accept?(mime_type)
if mime_type =~ @@mime_re
p1, p2 = $1, $2
else
return false # WTF?
end
@accept.each do |pat|
pat = pat.to_s # working around REXML ticket 164
if pat =~ @@mime_re
if ($1 == p1 || $1 == "*") && ($2 == p2 || $2 == "*")
return true
elsif ((pat == Names::AtomMediaType && mime_type == Names::AtomFeedMediaType) ||
(pat == Names::AtomFeedMediaType && mime_type == Names::AtomMediaType))
return true
end
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accept? ctype\n unless self.class.force_mime_type\n ctype = Regexp.escape ctype\n ctype = ctype.gsub(\"\\\\*\", \"[^/]*\")\n matcher = %r{#{ctype}}\n end\n\n !!self.class.mime_types.find do |mt|\n if matcher\n mt =~ matcher\n else\n mt == ctype\n end\n en... | [
"0.77527916",
"0.7095487",
"0.7025823",
"0.7024764",
"0.6996454",
"0.6996454",
"0.68388236",
"0.67528176",
"0.6731191",
"0.6707233",
"0.66846454",
"0.6659487",
"0.6642042",
"0.66240144",
"0.66003674",
"0.656797",
"0.65612775",
"0.65606403",
"0.6481699",
"0.6474869",
"0.642912... | 0.7534508 | 1 |
the name is supposed to suggest multiple instances of "categories" | def catses
REXML::XPath.match(@xml, './app:categories', Names::XmlNamespaces)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def categories\n add_to_query restrict_kind: 'category'\n end",
"def category_candidates(category)\n return @category_cache[category] unless @category_cache[category].nil?\n # from whole name singularized\n candidates = []\n decorated_category = Cyclopedio::Syntax::NameDecorat... | [
"0.71038395",
"0.70917416",
"0.6982192",
"0.69171596",
"0.6899555",
"0.6799439",
"0.6772932",
"0.67318565",
"0.6705984",
"0.66909087",
"0.66468537",
"0.6617299",
"0.6603744",
"0.6592889",
"0.65879345",
"0.65614706",
"0.65506774",
"0.6541382",
"0.65393263",
"0.6536403",
"0.653... | 0.0 | -1 |
GET /applicants GET /applicants.xml | def index
#@applicants = Applicant.paginate(:per_page => 10, :page => params[:page])
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @applicants }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @applicants = get_applicants if params[:applicants]\n end",
"def index\n @applicants = current_user.applicants rescue nil\n end",
"def index\n @applicants = Applicant.all\n end",
"def index\n @applicants = Applicant.all\n end",
"def index\n #@applicants = ApplicantUser.all.pag... | [
"0.7678585",
"0.7322472",
"0.6842018",
"0.6842018",
"0.658738",
"0.65523094",
"0.617821",
"0.6141633",
"0.6096072",
"0.60434496",
"0.6036075",
"0.6031986",
"0.59656745",
"0.59614336",
"0.5953296",
"0.5905208",
"0.5861879",
"0.58611906",
"0.5843751",
"0.58311975",
"0.5795912",... | 0.6720587 | 4 |
GET /applicants/1 GET /applicants/1.xml | def show
# security check
@job = Job.find(params[:id], :conditions => ["employer_id = ?", current_user.employer.id])
(@job.employer_id == current_user.employer.id).to_console
if @job.employer_id == current_user.employer.id
@applicants = Applicant.paginate(:conditions => ["job_id = ?", @job.id], :per_page => 10, :page => params[:page])
else
render :text => "You do not own that listing"
end
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @applicant }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @applicants = get_applicants if params[:applicants]\n end",
"def index\n #@applicants = Applicant.paginate(:per_page => 10, :page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @applicants }\n end\n end",
"def index\... | [
"0.7305356",
"0.69398254",
"0.6817581",
"0.6709612",
"0.6709612",
"0.6514056",
"0.6399076",
"0.63195497",
"0.6232536",
"0.62241703",
"0.61885494",
"0.6004993",
"0.599749",
"0.5975479",
"0.59644926",
"0.5893432",
"0.58829457",
"0.58297455",
"0.5786293",
"0.57731545",
"0.576751... | 0.56490815 | 38 |
Failing to get your bid is referred to as 'going set'. | def got_set
return self.bid != self.tricks
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bid\n self.bids.last.nil? ? Bid.new : self.bids.last\n end",
"def last_bid\n self.bids.last rescue nil\n end",
"def completed_bid\n completed_response.present? ? completed_response.bid : nil\n end",
"def give_bid(auction, bid)\r\n if Time.now > auction.due_date\r\n raise TradeExce... | [
"0.6487028",
"0.6323811",
"0.6147629",
"0.6105298",
"0.6056604",
"0.6041588",
"0.59762716",
"0.5968541",
"0.5896258",
"0.5883508",
"0.58788943",
"0.5874227",
"0.5859775",
"0.583372",
"0.57465434",
"0.5743956",
"0.57323456",
"0.5723878",
"0.5690312",
"0.56802124",
"0.56180745"... | 0.67868507 | 0 |
A player gets 1 point for every trick taken. Getting your bid gives you an automatic 10 bonus points. | def hand_score
score = self.tricks
if !self.got_set
score += 10
end
return score
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def won_with_points\n self.chips += 2 * self.bet_chips\n self.is_complete = true\n \"#{name}'s point is bigger than dealer! #{name} get extra one bet. Win for #{name}\"\n end",
"def bid\n return starting_bid unless prev_bid\n if prev_bid.total >= all_dice_count/(2*expected_prob) && prev_b... | [
"0.6678229",
"0.66671795",
"0.6557542",
"0.6357201",
"0.631796",
"0.6284298",
"0.62798786",
"0.61599845",
"0.6157859",
"0.613869",
"0.61082053",
"0.61082053",
"0.60540015",
"0.6048455",
"0.6048455",
"0.6048455",
"0.6048455",
"0.6048455",
"0.6048455",
"0.6048455",
"0.6048455",... | 0.5595402 | 84 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.