query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Never trust parameters from the scary internet, only allow the white list through. | def gmap_params
params.require(:bank).permit(:latitude, :longitude, :address)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Provides operations to manage the defaultManagedAppProtections property of the microsoft.graph.deviceAppManagement entity. | def default_managed_app_protections()
return MicrosoftGraph::DeviceAppManagement::DefaultManagedAppProtections::DefaultManagedAppProtectionsRequestBuilder.new(@path_parameters, @request_adapter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_managed_app_protections=(value)\n @default_managed_app_protections = value\n end",
"def default_managed_app_protections\n return @default_managed_app_protections\n end",
"def ios_managed_app_protections()\n return MicrosoftGraph::De... | [
"0.77753145",
"0.72597766",
"0.6829432",
"0.6721182",
"0.64629275",
"0.6291577",
"0.6066823",
"0.6062792",
"0.5831713",
"0.5815131",
"0.57798344",
"0.5612159",
"0.55968827",
"0.5468354",
"0.545257",
"0.541068",
"0.5343736",
"0.5313879",
"0.53048956",
"0.52950567",
"0.52796584... | 0.8005835 | 0 |
Provides operations to manage the iosManagedAppProtections property of the microsoft.graph.deviceAppManagement entity. | def ios_managed_app_protections()
return MicrosoftGraph::DeviceAppManagement::IosManagedAppProtections::IosManagedAppProtectionsRequestBuilder.new(@path_parameters, @request_adapter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ios_managed_app_protections=(value)\n @ios_managed_app_protections = value\n end",
"def ios_managed_app_protections\n return @ios_managed_app_protections\n end",
"def default_managed_app_protections()\n return MicrosoftGraph::DeviceAppManag... | [
"0.7477903",
"0.69932246",
"0.6872003",
"0.6630619",
"0.64953953",
"0.6470286",
"0.6329817",
"0.6088134",
"0.6011512",
"0.5970006",
"0.5940825",
"0.57495624",
"0.5685943",
"0.5636086",
"0.56063616",
"0.5560754",
"0.5548923",
"0.55247676",
"0.55194473",
"0.5437535",
"0.5385764... | 0.78540516 | 0 |
Provides operations to manage the managedAppPolicies property of the microsoft.graph.deviceAppManagement entity. | def managed_app_policies()
return MicrosoftGraph::DeviceAppManagement::ManagedAppPolicies::ManagedAppPoliciesRequestBuilder.new(@path_parameters, @request_adapter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def managed_app_policies=(value)\n @managed_app_policies = value\n end",
"def app_management_policies=(value)\n @app_management_policies = value\n end",
"def managed_app_policies\n return @managed_app_policies\n end",
"def managed_... | [
"0.75470936",
"0.69188136",
"0.6849626",
"0.658735",
"0.63462585",
"0.5977279",
"0.5651906",
"0.5556686",
"0.5510073",
"0.54415226",
"0.5242824",
"0.52209496",
"0.51883256",
"0.51432425",
"0.51116073",
"0.50694996",
"0.50259125",
"0.5020367",
"0.4961551",
"0.49563906",
"0.494... | 0.77995986 | 0 |
Provides operations to manage the managedAppRegistrations property of the microsoft.graph.deviceAppManagement entity. | def managed_app_registrations()
return MicrosoftGraph::DeviceAppManagement::ManagedAppRegistrations::ManagedAppRegistrationsRequestBuilder.new(@path_parameters, @request_adapter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def managed_app_registrations=(value)\n @managed_app_registrations = value\n end",
"def managed_app_registrations\n return @managed_app_registrations\n end",
"def managed_apps=(value)\n @managed_apps = value\n end",
"def device_app... | [
"0.72985137",
"0.67457193",
"0.6265421",
"0.6120318",
"0.5852492",
"0.5804979",
"0.57139933",
"0.55794626",
"0.5397568",
"0.5307091",
"0.5282389",
"0.5274645",
"0.5209892",
"0.5108425",
"0.50594586",
"0.50440323",
"0.49683988",
"0.49683988",
"0.49335074",
"0.4924272",
"0.4843... | 0.7485382 | 0 |
Provides operations to manage the managedAppStatuses property of the microsoft.graph.deviceAppManagement entity. | def managed_app_statuses()
return MicrosoftGraph::DeviceAppManagement::ManagedAppStatuses::ManagedAppStatusesRequestBuilder.new(@path_parameters, @request_adapter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def managed_app_statuses=(value)\n @managed_app_statuses = value\n end",
"def managed_app_statuses\n return @managed_app_statuses\n end",
"def managed_apps=(value)\n @managed_apps = value\n end",
"def managed_apps\n ... | [
"0.79606086",
"0.72728515",
"0.63220656",
"0.56817997",
"0.5501011",
"0.5481292",
"0.5354721",
"0.5318809",
"0.52537566",
"0.5229585",
"0.5186789",
"0.51442635",
"0.5122658",
"0.51043147",
"0.50992763",
"0.50816673",
"0.5009185",
"0.49941427",
"0.4993908",
"0.49923635",
"0.49... | 0.7845098 | 1 |
Provides operations to manage the managedEBooks property of the microsoft.graph.deviceAppManagement entity. | def managed_e_books()
return MicrosoftGraph::DeviceAppManagement::ManagedEBooks::ManagedEBooksRequestBuilder.new(@path_parameters, @request_adapter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def managed_e_books=(value)\n @managed_e_books = value\n end",
"def managed_apps=(value)\n @managed_apps = value\n end",
"def managed_devices=(value)\n @managed_devices = value\n end",
"def managed_e_books\n return @... | [
"0.6486972",
"0.6339535",
"0.6086713",
"0.59717584",
"0.57540375",
"0.5637973",
"0.5522624",
"0.54124457",
"0.53652656",
"0.5345044",
"0.5313149",
"0.5286193",
"0.526265",
"0.522382",
"0.51898265",
"0.5176836",
"0.51441675",
"0.5120621",
"0.5119191",
"0.51069444",
"0.5078245"... | 0.69566834 | 0 |
Provides operations to manage the mdmWindowsInformationProtectionPolicies property of the microsoft.graph.deviceAppManagement entity. | def mdm_windows_information_protection_policies()
return MicrosoftGraph::DeviceAppManagement::MdmWindowsInformationProtectionPolicies::MdmWindowsInformationProtectionPoliciesRequestBuilder.new(@path_parameters, @request_adapter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mdm_windows_information_protection_policies=(value)\n @mdm_windows_information_protection_policies = value\n end",
"def windows_information_protection_policies()\n return MicrosoftGraph::DeviceAppManagement::WindowsInformationProtectionPolicies::WindowsInformationProt... | [
"0.7528585",
"0.71643025",
"0.71293247",
"0.6655285",
"0.62881017",
"0.61900556",
"0.6021546",
"0.59574395",
"0.5909645",
"0.5811215",
"0.5615959",
"0.5498525",
"0.5464466",
"0.5408088",
"0.5201753",
"0.51493996",
"0.5114892",
"0.49813446",
"0.4949016",
"0.4862762",
"0.485927... | 0.7908284 | 0 |
Provides operations to manage the mobileAppCategories property of the microsoft.graph.deviceAppManagement entity. | def mobile_app_categories()
return MicrosoftGraph::DeviceAppManagement::MobileAppCategories::MobileAppCategoriesRequestBuilder.new(@path_parameters, @request_adapter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mobile_app_categories=(value)\n @mobile_app_categories = value\n end",
"def mobile_app_categories\n return @mobile_app_categories\n end",
"def mx_l7_application_categories\r\n MXL7ApplicationCategoriesController.instance\r\n end",
"def device_ca... | [
"0.7375698",
"0.6684424",
"0.58831906",
"0.5819288",
"0.5618737",
"0.5590688",
"0.5517008",
"0.5508222",
"0.53401375",
"0.53401375",
"0.53374296",
"0.51919377",
"0.5146399",
"0.5146399",
"0.5131816",
"0.5037006",
"0.50210446",
"0.5013232",
"0.49747172",
"0.49650228",
"0.49510... | 0.74035686 | 0 |
Provides operations to manage the mobileAppConfigurations property of the microsoft.graph.deviceAppManagement entity. | def mobile_app_configurations()
return MicrosoftGraph::DeviceAppManagement::MobileAppConfigurations::MobileAppConfigurationsRequestBuilder.new(@path_parameters, @request_adapter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mobile_app_configurations=(value)\n @mobile_app_configurations = value\n end",
"def targeted_managed_app_configurations()\n return MicrosoftGraph::DeviceAppManagement::TargetedManagedAppConfigurations::TargetedManagedAppConfigurationsRequestBuilder.new(@path_parameter... | [
"0.6725974",
"0.63592434",
"0.6272889",
"0.627158",
"0.6231614",
"0.62301904",
"0.613656",
"0.5974369",
"0.57873327",
"0.56845045",
"0.56845045",
"0.5633411",
"0.5614081",
"0.5583626",
"0.5522805",
"0.55174464",
"0.54779404",
"0.5474169",
"0.54059184",
"0.5382686",
"0.5354790... | 0.71362567 | 0 |
Provides operations to manage the mobileApps property of the microsoft.graph.deviceAppManagement entity. | def mobile_apps()
return MicrosoftGraph::DeviceAppManagement::MobileApps::MobileAppsRequestBuilder.new(@path_parameters, @request_adapter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mobile_apps=(value)\n @mobile_apps = value\n end",
"def device_app_management()\n return MicrosoftGraph::DeviceAppManagement::DeviceAppManagementRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def set_mobile_app\n @mobile_app = MobileApp.find... | [
"0.72200453",
"0.68944633",
"0.6520375",
"0.6520375",
"0.64326906",
"0.6157296",
"0.60891485",
"0.5919858",
"0.5884511",
"0.57775664",
"0.5759725",
"0.57033116",
"0.5698578",
"0.5651597",
"0.564872",
"0.5612222",
"0.55787176",
"0.5562505",
"0.5546961",
"0.552165",
"0.5484573"... | 0.7214287 | 1 |
Provides operations to call the syncMicrosoftStoreForBusinessApps method. | def sync_microsoft_store_for_business_apps()
return MicrosoftGraph::DeviceAppManagement::SyncMicrosoftStoreForBusinessApps::SyncMicrosoftStoreForBusinessAppsRequestBuilder.new(@path_parameters, @request_adapter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def i_cloud_block_managed_apps_sync\n return @i_cloud_block_managed_apps_sync\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 se... | [
"0.5747459",
"0.5391222",
"0.53708833",
"0.53315777",
"0.5279871",
"0.52146894",
"0.5201553",
"0.51331216",
"0.5074301",
"0.5056382",
"0.4947139",
"0.4921181",
"0.49015215",
"0.4881808",
"0.48788768",
"0.48672387",
"0.48614055",
"0.4861185",
"0.4819095",
"0.4816582",
"0.48079... | 0.82963526 | 0 |
Provides operations to manage the targetedManagedAppConfigurations property of the microsoft.graph.deviceAppManagement entity. | def targeted_managed_app_configurations()
return MicrosoftGraph::DeviceAppManagement::TargetedManagedAppConfigurations::TargetedManagedAppConfigurationsRequestBuilder.new(@path_parameters, @request_adapter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def targeted_managed_app_configurations=(value)\n @targeted_managed_app_configurations = value\n end",
"def targeted_managed_app_configurations\n return @targeted_managed_app_configurations\n end",
"def managed_apps=(value)\n @managed_apps = va... | [
"0.7347386",
"0.66561866",
"0.6338508",
"0.6231292",
"0.5843936",
"0.57476366",
"0.5617837",
"0.5516933",
"0.54802245",
"0.545087",
"0.5377525",
"0.5345815",
"0.5259468",
"0.5168223",
"0.51356244",
"0.49590248",
"0.4925007",
"0.49247476",
"0.4818033",
"0.4807955",
"0.4793031"... | 0.7684352 | 0 |
Provides operations to manage the vppTokens property of the microsoft.graph.deviceAppManagement entity. | def vpp_tokens()
return MicrosoftGraph::DeviceAppManagement::VppTokens::VppTokensRequestBuilder.new(@path_parameters, @request_adapter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vpp_tokens=(value)\n @vpp_tokens = value\n end",
"def vpp_tokens\n return @vpp_tokens\n end",
"def managed_app_policies()\n return MicrosoftGraph::DeviceAppManagement::ManagedAppPolicies::ManagedAppPoliciesRequestBuilder.new(@path_parameter... | [
"0.58985525",
"0.5865783",
"0.53844005",
"0.51103204",
"0.5009265",
"0.48977032",
"0.48176557",
"0.4722188",
"0.46599543",
"0.4658059",
"0.45846778",
"0.4567695",
"0.45508134",
"0.4543258",
"0.45325553",
"0.45120335",
"0.45057854",
"0.4498486",
"0.44790214",
"0.445957",
"0.44... | 0.6854494 | 0 |
Provides operations to manage the windowsInformationProtectionPolicies property of the microsoft.graph.deviceAppManagement entity. | def windows_information_protection_policies()
return MicrosoftGraph::DeviceAppManagement::WindowsInformationProtectionPolicies::WindowsInformationProtectionPoliciesRequestBuilder.new(@path_parameters, @request_adapter)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mdm_windows_information_protection_policies()\n return MicrosoftGraph::DeviceAppManagement::MdmWindowsInformationProtectionPolicies::MdmWindowsInformationProtectionPoliciesRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def windows_information_protection_policies=(va... | [
"0.741853",
"0.7280711",
"0.7244826",
"0.68403834",
"0.6824301",
"0.62857646",
"0.6271584",
"0.6042058",
"0.59910494",
"0.5934107",
"0.58292943",
"0.5700528",
"0.5619593",
"0.5529103",
"0.53095096",
"0.5308677",
"0.52143645",
"0.5134495",
"0.5103885",
"0.48595434",
"0.4809522... | 0.7787505 | 0 |
Instantiates a new DeviceAppManagementRequestBuilder and sets the default values. | def initialize(path_parameters, request_adapter)
super(path_parameters, request_adapter, "{+baseurl}/deviceAppManagement{?%24select,%24expand}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_app_management()\n return MicrosoftGraph::DeviceAppManagement::DeviceAppManagementRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def device_management()\n return MicrosoftGraph::DeviceManagement::DeviceManagementRequestBuilder.new(@path_parameters, @reques... | [
"0.7209858",
"0.66680187",
"0.55746",
"0.55090964",
"0.54941106",
"0.5345259",
"0.53223866",
"0.532088",
"0.5314688",
"0.5223433",
"0.5200963",
"0.51748246",
"0.5151056",
"0.49823293",
"0.4975952",
"0.49758455",
"0.49188557",
"0.48928013",
"0.48850247",
"0.48610565",
"0.48587... | 0.54072833 | 5 |
Read properties and relationships of the deviceAppManagement object. | def get(request_configuration=nil)
request_info = self.to_get_request_information(
request_configuration
)
error_mapping = Hash.new
error_mapping["4XX"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }
error_mapping["5XX"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }
return @request_adapter.send_async(request_info, lambda {|pn| MicrosoftGraph::Models::DeviceAppManagement.create_from_discriminator_value(pn) }, error_mapping)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def managed_devices\n return @managed_devices\n end",
"def devices\n @devices\n end",
"def properties\n start = Time.now\n debug \"Checking properties for device group: \\\"#{resource[:full_path]}\\\"\"\n connection = self.class.get_connection(resource[:account])\n ... | [
"0.5919667",
"0.5780612",
"0.57789814",
"0.5708176",
"0.5631735",
"0.5525409",
"0.55242884",
"0.5480965",
"0.53661984",
"0.5326116",
"0.52930397",
"0.5289022",
"0.524766",
"0.5226348",
"0.5221837",
"0.521806",
"0.51977646",
"0.51977646",
"0.5196834",
"0.51815414",
"0.5173878"... | 0.5665409 | 4 |
Update the properties of a deviceAppManagement object. | def patch(body, request_configuration=nil)
raise StandardError, 'body cannot be null' if body.nil?
request_info = self.to_patch_request_information(
body, request_configuration
)
error_mapping = Hash.new
error_mapping["4XX"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }
error_mapping["5XX"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }
return @request_adapter.send_async(request_info, lambda {|pn| MicrosoftGraph::Models::DeviceAppManagement.create_from_discriminator_value(pn) }, error_mapping)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_device_properties()\n return MicrosoftGraph::DeviceManagement::WindowsAutopilotDeviceIdentities::Item::UpdateDeviceProperties::UpdateDevicePropertiesRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def update\n wmi_object.put_\n end"... | [
"0.63075316",
"0.6080054",
"0.60480165",
"0.5920676",
"0.5898391",
"0.5898391",
"0.58927375",
"0.58395094",
"0.57998675",
"0.5744023",
"0.571048",
"0.5648379",
"0.5599876",
"0.5580509",
"0.5569869",
"0.5539044",
"0.5535193",
"0.5532164",
"0.5523894",
"0.5522327",
"0.55095917"... | 0.51097935 | 97 |
Read properties and relationships of the deviceAppManagement object. | def to_get_request_information(request_configuration=nil)
request_info = MicrosoftKiotaAbstractions::RequestInformation.new()
request_info.url_template = @url_template
request_info.path_parameters = @path_parameters
request_info.http_method = :GET
request_info.headers.add('Accept', 'application/json')
unless request_configuration.nil?
request_info.add_headers_from_raw_object(request_configuration.headers)
request_info.set_query_string_parameters_from_raw_object(request_configuration.query_parameters)
request_info.add_request_options(request_configuration.options)
end
return request_info
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def managed_devices\n return @managed_devices\n end",
"def devices\n @devices\n end",
"def properties\n start = Time.now\n debug \"Checking properties for device group: \\\"#{resource[:full_path]}\\\"\"\n connection = self.class.get_connection(resource[:account])\n ... | [
"0.5919667",
"0.5780612",
"0.57789814",
"0.5708176",
"0.5665409",
"0.5631735",
"0.5525409",
"0.55242884",
"0.5480965",
"0.53661984",
"0.5326116",
"0.52930397",
"0.5289022",
"0.524766",
"0.5226348",
"0.5221837",
"0.521806",
"0.51977646",
"0.51977646",
"0.5196834",
"0.51815414"... | 0.0 | -1 |
Update the properties of a deviceAppManagement object. | def to_patch_request_information(body, request_configuration=nil)
raise StandardError, 'body cannot be null' if body.nil?
request_info = MicrosoftKiotaAbstractions::RequestInformation.new()
request_info.url_template = @url_template
request_info.path_parameters = @path_parameters
request_info.http_method = :PATCH
request_info.headers.add('Accept', 'application/json')
unless request_configuration.nil?
request_info.add_headers_from_raw_object(request_configuration.headers)
request_info.add_request_options(request_configuration.options)
end
request_info.set_content_from_parsable(@request_adapter, "application/json", body)
return request_info
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_device_properties()\n return MicrosoftGraph::DeviceManagement::WindowsAutopilotDeviceIdentities::Item::UpdateDeviceProperties::UpdateDevicePropertiesRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def update\n wmi_object.put_\n end"... | [
"0.63075316",
"0.6080054",
"0.60480165",
"0.5920676",
"0.5898391",
"0.5898391",
"0.58927375",
"0.58395094",
"0.57998675",
"0.5744023",
"0.571048",
"0.5648379",
"0.5599876",
"0.5580509",
"0.5569869",
"0.5539044",
"0.5535193",
"0.5532164",
"0.5523894",
"0.5522327",
"0.55095917"... | 0.0 | -1 |
Maps the query parameters names to their encoded names for the URI template parsing. | def get_query_parameter(original_name)
raise StandardError, 'original_name cannot be null' if original_name.nil?
case original_name
when "expand"
return "%24expand"
when "select"
return "%24select"
else
return original_name
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_params(query)\n params = {\n bandName: query[:name] || \"\",\n exactBandMatch: (query[:exact] ? 1 : 0),\n genre: query[:genre] || \"\",\n yearCreationFrom: query[:year]&.begin || \"\",\n yearCreationTo: query[:year]&.end || \"\",\n bandNotes: que... | [
"0.60915565",
"0.605133",
"0.5986709",
"0.59832704",
"0.5906048",
"0.58652514",
"0.5841027",
"0.5797896",
"0.5774637",
"0.5710433",
"0.57084304",
"0.5695974",
"0.5660978",
"0.5642493",
"0.5642493",
"0.5634886",
"0.56341594",
"0.56057274",
"0.55981034",
"0.5559806",
"0.5526872... | 0.51743954 | 95 |
Defines a new query pattern | def query_api_pattern(method_name, verb, path='', opts={}, storage=nil, &block)
opts = opts.dup
method_name = method_name.to_s
storage ||= query_api_patterns
before = opts.delete(:before)
after = opts.delete(:after) || block
defaults = opts.delete(:defaults) || {}
params = opts.delete(:params) || {}
headers = opts.delete(:headers) || {}
options = opts.delete(:options) || {}
options[:method_name] = method_name
body = opts.delete(:body) || nil
# Complain if there are any unused keys left.
fail(Error.new("#{method_name.inspect} pattern: unsupported key(s): #{opts.keys.map{|k| k.inspect}.join(',')}")) if opts.any?
# Store the new pattern.
storage[method_name] = {
:verb => verb.to_s.downcase.to_sym,
:path => path.to_s,
:before => before,
:after => after,
:defaults => defaults,
:params => params,
:headers => HTTPHeaders::new(headers),
:options => options,
:body => body }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query( query )\n query.downcase!\n case query\n when /^:r:/ then query_regexp query.gsub(/^:r:/, '')\n when /^:f:/ then query_fulltext_regexp query.gsub(/^:f:/, '')\n else query_simple query\n end\n end",
"def query_pattern(pattern, **options, &block)\n return super unless pattern.gra... | [
"0.69121635",
"0.66614455",
"0.63049686",
"0.62333",
"0.6186912",
"0.6121629",
"0.6033767",
"0.60221285",
"0.6006964",
"0.59696007",
"0.596924",
"0.5965933",
"0.5907596",
"0.58410114",
"0.5833032",
"0.5824188",
"0.58212095",
"0.58176756",
"0.58053535",
"0.5786554",
"0.5687159... | 0.5510166 | 30 |
Returns the list of current patterns The patterns can be defined at the class levels or/and in special Wrapper modules. The patterns defined at the class levels are always inherited by the instances of this class, when the wrapper defined patterns are applied to this particular object only. This allows one to define generic patterns at the class level and somehow specific at the level of wrappers. | def query_api_patterns
@query_api_patterns ||= {}
# The current set of patterns may override whatever is defined at the class level.
self.class.query_api_patterns.merge(@query_api_patterns)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patterns\n #@rules.every.pattern\n @rules.map {|r| r.pattern }\n end",
"def patterns\n # BNodes in statements are existential variables.\n @patterns ||= enum_for(:each_pattern).to_a\n end",
"def patterns\n @patterns ||= []\n end",
"def patterns\n @patterns ||=\n ... | [
"0.6875152",
"0.6835282",
"0.6818043",
"0.6648354",
"0.6587895",
"0.6543487",
"0.6517851",
"0.61777425",
"0.6122028",
"0.59411126",
"0.5925849",
"0.5900743",
"0.5774054",
"0.5741235",
"0.56699604",
"0.55791473",
"0.55403584",
"0.55159557",
"0.54527724",
"0.5416432",
"0.532591... | 0.56173575 | 15 |
Set object specific QUERYlike pattern This guy is usually called from Wrapper's module from self.extended method (see S3 default wrapper) | def query_api_pattern(method_name, verb, path='', opts={}, &block)
self.class.query_api_pattern(method_name, verb, path, opts, @query_api_patterns, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query query_object\n\t\tcase query_object.kind\n\t\t\twhen \"random\"\n\t\t\t\tget_random query_object\n\t\t\twhen \"query\"\n\t\t\t\tget_query query_object\n\t\t\twhen \"category_kind\"\n\t\t\t\tget_category query_object\n\t\t\telse\n\t\t\t\tset_error query_object\n\t\tend\n\n\t\tquery_object\n\tend",
"def ... | [
"0.59348685",
"0.56808645",
"0.5632828",
"0.56049305",
"0.54671735",
"0.54070777",
"0.5399473",
"0.5396979",
"0.53913575",
"0.537633",
"0.53683335",
"0.53572387",
"0.5321244",
"0.5310514",
"0.52856326",
"0.5284533",
"0.52660924",
"0.5246995",
"0.5235153",
"0.5195139",
"0.5186... | 0.0 | -1 |
Build request based on the given set of variables and QUERYlike api pattern | def compute_query_api_pattern_based_params(query_pattern_name, query_params={})
# fix a method name
pattern = query_api_patterns[query_pattern_name.to_s]
# Complain if we dont know the method
raise PatternNotFoundError::new("#{query_pattern_name.inspect} pattern not found") unless pattern
# Make sure we got what we expected
query_params ||= {}
raise Error::new("Params must be Hash but #{query_params.class.name} received.") unless query_params.is_a?(Hash)
# Make a new Hash instance from the incoming Hash.
# Do not clone because we don't want to have HashWithIndifferentAccess instance or
# something similar because we need to have Symbols and Strings separated.
query_params = Hash[query_params]
opts = {}
opts[:body] = query_params.delete(:body)
opts[:headers] = query_params.delete(:headers) || {}
opts[:options] = query_params.delete(:options) || {}
opts[:params] = query_params._stringify_keys
opts[:manager] = self
request_opts = compute_query_api_pattern_request_data(query_pattern_name, pattern, opts)
# Try to use custom :process_rest_api_request method first because some auth things
# may be required.
# (see OpenStack case) otherwise use standard :process_api_request method
{ :method => respond_to?(:process_rest_api_request) ? :process_rest_api_request : :process_api_request,
:verb => request_opts.delete(:verb),
:path => request_opts.delete(:path),
:opts => request_opts }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_request(*args); end",
"def build_request(**args)\n params = {}\n\n self.class.parameter_validations.each do |validation|\n validation.call(args, params)\n end\n\n if self.class.parameter_formatter\n params = self.class.parameter_formatter.call(params)\n else\n ... | [
"0.65821856",
"0.65083283",
"0.64105535",
"0.6227571",
"0.61576045",
"0.5906652",
"0.59020334",
"0.5890922",
"0.58692807",
"0.5861532",
"0.5859799",
"0.58561933",
"0.5832082",
"0.58067083",
"0.5802134",
"0.5800186",
"0.57933646",
"0.5774031",
"0.57732654",
"0.574966",
"0.5723... | 0.6095319 | 5 |
Create custom method_missing method If the called method is not explicitly defined then it tries to find the method definition in the QUERYlike patterns. And if the method is there it builds a request based on the pattern definition. | def method_missing(method_name, *args, &block)
begin
invoke_query_api_pattern_method(method_name, *args, &block)
rescue PatternNotFoundError
super
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method_missing(method_id, params = {})\n request(method_id.id2name.gsub(/_/, '.'), params)\n end",
"def method_missing(method_name, *args)\n req(method_name.to_s)\n end",
"def method_missing(method, *args, &block)\n self.class.class_eval do\n attr_accessor method.t... | [
"0.68908876",
"0.6640613",
"0.6578027",
"0.6505683",
"0.6474533",
"0.63532174",
"0.63520944",
"0.63334846",
"0.6246511",
"0.62444043",
"0.62444043",
"0.6210736",
"0.6193969",
"0.6192093",
"0.6170323",
"0.6157224",
"0.61466014",
"0.6145581",
"0.61400056",
"0.61383915",
"0.6127... | 0.7029882 | 0 |
Computes the path for the API request | def compute_query_api_pattern_path(query_api_method_name, container, used_query_params)
container[:path] = compute_query_api_pattern_param(query_api_method_name, container[:path], container[:params_with_defaults], used_query_params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_path\n path = %w(api where)\n path.concat api_method\n path = path.join('/')\n @path = \"/#{path}.json\"\n end",
"def build_request_path()\n path = \"/#{self.action}\"\n if query_string = build_query_string\n path += \"/#{query_string}\"\n end\n path\n ... | [
"0.8110587",
"0.7501966",
"0.7481521",
"0.74205613",
"0.7340097",
"0.7314376",
"0.7255199",
"0.7254122",
"0.72255975",
"0.71835375",
"0.71815455",
"0.7157831",
"0.71500844",
"0.71145463",
"0.70081943",
"0.70081943",
"0.7006095",
"0.69952446",
"0.69499505",
"0.6946979",
"0.693... | 0.69510937 | 18 |
Computes the set of URL params for the API request | def compute_query_api_pattern_params(query_api_method_name, container, used_query_params)
container[:params] = compute_query_api_pattern_param(query_api_method_name, container[:params], container[:params_with_defaults], used_query_params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_params\n params = get_params_hash(@url.query)\n params['body'] = percent_encode(Base64.strict_encode64(@request_body))\n params.sort.map { |key, value| \"#{key}=#{value}\" }.join('&')\n end",
"def parameters\n url_params = \"\"\n\n if @resource == :catalog\n url_par... | [
"0.7138753",
"0.7097966",
"0.70769316",
"0.6975737",
"0.6893567",
"0.6885916",
"0.6872389",
"0.68647146",
"0.6861682",
"0.68573695",
"0.6852328",
"0.6842345",
"0.6814392",
"0.67723185",
"0.6745835",
"0.67377913",
"0.66913235",
"0.669115",
"0.6660924",
"0.66310006",
"0.6603211... | 0.0 | -1 |
Computes the set of headers for the API request | def compute_query_api_pattern_headers(query_api_method_name, container, used_query_params)
container[:headers].dup.each do |header, header_values|
container[:headers][header].each_with_index do |header_value, idx|
container[:headers][header] = container[:headers][header].dup
container[:headers][header][idx] = compute_query_api_pattern_param(query_api_method_name, header_value, container[:params_with_defaults], used_query_params)
container[:headers][header].delete_at(idx) if container[:headers][header][idx] == Utils::NONE
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_headers\n # the base uri for api requests\n _query_builder = Configuration.base_uri.dup\n\n # prepare query string for API call\n _query_builder << '/response/headers'\n\n # validate and preprocess url\n _query_url = APIHelper.clean_url _query_builder\n\n # prepare header... | [
"0.7886555",
"0.7835401",
"0.7763427",
"0.7763427",
"0.7689034",
"0.7673939",
"0.7669375",
"0.76252156",
"0.76212615",
"0.760028",
"0.7560757",
"0.75551826",
"0.7507351",
"0.7480963",
"0.74709487",
"0.7439533",
"0.7388652",
"0.7386872",
"0.7354329",
"0.734037",
"0.73400825",
... | 0.0 | -1 |
Computes the body value for the API request | def compute_query_api_pattern_body(query_api_method_name, container, used_query_params, pattern)
if container[:body].nil? && !pattern[:body].nil?
# Make sure body is not left blank when it must be set
fail(Error::new("#{query_api_method_name}: body parameter must be set")) if pattern[:body] == Utils::MUST_BE_SET
container[:body] = compute_query_api_pattern_param(query_api_method_name, pattern[:body], container[:params_with_defaults], used_query_params)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_body\n request_object.body\n end",
"def body\n data[:body]\n end",
"def body\n @body ||= @request.body.read\n end",
"def request_body\n # rewind in case anything in the past has left this un-rewound \n request.body.rewind\n request.body.read.tap do\n # re... | [
"0.7472376",
"0.7166822",
"0.7087384",
"0.7058858",
"0.7055976",
"0.7036933",
"0.700654",
"0.67885125",
"0.6787934",
"0.67851615",
"0.6771744",
"0.67294073",
"0.6705411",
"0.66983247",
"0.66577965",
"0.66535336",
"0.66465807",
"0.6639614",
"0.6637837",
"0.6611957",
"0.6610001... | 0.0 | -1 |
Computes single Query API pattern parameter | def compute_query_api_pattern_param(query_api_method_name, source, params_with_defaults, used_query_params) # :nodoc:
case
when source.is_a?(Hash) then compute_query_api_pattern_hash_data(query_api_method_name, source, params_with_defaults, used_query_params)
when source.is_a?(Array) then compute_query_api_pattern_array_data(query_api_method_name, source, params_with_defaults, used_query_params)
when source.is_a?(Symbol) then compute_query_api_pattern_symbol_data(query_api_method_name, source, params_with_defaults, used_query_params)
when source.is_a?(String) then compute_query_api_pattern_string_data(query_api_method_name, source, params_with_defaults, used_query_params)
else source
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_query_api_pattern_params(query_api_method_name, container, used_query_params)\n container[:params] = compute_query_api_pattern_param(query_api_method_name, container[:params], container[:params_with_defaults], used_query_params)\n end",
"def compute_query_api_pattern_based_params(que... | [
"0.68365395",
"0.64351565",
"0.62785095",
"0.62463754",
"0.61687696",
"0.6143873",
"0.6143873",
"0.6137482",
"0.6137482",
"0.6137482",
"0.61180097",
"0.6101446",
"0.6075014",
"0.60418373",
"0.60298634",
"0.59711194",
"0.59711194",
"0.5954473",
"0.5954473",
"0.59298915",
"0.58... | 0.7036557 | 0 |
Deals with blank values. | def parse_query_api_pattern_remove_blank_key( key, value, result)
# 'KeyName{!remove-if-blank}'
blank_key_sign = key[FIND_BLANK_KEYS_TO_REMOVE]
if blank_key_sign
# Delete the original key from the resulting hash.
result.delete(key)
# But if its value is not blank then fix the key name (get rid of {!remove-if-blank}) and
# put it back.
unless value.respond_to?(:_blank?) && value._blank?
key = key.sub(blank_key_sign, '')
result[key] = value
end
end
[key, value]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_blank_values\n attributes.each do |column, value|\n self[column].present? || self[column] = nil\n end\n end",
"def skip_blanks?() @skip_blanks end",
"def normalize_blank_strings\n attributes.each do |column, value|\n self[column] = nil if value.is... | [
"0.7208345",
"0.70001227",
"0.6798062",
"0.6768922",
"0.67579424",
"0.6656088",
"0.6647025",
"0.6588933",
"0.6574041",
"0.6542165",
"0.6534159",
"0.65135974",
"0.6498591",
"0.6463873",
"0.64541864",
"0.6358975",
"0.63384277",
"0.6334676",
"0.63287187",
"0.6317623",
"0.6315478... | 0.0 | -1 |
Query API pattern: ARRAY Parses Array objects | def compute_query_api_pattern_array_data(query_api_method_name, source, params_with_defaults, used_query_params)
result = source.dup
source.dup.each_with_index do |item, idx|
value = compute_query_api_pattern_param(query_api_method_name, item, params_with_defaults, used_query_params)
value == Utils::NONE ? result.delete_at(idx) : result[idx] = value
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def terms_array_query(field, val, options = {})\n terms_query(field, val, options) if val && (!val.is_a?(Array) || val.any?)\n end",
"def sql_array(array)\n Arel.sql(ActiveRecord::Base.sanitize_sql([\"ARRAY[?]\", array]))\n end",
"def getify_array(array_of_records)\n return array_of_records.... | [
"0.6516067",
"0.6333517",
"0.60201085",
"0.5890065",
"0.5876593",
"0.58045363",
"0.5801883",
"0.5792966",
"0.5740559",
"0.5720513",
"0.57193416",
"0.5711123",
"0.57037103",
"0.5682244",
"0.5675916",
"0.56669843",
"0.5663608",
"0.56556344",
"0.56377596",
"0.5627342",
"0.558490... | 0.5676126 | 14 |
1. sets all joinable join_requests as member/participant 2. ensure user_id has a join_request for joinable 3. sets user_id as the organizer/creator for joinable 4. create a chat_message to let people know about this new organizer/creator | def to user_id, message
return yield false, USER_NOT_FOUND unless user = User.find(user_id)
return yield false, INVALID_JOINABLE unless joinable_is_valid?
owner_join_request = JoinRequest.where(joinable: @joinable, user_id: user_id, role: member_type).first_or_create
ApplicationRecord.transaction do
creator_join_requests.update_all(role: member_type)
owner_join_request.update(status: :accepted, role: creator_type)
@joinable.update_attribute(:user_id, user_id)
end
if message.present?
ChatServices::ChatMessageBuilder.new(
user: user,
joinable: @joinable,
join_request: owner_join_request,
params: {
message_type: :text,
content: message,
}
).create
end
yield true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join!(user)\n # It loads up all the user because in the case where the chat is saved but the chat_participations have not been saved,\n # this is the only way to ensure we don't have duplicates.\n return if self.chat_participations.map(&:user_id).include?(user.id)\n self.chat_participations.create!... | [
"0.668035",
"0.61500156",
"0.60958534",
"0.5935227",
"0.586472",
"0.586472",
"0.5839209",
"0.5829119",
"0.582883",
"0.5818461",
"0.5803809",
"0.57498085",
"0.5695783",
"0.5689204",
"0.5628463",
"0.5624066",
"0.5599365",
"0.5590072",
"0.5586949",
"0.55716646",
"0.5555593",
"... | 0.6975022 | 0 |
Initialize the directories and the railstoflex class map | def initialize(src,trgt,rootpackage,test_url = "http://localhost:3000")
@source,@target,@package_root,@test_base_url = src,trgt,rootpackage,test_url
@typemap = {}
@typemap[:integer] = 'int'
@typemap[:float] = 'Number'
@typemap[:datetime] = 'Date'
@typemap[:date] = 'Day'
@typemap[:time] = 'Time'
@typemap[:string] = 'String'
@typemap[:text] = 'String'
@typemap[:boolean] = 'Boolean'
@defaultvaluemap = {}
@defaultvaluemap[:integer] = '0'
@defaultvaluemap[:float] = '0.0'
@defaultvaluemap[:datetime] = 'new Date()'
@defaultvaluemap[:date] = 'new Day()'
@defaultvaluemap[:time] = 'new Time()'
@defaultvaluemap[:string] = '""'
@defaultvaluemap[:text] = '""'
@defaultvaluemap[:boolean] = 'false'
# template variables hash
@tmap = { 'timestamp' => Time.now.httpdate}
@tmap['testbaseurl'] = test_url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n set_root_path!\n \n self.frameworks = default_frameworks\n self.autoload_paths = default_autoload_paths\n self.autoload_once_paths = default_autoload_once_paths\n self.dependency_loading = default_dependency_loa... | [
"0.67733794",
"0.6733427",
"0.6622824",
"0.6516375",
"0.6503654",
"0.643286",
"0.6418493",
"0.64173424",
"0.6368886",
"0.6366727",
"0.6310562",
"0.6295939",
"0.62547314",
"0.6253043",
"0.6236144",
"0.6235043",
"0.6221744",
"0.6212774",
"0.6192451",
"0.61827946",
"0.617857",
... | 0.0 | -1 |
Read and transform a template using a map of keyvalue pairs template must refer to a relative filename (without extension ".st") that uses the syntax: $var$ (StringTemplate lib for Java) | def process_template(template_name,map)
template = File.dirname(__FILE__) + "/../templates/#{template_name}.st"
map['timestamp']=Time.now.httpdate
File.open(template,'r') do | f |
# detect words inside dollar sign pairs
replaced = f.read.gsub(/(\$\w*\$)/) do | match |
key = match[1..match.size-2]
(map.has_key? key) ? map[key] : 'MISSING:'+key
end
return replaced
end # file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def template_replace template, myhash\n #tmpltext=File::read(template);\n\n t = template.dup\n t.gsub!( /##(.*?)##/ ) {\n #raise \"Key '#{$1}' found in template but the value has not been set\" unless ( myhash.has_key?( $1 ) )\n myhash[ $1 ].to_s\n }\n t\n end",
"def template(file, temp... | [
"0.7095161",
"0.6911082",
"0.6651287",
"0.64512587",
"0.6411285",
"0.640328",
"0.6368353",
"0.6345529",
"0.6284182",
"0.62681",
"0.61360824",
"0.61357534",
"0.6080982",
"0.6074778",
"0.60469043",
"0.6046569",
"0.60050505",
"0.599368",
"0.5984869",
"0.5967799",
"0.59600604",
... | 0.7969874 | 0 |
def Lookup the Ruby class refered to by a model name | def to_class(model_name)
Kernel.const_get(model_name.to_s.camelize)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_from_name\n if model_name.to_s.include? \"_\"\n ns, *klass = model_name.to_s.split(\"_\").collect(&:camelize)\n begin\n \"#{ns}::#{klass.join(\"\")}\".constantize\n rescue NameError\n \"#{ns}#{klass.join(\"\")}\".constantize\n end\n ... | [
"0.7741191",
"0.7725917",
"0.77190685",
"0.7625627",
"0.7589509",
"0.7567288",
"0.7484071",
"0.74534875",
"0.7410137",
"0.73734826",
"0.7340206",
"0.7282993",
"0.72777945",
"0.7259289",
"0.7258466",
"0.72416747",
"0.7139413",
"0.71297276",
"0.71297276",
"0.71224797",
"0.70982... | 0.7933407 | 0 |
Create a new file using a template name and a hash with value for all template variables | def generate(file_name,template,map, overwrite = true)
# make sure the package folder exists
pkg_path = (map['package'] || '').gsub('.','/')
FileUtils.makedirs "#{target}/#{pkg_path}"
File.open("#{target}/#{pkg_path}/#{file_name}",'w') do |f|
f << self.process_template(template,map)
log ">> writing #{f.path}"
end #file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buildup_template_file(basename, header, hash)\n type = hash[:type] || :script\n filename = filename_for(basename, type)\n\n if File.exist? filename\n exit 0 unless prompt(\"* '#{filename}' already exists, overwrite it? (y/n): \") =~ /^y$/i\n end\n File.open(filename, \"w\") {|fi... | [
"0.71314526",
"0.70949185",
"0.7052817",
"0.6523122",
"0.65225816",
"0.6518813",
"0.6487467",
"0.6463251",
"0.6304741",
"0.62920666",
"0.6267362",
"0.621183",
"0.621183",
"0.618955",
"0.61689293",
"0.61512595",
"0.6140747",
"0.61276853",
"0.61258334",
"0.61191213",
"0.6095173... | 0.6203255 | 13 |
Map a ActiveRecord column type of a ActionScript Class name. Returns "missing_type" is no mapping was found. | def flex_type_from(column_type)
@typemap[column_type] ||= "MISSING in template_processor.rb=#{column_type}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def column_type\n class_name.columns_hash[@column.to_s].type\n end",
"def map_types!(column_mapping)\n\t\tself.column_mapping = column_mapping\n\t\tself\n\tend",
"def type(column); self[column]['type']; end",
"def sql_type_for_class(klass)\n @typemap[klass]\n end",
"def scaffold_tab... | [
"0.68826586",
"0.6616182",
"0.65956",
"0.6566813",
"0.6552976",
"0.64582145",
"0.64322907",
"0.6280331",
"0.6280331",
"0.61629206",
"0.61547333",
"0.61547333",
"0.6148046",
"0.611967",
"0.6104372",
"0.6080398",
"0.5972758",
"0.597159",
"0.59491104",
"0.5920291",
"0.5864119",
... | 0.6414151 | 7 |
Return a source snippet for initializing a Flex variable | def flex_default_from(column_type)
@defaultvaluemap[column_type] ||= "MISSING in template_processor.rb=#{column_type}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_variable(name)\n emit_section :data\n emit \"#{name}: .long 0x0\\n\"\n emit_section :text\nend",
"def define_variable(name)\n emit_section :data\n emit \"#{name}: .long 0x0\\n\"\n emit_section :text\nend",
"def lex_en_expr_variable=(_arg0); end",
"def lex_en_expr_variable=(_arg0); end",
"d... | [
"0.6435515",
"0.6435515",
"0.6079845",
"0.6079845",
"0.6079845",
"0.6007315",
"0.5888799",
"0.5875815",
"0.57994664",
"0.57475376",
"0.57456684",
"0.57456684",
"0.57456684",
"0.571577",
"0.5713784",
"0.5645336",
"0.56447864",
"0.56447864",
"0.564044",
"0.55978996",
"0.5594771... | 0.0 | -1 |
what kind of thing a variable is before using it. | def setup
size 200, 200
count = 0 # count gets assigned 0, an integer (Fixnum)
letter = 'a' # letter gets the letter 'a', a String
d = 132.32 # d gets the decimal 132.32, a Float (floating-point number)
happy = false # happy gets false, a Boolean (true or false)
x = 4.0 # x gets 4.0, another Float
y = nil # y gets nil, which stands for nothing
y = x + 5.2 # assign the value of x plus 5.2 to y
z = x * y + 15.0 # z gets the value of x times y plus 15.0 (or 51.8)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type\n :variable\n end",
"def kind_of(kind)\n case kind\n when 'var'\n 'local'\n when 'field'\n 'this'\n else\n kind\n end\n end",
"def kind\n parser_for(:variable_kind, variable_attributes) || \"secret\"\n end",
"def variable; end",
"def variable; end... | [
"0.66155005",
"0.65988743",
"0.63557374",
"0.633887",
"0.633887",
"0.6273676",
"0.6273676",
"0.603618",
"0.5998714",
"0.59018505",
"0.58339095",
"0.5777365",
"0.5767829",
"0.5745168",
"0.5745168",
"0.566444",
"0.56605226",
"0.56477165",
"0.5618115",
"0.56177866",
"0.560092",
... | 0.0 | -1 |
Creates a new Config. The configuration is loaded from the file 'hiera.yaml' which is expected to be found in the given module_dir. | def initialize(module_dir, diagnostics)
@module_dir = module_dir
config_file = File.join(module_dir, 'hiera.yaml')
validator = ConfigChecker.new(diagnostics)
begin
data = YAML.load_file(config_file)
validator.validate(data, config_file)
unless diagnostics.errors?
# if these are missing the result is nil, and they get default values later
@hierarchy = data['hierarchy']
@backends = data['backends']
end
rescue Errno::ENOENT
diagnostics.accept(Issues::CONFIG_FILE_NOT_FOUND, config_file)
rescue Errno::ENOTDIR
diagnostics.accept(Issues::CONFIG_FILE_NOT_FOUND, config_file)
rescue ::SyntaxError => e
diagnostics.accept(Issues::CONFIG_FILE_SYNTAX_ERROR, e)
rescue *YamlLoadExceptions => e
diagnostics.accept(Issues::CONFIG_FILE_SYNTAX_ERROR, e)
end
@hierarchy ||= DEFAULT_HIERARCHY
@backends ||= DEFAULT_BACKENDS
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(options={})\n config = options[:config]\n if config.nil?\n # Look in codedir first, then confdir\n config = File.join(Util.code_dir, 'hiera.yaml')\n config = File.join(Util.config_dir, 'hiera.yaml') unless File.exist?(config)\n end\n @config = Config.load(config)\n\n Co... | [
"0.66142774",
"0.6323906",
"0.6308874",
"0.6004687",
"0.5995144",
"0.595492",
"0.5898234",
"0.5880586",
"0.5851178",
"0.58310044",
"0.5776565",
"0.5755142",
"0.572212",
"0.57084197",
"0.56564426",
"0.56489426",
"0.5616188",
"0.561147",
"0.56078607",
"0.559351",
"0.55861735",
... | 0.7328607 | 0 |
GET /organizations GET /organizations.json | def index
if search_params
logger.debug "Got params: #{search_params}"
@organization = Organization.find(search_params)
else
logger.debug "No params!"
end
# @organizations = Organization.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_organizations\n params = {\n 'method' => :get,\n 'command' => '/org'\n }\n\n response, headers = send_request(params)\n orgs = response.css('OrgList Org')\n\n results = {}\n orgs.each do |org|\n results[org['name']] = or... | [
"0.80765116",
"0.80071",
"0.78597564",
"0.78338337",
"0.78312206",
"0.7745588",
"0.7691283",
"0.7672265",
"0.76290935",
"0.7590858",
"0.7536119",
"0.7533662",
"0.7521284",
"0.75053763",
"0.75053763",
"0.75053763",
"0.75053763",
"0.75053763",
"0.75053763",
"0.75053763",
"0.750... | 0.6490563 | 92 |
GET /organizations/1 GET /organizations/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetOrg id\n\n APICall(path: \"organizations/#{id}.json\")\n\n end",
"def show\n organization = current_user.organizations.find(params[:id])\n if organization\n render json: organization, status: 200\n else\n head 404\n end\n end",
"def index\n ... | [
"0.7965355",
"0.7789723",
"0.7624976",
"0.76014984",
"0.75791377",
"0.75791377",
"0.75518954",
"0.7519814",
"0.74602246",
"0.74229765",
"0.7412952",
"0.7383728",
"0.7383559",
"0.7383559",
"0.7383559",
"0.7383559",
"0.7383559",
"0.7383559",
"0.7383559",
"0.7383559",
"0.7383559... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_organization
@organization = Organization.find(params[:name])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def search_params
params[:name]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /tunning_diagrams GET /tunning_diagrams.json GET /tunning_diagrams.xml | def index
@tunning_diagrams = TunningDiagram.accessible_by(current_ability).search(params[:search]).page(params[:page])
respond_to do |format|
format.html # index.html.erb
format.json { render json: @tunning_diagrams }
format.xml { render xml: @tunning_diagrams }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tunning_diagram }\n format.xml { render xml: @tunning_diagram }\n end\n end",
"def load_tunning_diagram\n @tunning_diagram = TunningDiagram.accessible_by(current_ability).find(params[:id])\n e... | [
"0.64302707",
"0.6269652",
"0.5962418",
"0.56608623",
"0.55094826",
"0.54959035",
"0.5261463",
"0.52576977",
"0.5217472",
"0.5156205",
"0.5143938",
"0.51160264",
"0.5092586",
"0.50656277",
"0.5062149",
"0.5048742",
"0.49743572",
"0.49710086",
"0.4951045",
"0.49499214",
"0.494... | 0.7052123 | 0 |
GET /tunning_diagrams/1 GET /tunning_diagrams/1.json GET /tunning_diagrams/1.xml | def show
respond_to do |format|
format.html # show.html.erb
format.json { render json: @tunning_diagram }
format.xml { render xml: @tunning_diagram }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tunning_diagrams = TunningDiagram.accessible_by(current_ability).search(params[:search]).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tunning_diagrams }\n format.xml { render xml: @tunning_diagrams }\n end\n end",... | [
"0.7020619",
"0.63848007",
"0.6086284",
"0.6053616",
"0.5594579",
"0.54399014",
"0.5396608",
"0.5376734",
"0.5370773",
"0.53577954",
"0.53278077",
"0.5285031",
"0.52596384",
"0.52386945",
"0.52247274",
"0.5216956",
"0.5213363",
"0.51792276",
"0.51583666",
"0.5145195",
"0.5141... | 0.6766607 | 1 |
GET /tunning_diagrams/new GET /tunning_diagrams/new.json GET /tunning_diagrams/new.xml | def new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @tunning_diagram }
format.xml { render xml: @tunning_diagram }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @diagram = Diagram.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @diagram }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tunning_diagram }\n format.xml { r... | [
"0.6363906",
"0.60876155",
"0.60338914",
"0.6027419",
"0.60028416",
"0.59563315",
"0.59469086",
"0.59221077",
"0.59199166",
"0.59083074",
"0.58987087",
"0.58923894",
"0.5888841",
"0.5875507",
"0.5871645",
"0.5839852",
"0.5836289",
"0.5830615",
"0.5829557",
"0.5827808",
"0.582... | 0.75504357 | 0 |
POST /tunning_diagrams POST /tunning_diagrams.json POST /tunning_diagrams.xml | def create
all_saved = false
if params[:tunning_diagram] && file = params[:tunning_diagram][:archive]
if file.original_filename =~ /\.zip$/i
require 'zip/zipfilesystem'
extract_path = Rails.root.join('public', 'tmp', Digest::MD5.hexdigest(file.original_filename))
FileUtils.rm_rf(extract_path)
FileUtils.mkdir_p(extract_path)
Zip::ZipFile.open(file.tempfile) do |zip|
all_saved = zip.select{|zipfile| zipfile.name =~ /\.(jpg|jpeg)$/i}.map do |zipfile|
f_path = File.join(extract_path, zipfile.name)
zipfile.extract(f_path)
File.open(f_path = File.join(extract_path, zipfile.name), 'r+') do |f|
f_name = zipfile.name.split('.')[0].upcase
td = TunningDiagram.where(hilt_no: f_name).first || TunningDiagram.new(hilt_no: f_name)
td.archive = f
td.save
end
end
end
FileUtils.rm_rf(extract_path)
elsif file.original_filename =~ /\.(jpg|jpeg)$/i
f_name = file.original_filename.split('.')[0]
td = TunningDiagram.where(hilt_no: f_name).first || TunningDiagram.new(hilt_no: f_name)
td.archive = file
all_saved = td.save
end
end
respond_to do |format|
if all_saved
format.html { redirect_to @tunning_diagram, notice: I18n.t('controllers.create_success', name: @tunning_diagram.class.model_name.human) }
format.json { render json: @tunning_diagram, status: :created, location: @tunning_diagram }
format.xml { render xml: @tunning_diagram, status: :created, location: @tunning_diagram }
else
format.html { render action: "new" }
format.json { render json: @tunning_diagram.errors, status: :unprocessable_entity }
format.xml { render xml: @tunning_diagram.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tunning_diagram_params\n params.require(:tunning_diagram).permit()\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tunning_diagram }\n format.xml { render xml: @tunning_diagram }\n end\n end",
"def load_tunning_diagram\n @tu... | [
"0.6025509",
"0.5852471",
"0.5678888",
"0.54949474",
"0.54936635",
"0.5356828",
"0.5270989",
"0.5102948",
"0.5099927",
"0.50024647",
"0.484845",
"0.4813623",
"0.48073804",
"0.48020402",
"0.47753787",
"0.47617656",
"0.47148153",
"0.46824607",
"0.4632156",
"0.46232826",
"0.4609... | 0.49316886 | 10 |
PUT /tunning_diagrams/1 PUT /tunning_diagrams/1.json PUT /tunning_diagrams/1.xml | def update
respond_to do |format|
if @tunning_diagram.update_attributes(params[:tunning_diagram])
format.html { redirect_to @tunning_diagram, notice: I18n.t('controllers.update_success', name: @tunning_diagram.class.model_name.human) }
format.json { head :no_content }
format.xml { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @tunning_diagram.errors, status: :unprocessable_entity }
format.xml { render xml: @tunning_diagram.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_tunning_diagram\n @tunning_diagram = TunningDiagram.accessible_by(current_ability).find(params[:id])\n end",
"def tunning_diagram_params\n params.require(:tunning_diagram).permit()\n end",
"def update\n @diagram = Diagram.find(params[:id])\n\n respond_to do |format|\n if @diagram.up... | [
"0.5468396",
"0.540846",
"0.5381618",
"0.5317307",
"0.52022266",
"0.50914097",
"0.5015315",
"0.49808025",
"0.49579468",
"0.4956918",
"0.4947348",
"0.4920314",
"0.48651648",
"0.48610976",
"0.48513702",
"0.482983",
"0.48271123",
"0.4812472",
"0.47715932",
"0.4768334",
"0.474988... | 0.6469807 | 0 |
DELETE /tunning_diagrams/1 DELETE /tunning_diagrams/1.json DELETE /tunning_diagrams/1.xml | def destroy
#@tunning_diagram = TunningDiagram.find(params[:id])
if @tunning_diagram.destroy && @tunning_diagram.destroy
respond_to do |format|
format.html { redirect_to tunning_diagrams_url, notice: I18n.t('controllers.destroy_success', name: @tunning_diagram.class.model_name.human) }
format.json { head :no_content }
format.xml { head :no_content }
end
else
respond_to do |format|
format.html { redirect_to tunning_diagrams_url, notice: I18n.t('controllers.destroy_fail', name: @tunning_diagram.class.model_name.human) }
format.json { head :no_content }
format.xml { head :no_content }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @diagram = Diagram.find(params[:id])\n @diagram.destroy\n\n respond_to do |format|\n format.html { redirect_to(diagrams_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @diagramm = Diagramm.find(params[:id])\n @diagramm.destroy\n\n respond_to do |format... | [
"0.6749001",
"0.63204056",
"0.6253094",
"0.61594135",
"0.61372536",
"0.60985154",
"0.6084779",
"0.6075024",
"0.6073417",
"0.6040757",
"0.6013109",
"0.59900504",
"0.5987455",
"0.5973118",
"0.59715456",
"0.5968056",
"0.5964777",
"0.5962027",
"0.59588146",
"0.59562695",
"0.59466... | 0.68134 | 0 |
Use callback to share common setup or constraints between actions | def load_tunning_diagram
@tunning_diagram = TunningDiagram.accessible_by(current_ability).find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_hook; end",
"def run_actions; end",
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def callbacks; end",
"def callbacks; end",
"def define_action_hook; end",
"def actions; end",
"def add_actions; end",
"def setup_handler\n end",
"def ... | [
"0.62433624",
"0.61606205",
"0.61442274",
"0.60236615",
"0.60236615",
"0.5957384",
"0.59124553",
"0.5815883",
"0.57709527",
"0.57247967",
"0.56691265",
"0.5662611",
"0.5647806",
"0.5625292",
"0.5624815",
"0.55596256",
"0.5546272",
"0.5532163",
"0.5514178",
"0.5499426",
"0.548... | 0.0 | -1 |
User this method to whitelist the permissible parameters. Example: params.require(:person).permit(:name, :age) Also, you can specialize this method with peruser checking of permissible attributes. | def tunning_diagram_params
params.require(:tunning_diagram).permit()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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(:user).pe... | [
"0.78805184",
"0.7715858",
"0.7491385",
"0.7300915",
"0.7262711",
"0.7255844",
"0.72538334",
"0.7227243",
"0.7163269",
"0.7161134",
"0.71351975",
"0.71351975",
"0.7103507",
"0.7088179",
"0.7047137",
"0.6974054",
"0.6969322",
"0.69616586",
"0.694162",
"0.6932733",
"0.6889958",... | 0.0 | -1 |
Returning any kind of identification you want for the model | def name
return self.email
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identifier(model)\n models[model]\n end",
"def input_id_from_type(type); end",
"def identifier\n best_identifier\n end",
"def identification_name(identification_type)\n case identification_type\n when Donor.identification_types['pan_card']\n 'Permanent Account Number'\n when Don... | [
"0.65590584",
"0.648132",
"0.6455226",
"0.6344137",
"0.633256",
"0.62737584",
"0.621614",
"0.6179366",
"0.61688393",
"0.6113753",
"0.6113753",
"0.6113753",
"0.6113753",
"0.61099976",
"0.6098491",
"0.6065589",
"0.60568094",
"0.60568094",
"0.60554343",
"0.60554343",
"0.6036695"... | 0.0 | -1 |
Returning the email address of the model if an email should be sent for this object (Message or Notification). If no mail has to be sent, return nil. | def mailboxer_email(object)
#Check if an email should be sent for that object
#if true
return "define_email@on_your.model"
#if false
#return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email\n result_record = default_email_record\n default_email_record.email if result_record\n end",
"def email\n result_record = default_email_record\n default_email_record.email if result_record\n end",
"def mailboxer_email(object)\n #Check if an email should be sent for that object\n #... | [
"0.74394685",
"0.74394685",
"0.7433783",
"0.7351371",
"0.73307574",
"0.7324078",
"0.7205258",
"0.70875454",
"0.7013618",
"0.7013618",
"0.6981674",
"0.6878962",
"0.6852198",
"0.6794687",
"0.6764991",
"0.67487496",
"0.67481905",
"0.67164683",
"0.67000943",
"0.66906345",
"0.6648... | 0.7342027 | 4 |
Constructor takes one argument name of the Player instance | def initialize(name = 'Unnamed Player')
@name = name
@score = 0
@available_dices = 5
@dice_set = DiceSet.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(player_name)\n @name = player_name.to_s\n @life_points = 10\n end",
"def initialize name\n @player = name\n @@player_count+=1\n end",
"def initialize(name_player)\n @life_points = 10\n @name = name_player\n end",
"def initialize\n @player1 = get_player_name('1... | [
"0.8037702",
"0.79228747",
"0.792003",
"0.7903484",
"0.78550553",
"0.7828283",
"0.7797295",
"0.7783487",
"0.7690049",
"0.7674859",
"0.76047456",
"0.75539786",
"0.75539786",
"0.75199616",
"0.75087094",
"0.7382767",
"0.7381529",
"0.73285675",
"0.72871447",
"0.72648495",
"0.7259... | 0.7257724 | 21 |
Roll dices for the current round and calculates score | def roll
@dice_set.clear
@dice_set.roll(@available_dices)
calculate_points
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score\n while @current_roll < @rolls.size - 1\n init_roll\n\n if strike?\n score_strike\n elsif spare?\n score_spare\n else\n score_roll\n end \n end\n \n return @total_score\n end",
"def score\n while @current_roll < @rolls.size - 1\n init_r... | [
"0.7530656",
"0.7526535",
"0.7526535",
"0.7419668",
"0.741699",
"0.7372666",
"0.7356575",
"0.7356575",
"0.7301996",
"0.7237499",
"0.72321147",
"0.7179739",
"0.7173664",
"0.71542454",
"0.7114859",
"0.7105003",
"0.7073966",
"0.7071923",
"0.7055875",
"0.70199597",
"0.699146",
... | 0.77730453 | 0 |
Little helper to clean up examples | def notify(instrumentation)
ActiveSupport::Notifications.instrument(
'client_request_matrix_data.google_distance_matrix', instrumentation
) do
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_examples\n examples.\n map {|title, body|\n [\n \"#{ title }:\",\n body.lines.map {|l|\n # only indent non-empty lines\n # makes compacting newline sequences easier (see below)\n if l.match(/^\\s*$/)\n l\n else\n ... | [
"0.6309135",
"0.5955377",
"0.5943286",
"0.59292436",
"0.5867937",
"0.57253605",
"0.5625203",
"0.56016016",
"0.5600385",
"0.5575843",
"0.5571277",
"0.5522046",
"0.5470743",
"0.5470743",
"0.54483247",
"0.54189974",
"0.5412778",
"0.5412643",
"0.5398807",
"0.53766084",
"0.5362165... | 0.0 | -1 |
=========== Refund money from transaction============== | def create_issue_refund
@error = ""
if params[:refund_amount].present?
if params[:refund_amount].to_d > 0.0 && params[:refund_amount].to_d <= @trans.amount
@refund_trans = Transaction.new(
amount: params[:refund_amount].to_d,
transaction_type: "Payment",
status: "Refunded",
from_account_id: current_user.account.id,
to_account_id: @trans.from_account.id,
transaction_from: "User",
transaction_to: "User",
kaenko_currency_id: @trans.kaenko_currency_id,
status: "Completed" ,
user_id: current_user.id,
transaction_from_id: current_user.id,
transaction_to_id: @trans.transaction_from_id,
parent_id: @trans.id
)
Transaction.transaction do
if @refund_trans.save
@account_balance = current_user.account.account_balances.where(
"kaenko_currency_id = ?",
@trans.kaenko_currency_id
).first
@account_balance.update_attributes(balance: @account_balance.balance - params[:refund_amount].to_d)
@trans.update_attributes(status: "Refunded")
end
end
else
@error = "Please enter valid amount."
end
else
@error = "Please enter amount."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refund(money, authorization ,options={})\n post = {\n amount: money\n }\n\n add_reference(post, authorization)\n commit(:refund, post)\n end",
"def refund(money, authorization, options = {})\n post = {}\n add_order_id(post, order_id_from(authorization))... | [
"0.7117888",
"0.6953859",
"0.6891258",
"0.689027",
"0.6822686",
"0.6806595",
"0.67969036",
"0.67913246",
"0.6771533",
"0.6748782",
"0.6731747",
"0.6705402",
"0.6687968",
"0.6677174",
"0.66758776",
"0.6673207",
"0.66716194",
"0.66571033",
"0.66395646",
"0.65961367",
"0.6594139... | 0.64714897 | 40 |
extract french and other addresses | def extract_destinations
destinations = @tiers.mails.group_by { |dest| dest.split('.').last == 'fr' }
@french = destinations[true]
@other = destinations[false]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def address_parts\n texts = @page.css('.claAngebot .claRight p').map(&:text)\n found_address = address_part(CITY_REGEXP, texts) || address_part(WEBSITE_REGEXP, texts) || ''\n found_address.split(\"\\n\").map { |line| clean_up_spaces(line) }\n end",
"def full_address\n part_1 = address\n part_2 = ... | [
"0.67254376",
"0.629819",
"0.6006042",
"0.6006042",
"0.599553",
"0.57814217",
"0.5732348",
"0.57316375",
"0.5690134",
"0.5647639",
"0.56393284",
"0.56388414",
"0.56385905",
"0.5616885",
"0.5599533",
"0.5587805",
"0.55788124",
"0.55572313",
"0.5554167",
"0.5537792",
"0.553198"... | 0.6258206 | 2 |
do notification for this tiers | def notify
return false unless @tiers # invalid tiers_id
extract_destinations
if @french || @other
done = notify_all_destinations
say_notified if done && @mode
done
else # no mail
register_tiers
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notify\n end",
"def do_notify_all\n number = tiers_list.size\n @report << \"#{number} mail(s) à envoyer\"\n tiers_list.each do |tiers_id|\n subs = to_be_notified_for(tiers_id)\n done = Notifier.new(tiers_id, subs, @mode).notify\n next if done\n ... | [
"0.6846709",
"0.6812397",
"0.6638251",
"0.6638251",
"0.6400945",
"0.63631654",
"0.6316323",
"0.6270889",
"0.6270889",
"0.625349",
"0.62436175",
"0.62123454",
"0.62123454",
"0.62123454",
"0.6206341",
"0.619524",
"0.61609405",
"0.6044616",
"0.60317105",
"0.6019092",
"0.59932035... | 0.61250633 | 17 |
send all notification mails | def notify_all_destinations
done_french = !@french || notify_french(@french)
done_other = !@other || notify_english(@other)
done_french && done_other
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_notify_all\n number = tiers_list.size\n @report << \"#{number} mail(s) à envoyer\"\n tiers_list.each do |tiers_id|\n subs = to_be_notified_for(tiers_id)\n done = Notifier.new(tiers_id, subs, @mode).notify\n next if done\n number -= 1\n @repor... | [
"0.78565943",
"0.7747894",
"0.76817447",
"0.76007515",
"0.75743717",
"0.733876",
"0.733143",
"0.7303527",
"0.72838527",
"0.72536343",
"0.72476107",
"0.72438985",
"0.71408147",
"0.7120416",
"0.70938724",
"0.708356",
"0.7008678",
"0.698971",
"0.69853824",
"0.69696784",
"0.69679... | 0.0 | -1 |
send notification in french to this address | def notify_french(dest)
mail(dest, FRENCH_SUBJECT, mail_content(french_model_file))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tender_updated\n @greeting = \"Χαίρετε\"\n\n mail to: \"to@example.org\"\n end",
"def notify_english(dest)\n mail(dest, ENGLISH_SUBJECT, mail_content(english_model_file))\n end",
"def notify_shipped(order)\n @order = order\n @info = @order.info\n email = @order.user.email\n s... | [
"0.654578",
"0.65252733",
"0.64850813",
"0.6276096",
"0.62659794",
"0.6239277",
"0.6083753",
"0.6067907",
"0.5981108",
"0.5964361",
"0.59534293",
"0.59455216",
"0.5942909",
"0.5942316",
"0.59048444",
"0.5872955",
"0.58694094",
"0.58549124",
"0.5846537",
"0.5846181",
"0.58425"... | 0.6973913 | 0 |
WARNING: DO NOT INLINE : Hack for collective | def french_model_file
FRENCH_MODEL_FILE
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inline_code; end",
"def inline?; false; end",
"def inline?; false; end",
"def all_inline?; end",
"def private; end",
"def code_point=(_); end",
"def probers; end",
"def big_bad; end",
"def max_fast_inline(num_of_requests); end",
"def code; end",
"def code; end",
"def code; end",
"def co... | [
"0.6889724",
"0.6675696",
"0.6675696",
"0.6618395",
"0.6413179",
"0.60098547",
"0.5924349",
"0.59042925",
"0.58059376",
"0.5783583",
"0.5783583",
"0.5783583",
"0.5783583",
"0.5783583",
"0.5783583",
"0.5783583",
"0.5775712",
"0.5763482",
"0.5759488",
"0.5732742",
"0.5730331",
... | 0.0 | -1 |
send notification in english to this address | def notify_english(dest)
mail(dest, ENGLISH_SUBJECT, mail_content(english_model_file))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notify_french(dest)\n mail(dest, FRENCH_SUBJECT, mail_content(french_model_file))\n end",
"def tender_updated\n @greeting = \"Χαίρετε\"\n\n mail to: \"to@example.org\"\n end",
"def admin_broadcast(desired_locale, emails_as_string, subject, body)\n ActionMailer::Base.smtp_settings = AP... | [
"0.64111954",
"0.6263988",
"0.62529945",
"0.62239",
"0.6223147",
"0.62105626",
"0.6192396",
"0.61874944",
"0.61850315",
"0.6183237",
"0.613429",
"0.6119588",
"0.6111077",
"0.6101984",
"0.6058111",
"0.6035919",
"0.6025501",
"0.6006228",
"0.5996783",
"0.5979157",
"0.5969079",
... | 0.7066022 | 0 |
WARNING: DO NOT INLINE : Hack for collective | def english_model_file
ENGLISH_MODEL_FILE
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inline_code; end",
"def inline?; false; end",
"def inline?; false; end",
"def all_inline?; end",
"def private; end",
"def code_point=(_); end",
"def probers; end",
"def big_bad; end",
"def max_fast_inline(num_of_requests); end",
"def code; end",
"def code; end",
"def code; end",
"def co... | [
"0.6889724",
"0.6675696",
"0.6675696",
"0.6618395",
"0.6413179",
"0.60098547",
"0.5924349",
"0.59042925",
"0.58059376",
"0.5783583",
"0.5783583",
"0.5783583",
"0.5783583",
"0.5783583",
"0.5783583",
"0.5783583",
"0.5775712",
"0.5763482",
"0.5759488",
"0.5732742",
"0.5730331",
... | 0.0 | -1 |
public instance methods ................................................... | def total
Product.find(self.product_id).price * quantity.to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def implementation; end",
"def implementation; end",
"def initialize\n\t\t\n\tend",
"def instance; end",
"def instance; end",
"def instance; end",
"def internal; end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def initialize\n \n end"... | [
"0.8471986",
"0.75887525",
"0.75887525",
"0.7408363",
"0.7389037",
"0.7389037",
"0.7389037",
"0.733222",
"0.7306463",
"0.7306463",
"0.7306463",
"0.7306463",
"0.72930485",
"0.7246825",
"0.71916157",
"0.71916157",
"0.7188285",
"0.7188285",
"0.7188285",
"0.7188285",
"0.71772283"... | 0.0 | -1 |
return the string that contains last name, comma, space, first name Split the string and then combine them together in reverse | def swap_name(name)
name.split.reverse.join(', ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flip_first_last_name(name)\n fixed_name = name.split(\", \")\n if fixed_name[1] \n fixed_name[1] + ' ' + fixed_name[0]\n else\n name\n end\n end",
"def last_name_first_name(name)\n last = last_name(name)\n first = name.gsub(last, '').strip \n \"#{last}, #{first}\"\n ... | [
"0.76949465",
"0.76815027",
"0.76703227",
"0.7492497",
"0.7465855",
"0.74643314",
"0.7390674",
"0.73892635",
"0.7389244",
"0.73819494",
"0.736028",
"0.73563695",
"0.7341007",
"0.7325225",
"0.7317771",
"0.7270826",
"0.72299665",
"0.7215072",
"0.71906596",
"0.7142038",
"0.71357... | 0.6575941 | 89 |
Test that sentences of words are split up into distinct words correctly | def test_words
assert_equal(%w{this is a test}, "this is a test".words)
assert_equal(%w{these are mostly words}, "these are, mostly, words".words)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_small_words_within_phrase\n %w( a an and as at but by en for if in of on or the to v v. via vs vs. ).each do |word|\n \n # Test in a string\n original_str = @str.join( \" #{word} \" ) + \".\"\n assert_equal \"This #{word} Script.\", original_str.titlecase\n \n # Test with ... | [
"0.6853352",
"0.68158805",
"0.66949224",
"0.66271335",
"0.66233927",
"0.6602829",
"0.6602356",
"0.6602356",
"0.6575891",
"0.64489406",
"0.64481384",
"0.6442091",
"0.6430795",
"0.6430795",
"0.64174986",
"0.6384774",
"0.6374738",
"0.6374738",
"0.63480407",
"0.6308421",
"0.62806... | 0.6735185 | 2 |
Test that the correct sentence is chosen, given the input | def test_sentence_choice
assert_equal('This is a great test',
WordPlay.best_sentence(['This is a test',
'This is another test',
'This is a great test'],
%w{test great this}))
assert_equal('This is a great test',
WordPlay.best_sentence(['This is a great test'],
%w{still the best}))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sentence_choice\n assert_equal('This is a great test', \n WordPlay.best_sentence(['This is a test',\n 'This is a great test'],\n %w{test great this}))\n assert_equal('This is a great test', WordPlay.best_... | [
"0.7755298",
"0.6958053",
"0.69062454",
"0.6733327",
"0.6602947",
"0.65434533",
"0.6469821",
"0.64494824",
"0.6417932",
"0.63412744",
"0.63381684",
"0.63208",
"0.6262111",
"0.6249105",
"0.6216082",
"0.621405",
"0.6162877",
"0.61574835",
"0.61547",
"0.6128183",
"0.61276066",
... | 0.7765891 | 0 |
Test that basic pronouns are switched by switch_pronouns | def test_basic_pronouns
assert_equal("i am a robot", WordPlay.switch_pronouns("you are a robot"))
assert_equal("you are a person", WordPlay.switch_pronouns("i am a person"))
assert_equal("i love you", WordPlay.switch_pronouns("you love me"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_pronouns\n assert_equal('I am a robot', WordPlay.switch_pronouns('You are a robot'))\n assert_equal('You are a person', WordPlay.switch_pronouns('I am a person'))\n assert_equal('I love you', WordPlay.switch_pronouns('You love me'))\n assert_equal('You suck balls', WordPlay.switch_pronouns('I ... | [
"0.87323207",
"0.85730827",
"0.831533",
"0.82682353",
"0.6167959",
"0.5877165",
"0.5877165",
"0.5872348",
"0.5810333",
"0.56944364",
"0.56425726",
"0.56394184",
"0.5601467",
"0.55877566",
"0.5563721",
"0.55607045",
"0.5539707",
"0.552242",
"0.5400427",
"0.53895354",
"0.538016... | 0.8657003 | 1 |
Test more complex sentence switches using switch_pronouns | def test_mixed_pronouns
assert_equal("you gave me life",
WordPlay.switch_pronouns("i gave you life"))
assert_equal("i am not what you are",
WordPlay.switch_pronouns("you are not what i am"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_complex_pronouns\n assert_equal('yes, I rule', WordPlay.switch_pronouns('yes, you rule'))\n assert_equal('Am I stupid?', WordPlay.switch_pronouns('are u stupid?'))\n assert_equal('why do i cry?', WordPlay.switch_pronouns('why do you cry?'))\n end",
"def test_complex_pronouns\n\t\tassert_equal(... | [
"0.75419617",
"0.7539772",
"0.7229998",
"0.71595824",
"0.6289475",
"0.61194956",
"0.5983515",
"0.5761694",
"0.57021093",
"0.56883323",
"0.5654398",
"0.56201804",
"0.55753523",
"0.5556518",
"0.55551314",
"0.55510956",
"0.55510956",
"0.55227166",
"0.5508784",
"0.548933",
"0.548... | 0.7197868 | 3 |
Initializes the bot object, loads in the external YAML data file and sets the bot's name. Raises an exception if the data loading process fails. | def initialize(options)
@name = options[:name] || "Unnamed Bot"
begin
@data = YAML.load(File.open(options[:data_file]).read)
rescue
raise "Can't load bot data"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(options)\n\t\t@name = options[:name] || \"Unnamed Bot\" # name = name otherwise it is an Unnamed bot\n\t\tbegin\n\t\t\t@data = YAML.load(File.read(options[:data_file]))\n\t\trescue \n\t\t\traise \"Can't load bot data\"\n\t\tend\n\tend",
"def initialize(options)\n\t\t@name = options[:name] || \"Unn... | [
"0.771837",
"0.7648457",
"0.7572003",
"0.61225015",
"0.5986048",
"0.58580446",
"0.58363676",
"0.583599",
"0.5745516",
"0.57450503",
"0.57012063",
"0.55806094",
"0.55806094",
"0.55789787",
"0.5577239",
"0.55616033",
"0.55525935",
"0.55413663",
"0.5503913",
"0.5503913",
"0.5502... | 0.7728877 | 0 |
Returns a random greeting as specified in the bot's data file | def greeting
random_response(:greeting)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def greeting\n greetings = [\"Hello\", \"Hey\", \"Greetings\", \"Salutations\", \"Welcome\"]\n greetings[rand(greetings.size)]\n end",
"def greeting\n\t\trandom_response(:greeting)\n\tend",
"def generate_greeting\n languages = %w[French Spanish English Italian Hindi Japanese Korean Chinese Tamil... | [
"0.79042333",
"0.7470434",
"0.7464322",
"0.7300656",
"0.72177225",
"0.71532494",
"0.68522143",
"0.67995834",
"0.66879225",
"0.6538214",
"0.65081817",
"0.65005773",
"0.64713556",
"0.6391153",
"0.63380754",
"0.6309222",
"0.6291592",
"0.62910813",
"0.62583596",
"0.62285316",
"0.... | 0.7460681 | 3 |
Returns a random farewell message as specified in the bot's data file | def farewell
random_response(:farewell)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_message()\n\t\topening = [ \"Developer Portfolio\",\n \t\t\"My Rails 4 Portfolio\",\n \t\t\"Hello World\" ]\n\n\t\tmiddle = [ \"Built from the Rails Tutorial\",\n \t\t\"Rails Apps Are Great\",\n \t\t\"Rails Twitter clone App\" ]\n\n\t\tending = [ \"Conta... | [
"0.6953912",
"0.67429435",
"0.6358108",
"0.6257348",
"0.6242795",
"0.62339854",
"0.60725987",
"0.6047887",
"0.60347754",
"0.60271317",
"0.5987562",
"0.5970796",
"0.59435695",
"0.58729434",
"0.58692855",
"0.5856846",
"0.578567",
"0.57726103",
"0.577092",
"0.57657737",
"0.57480... | 0.5912561 | 13 |
Responds to input text as given by a user | def response_to(input)
prepared_input = preprocess(input.downcase)
sentence = best_sentence(prepared_input)
reversed_sentence = WordPlay.switch_pronouns(sentence)
responses = possible_responses(sentence)
responses[rand(responses.length)]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text_input; end",
"def set_text_input(input); end",
"def input_model_text(new_text)\n pending(\"proper input text method that triggers all normal events\")\n fail\n end",
"def text(text_input_handle)\n end",
"def ask(text)\n say(text)\n @bot.listen do |message|\n return m... | [
"0.73320746",
"0.7157467",
"0.7041897",
"0.6928743",
"0.6844111",
"0.6514488",
"0.6500375",
"0.6428982",
"0.6405315",
"0.6320323",
"0.6285531",
"0.62815255",
"0.62593013",
"0.625168",
"0.6176133",
"0.6174668",
"0.61628026",
"0.6137685",
"0.60880244",
"0.6085792",
"0.6085792",... | 0.0 | -1 |
Chooses a random response phrase from the :responses hash and substitutes metadata into the phrase | def random_response(key)
random_index = rand(@data[:responses][key].length)
@data[:responses][key][random_index].gsub(/\[name\]/, @name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_response(key)\n\t\trandom_index = rand(@data[:responses][key].length)\n\t\t@data[:responses][key][random_index].gsub(/\\[name\\]/,@name)\n\tend",
"def response_to(input)\n prepared_input = preprocess(input.downcase)\n sentence = best_sentence(prepared_input)\n reversed_sentence = WordPlay.swi... | [
"0.72853094",
"0.6784648",
"0.6619443",
"0.6593563",
"0.6586191",
"0.6484881",
"0.63402075",
"0.6267631",
"0.6192105",
"0.6165832",
"0.60533893",
"0.60341126",
"0.590889",
"0.58956814",
"0.5831062",
"0.57584804",
"0.5692721",
"0.5670045",
"0.5644329",
"0.56239384",
"0.5616981... | 0.73591137 | 0 |
Performs preprocessing tasks upon all input to the bot | def preprocess(input)
perform_substitutions(input)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess(input); end",
"def pre_process\n end",
"def preprocess_input(input)\nend",
"def pre_process(message)\n end",
"def process_input(raw_input)\n @engine.inject_command(normalized_input(raw_input), self)\n @engine.execute_pending_commands\n end",
"def processed_input!\n ... | [
"0.6466349",
"0.64644665",
"0.64398235",
"0.6390602",
"0.6235506",
"0.60365945",
"0.60285026",
"0.595726",
"0.59250295",
"0.59217334",
"0.5908038",
"0.58805287",
"0.5863677",
"0.5779307",
"0.5761706",
"0.57403475",
"0.5695637",
"0.5661843",
"0.5655688",
"0.56481344",
"0.56270... | 0.58195215 | 13 |
Substitutes words and phrases on supplied input as dictated by the bot's :presubs data | def perform_substitutions(input)
@data[:presubs].each { |s| input.gsub!(s[0], s[1]) }
input
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translator\n # Greet your user in the language of their people.\n puts [\"SUP KID? \",\n \t \"What didja say? \",\n \t \"How ya doan? \",\n \t \"How ahrya?\",\n \t \"How 'bout them Sox? \",\n \t \"How 'bout them Pats? \"].sample\n\n # Get their response and lop off the carriage return, Massachusetts Le... | [
"0.68777394",
"0.67341346",
"0.67172587",
"0.6672194",
"0.6643442",
"0.6517552",
"0.6492399",
"0.6474987",
"0.6468659",
"0.64544314",
"0.64428633",
"0.64399314",
"0.6407532",
"0.63612056",
"0.6349674",
"0.63430846",
"0.6334027",
"0.6243357",
"0.62378657",
"0.6188131",
"0.6142... | 0.7240941 | 0 |
Using the single word keys from :responses, we search for the sentence that uses the most of them, as it's likely to be the 'best' sentence to parse | def best_sentence(input)
hot_words = @data[:responses].keys.select do |k|
k.class == String && k =~ /^\w+$/
end
WordPlay.best_sentence(input.sentences, hot_words)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def possible_responses(sentence)\n responses = []\n\n # Find all patterns to try to match against\n @data[:responses].keys.each do |pattern|\n next unless pattern.is_a?(String)\n\n # For each pattern, see if the supplied sentence contains\n # a match. Remove substitution symbols (*) before checking.\... | [
"0.7121943",
"0.67639285",
"0.6570952",
"0.62986463",
"0.6152937",
"0.612665",
"0.60802275",
"0.6064807",
"0.6060163",
"0.60441655",
"0.6015933",
"0.5998066",
"0.59933066",
"0.59491307",
"0.5948895",
"0.5944669",
"0.59445024",
"0.59289426",
"0.59289426",
"0.5908157",
"0.58794... | 0.71103525 | 1 |
Using a supplied sentence, go through the bot's :responses data set and collect together all phrases that could be used as responses | def possible_responses(sentence)
responses = []
# Find all patterns to try to match against
@data[:responses].keys.each do |pattern|
next unless pattern.is_a?(String)
# For each pattern, see if the supplied sentence contains
# a match. Remove substitution symbols (*) before checking.
# Push all responses to the responses array.
if sentence.match('\b' + pattern.gsub(/\*/, '') + '\b')
# If the pattern contains substitution placeholders,
# perform the substitutions
if pattern.include?('*')
responses << @data[:responses][pattern].collect do |phrase|
# First, erase everything before the placeholder
# leaving everything after it
matching_section = sentence.sub(/^.*#{pattern}\s+/, '')
# Then substitute the text after the placeholder, with
# the pronouns switched
phrase.sub('*', WordPlay.switch_pronouns(matching_section))
end
else
# No placeholders? Just add the phrases to the array
responses << @data[:responses][pattern]
end
end
end
# If there were no matches, add the default ones
responses << @data[:responses][:default] if responses.empty?
# Flatten the blocks of responses to a flat array
responses.flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def phrases\n response[\"phrases\"]\n end",
"def response_to(input)\n\t\tprepared_input = preprocess(input).downcase # Taking the input, processing and prepare it\n\t\tsentence = best_sentence(prepared_input) # Finding the best sentence to use based on input\n\t\tresponses = possible_responses(senten... | [
"0.6112034",
"0.6044615",
"0.60339415",
"0.59371984",
"0.5903337",
"0.5884288",
"0.5847992",
"0.57185256",
"0.5692795",
"0.5614652",
"0.55741954",
"0.55661863",
"0.55509245",
"0.55509245",
"0.5526807",
"0.5525261",
"0.550257",
"0.54948574",
"0.54942715",
"0.54906434",
"0.5456... | 0.8276681 | 0 |
total number of hosts available for the specified zone. It is the same value as provided in the XQueryCount header in the list_hosts API method ==== Returns response: body 'count' 'status' 200 indicates success | def count_hosts( zone_id)
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Zerigo::DNS::CountHosts.new,
:path => "/api/1.1/zones/#{zone_id}/hosts/count.xml"
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_host_templates\n get(\"zone_templates/#{id}/host_templates/count.xml\").body['count'].to_i\n end",
"def count(zone_id, version_id)\n call('domain.zone.record.count', zone_id, version_id)\n end",
"def zone_available_ip_count(zone_name, plan = nil)\n parameters = \"zone=#... | [
"0.7250891",
"0.68440694",
"0.6837091",
"0.6783943",
"0.6515743",
"0.6267639",
"0.6122488",
"0.5923488",
"0.585694",
"0.5724265",
"0.57075244",
"0.5673514",
"0.56047374",
"0.5581793",
"0.5523989",
"0.54913",
"0.54732513",
"0.54730624",
"0.54643935",
"0.5456252",
"0.54331946",... | 0.8165326 | 0 |
Expected date format: "MM/DD/YYYY" Time string: "HH:MM AM/PM" | def parse_usa_date(date, time_string = nil)
date = date.to_s.strip
# TODO: Many tests pass either a Date, a Time, or an YYYY-MM-DD formatted
# string as a parameter. This conditional will handle those cases. We should
# probably go through and clean up the tests at some point.
date = format_usa_date(Date.parse(date)) if date =~ /\A\d{4}-\d{2}-\d{2}/
return unless usa_formatted_date?(date)
date_string = Date.strptime(date, "%m/%d/%Y").to_s
date_string += " #{time_string}" if time_string
Time.zone.parse(date_string)
rescue ArgumentError
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_registration_time(date_time)\n format_time = DateTime.strptime(date_time, '%m/%d/%y %H:%M')\nend",
"def appt_date_time_formatter(time, date)\n apptHour = (time[0] + time[1]).to_i\n apptMin = (time[3] + time[4]).to_i\n if time.match(\"PM\")\n apptHour += 12\n end\n appt_date = date... | [
"0.69543517",
"0.6395716",
"0.6341991",
"0.6246984",
"0.6222652",
"0.6206912",
"0.6203109",
"0.6148219",
"0.6068987",
"0.6027255",
"0.6025781",
"0.6009908",
"0.6009268",
"0.6000338",
"0.5980418",
"0.5980075",
"0.5967324",
"0.5957498",
"0.59498614",
"0.5943719",
"0.59269905",
... | 0.0 | -1 |
This is to DRY up many of the legacy places where hour/min/meridian is used in forms | def time_select(f, field, options_tag = {}, html_options = {})
output = f.select(:"#{field}_hour", (1..12).to_a, {}, html_options.merge("aria-label": f.object.class.human_attribute_name("#{field}_hour")))
output.safe_concat f.select(:"#{field}_min", minute_options(options_tag[:minute_step]), {}, html_options.merge("aria-label": f.object.class.human_attribute_name("#{field}_min")))
output.safe_concat f.select(:"#{field}_meridian", %w(AM PM), {}, html_options.merge("aria-label": f.object.class.human_attribute_name("#{field}_meridian")))
content_tag :div, output, class: "time-select"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_select_for(select_start, select_end) #bcoz time_select name is already a rails helper\n #need to map time_choices to am_pm view format and normal time save format -H\n get_time_choices(select_start, select_end, min_block).map {|t| [t.to_s(:am_pm), t]}\n end",
"def format_of_datetimes\n # if is... | [
"0.6315542",
"0.60712105",
"0.6051282",
"0.5934058",
"0.5899801",
"0.5884512",
"0.5881669",
"0.58720845",
"0.5861623",
"0.5851576",
"0.5851396",
"0.58484447",
"0.5819397",
"0.5792184",
"0.5790428",
"0.57732356",
"0.5757192",
"0.57281387",
"0.57235205",
"0.5705814",
"0.5682995... | 0.5790238 | 15 |
Check if the rule is enabled | def enabled?
@metadata.fetch(:enabled, true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_matching_rules_are_enabled(rule_state)\n modify_matching_rules(method(:verify_rule_exists_and_is_enabled), rule_state, nil)\n end",
"def verify_rule_exists_and_is_enabled(rule_name, _firewall_name, _data)\n raise \"Firewall rule '#{rule_name}' does not exist so cannot be enabled\" unless ... | [
"0.70113635",
"0.6768937",
"0.66756785",
"0.6654105",
"0.6654105",
"0.6648568",
"0.6600669",
"0.6541667",
"0.6504297",
"0.6504297",
"0.64850235",
"0.6483539",
"0.6482845",
"0.64401436",
"0.6406674",
"0.6405627",
"0.6405627",
"0.6405627",
"0.6405627",
"0.6397248",
"0.6392036",... | 0.0 | -1 |
ScrapsController > show_scrap_topic : Render scrap topic to browser | def show_scrap_topic
render_404 and return if @scrap_topic.nil?
@scraps = @scrap_topic.scraps if @scrap_topic
flash[:notice] = 'This topic is empty, please add some scraps.'[:msg_empty_topic_add_scraps] if @scraps.length == 0
respond_to do |format|
format.html { render :action => 'scrap_topic' and return }
format.js { render :action => 'scrap_topic', :layout => false and return }
format.xml { return }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_inline_scrap_topic\n respond_to do |format|\n format.html { redirect_to scrap_topic_path(@scrap.scrap_topic.slug) and return }\n format.js { @scraps = @scrap_topic.scraps if @scraps.nil?; render :partial => \"scrap\", :layout => false and return }\n format.xml { return }\n ... | [
"0.7173283",
"0.6974418",
"0.6898802",
"0.6822776",
"0.67724544",
"0.6731785",
"0.66351664",
"0.66268706",
"0.660618",
"0.6552798",
"0.6542236",
"0.6542236",
"0.6542236",
"0.6542236",
"0.65344536",
"0.65113366",
"0.6502551",
"0.64953625",
"0.64294374",
"0.6399049",
"0.6371876... | 0.7615448 | 0 |
ScrapsController > new_scrap_topic : Render new scrap topic form to browser | def new_scrap_topic
@scrap_topic = ScrapTopic.new
respond_to do |format|
format.html { return }
format.js { render :action => 'new_scrap_topic', :layout => false and return }
format.xml { return }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_topic\n click_link 'Add Topic' \n within 'form' do\n fill_in( 'Title', with: 'Shoes' )\n fill_in( 'Description', with: 'Shoes of desire' )\n click_button 'save' \n end\n end",
"def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n e... | [
"0.6986612",
"0.69399065",
"0.68541425",
"0.68117905",
"0.6781969",
"0.6774142",
"0.6752361",
"0.66998386",
"0.66387737",
"0.6631269",
"0.6629747",
"0.6596712",
"0.65840435",
"0.655308",
"0.653429",
"0.6531935",
"0.6494144",
"0.6494144",
"0.6494144",
"0.6494144",
"0.6494144",... | 0.783379 | 0 |
ScrapsController > create_scrap_topic : Create new scrap topic and render to browser | def create_scrap_topic
@scrap_topic = ScrapTopic.new
@scrap_topic.title = params[:scrap_topic][:title].strip
@scrap_topic.user_id = current_user.id
begin
ScrapTopic.transaction do
tag = Tag.find_or_create_by_name(params[:scrap_topic][:title].strip)
@scrap_topic.save!
respond_to do |format|
format.html do
flash[:notice] = 'Topic successfully created'[:msg_topic_created]
redirect_to scrap_topic_path(@scrap_topic.slug)
end
format.js { show_scrap_topic and return }
format.xml { return }
end
end
rescue
respond_to do |format|
format.html { render :action => 'new_scrap_topic' and return }
format.js { render :action => 'new_scrap_topic', :layout => false and return }
format.xml { return }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_scrap_topic\n @scrap_topic = ScrapTopic.new\n respond_to do |format|\n format.html { return }\n format.js { render :action => 'new_scrap_topic', :layout => false and return }\n format.xml { return }\n end\n end",
"def create\n return if cancelled?\n begin\n if params[:... | [
"0.77216476",
"0.7318679",
"0.72042066",
"0.7189846",
"0.7126289",
"0.7122961",
"0.7110386",
"0.7031366",
"0.7031366",
"0.7017458",
"0.7017458",
"0.70102733",
"0.7008804",
"0.6986532",
"0.6983561",
"0.6973378",
"0.696002",
"0.69316626",
"0.6923276",
"0.6884412",
"0.68751824",... | 0.7519294 | 1 |
ScrapsController > edit_scrap_topic : Render edict scrap topic form to browser | def edit_scrap_topic
if can_modify_scrap_topic?
respond_to do |format|
format.html { return }
format.js { render :action => 'edit_scrap_topic', :layout => false and return }
format.xml { return }
end
else
render_401 and return
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n frm.button(:value=>\"Edit\").click\n AddEditAnnouncements.new(@browser)\n end",
"def edit\n # return an HTML form for editing a specific message\n end",
"def edit\n # return an HTML form for editing a specific message\n end",
"def edit\n # return an HTML form for editing ... | [
"0.6503634",
"0.6389094",
"0.6389094",
"0.6387619",
"0.6355652",
"0.62464166",
"0.62464166",
"0.62464166",
"0.62464166",
"0.62464166",
"0.62464166",
"0.62464166",
"0.62464166",
"0.62464166",
"0.62464166",
"0.62464166",
"0.62464166",
"0.62464166",
"0.62464166",
"0.62464166",
"... | 0.69367373 | 0 |
ScrapsController > update_scrap_topic : Update scrap topic and render to browser NOT IMPLEMENTED! | def update_scrap_topic
# Not allowed for now
render_401 and return
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_scrap_topic\n if can_modify_scrap_topic?\n respond_to do |format|\n format.html { return }\n format.js { render :action => 'edit_scrap_topic', :layout => false and return }\n format.xml { return }\n end\n else\n render_401 and return\n end\n end",
"def updat... | [
"0.6591119",
"0.64784265",
"0.6426784",
"0.63999075",
"0.6395567",
"0.6357706",
"0.6332408",
"0.63239807",
"0.63239354",
"0.6258436",
"0.6236693",
"0.62352145",
"0.62208545",
"0.6215314",
"0.6213119",
"0.6212678",
"0.6205931",
"0.6199405",
"0.6181844",
"0.6180103",
"0.6145935... | 0.7629243 | 0 |
ScrapsController > show : Render scrap to browser, right now only used by ParallelText scraps | def show
render_404 and return if @scrap.nil?
respond_to do |format|
format.html { redirect_to show_scrap_path(@scrap.slug) and return }
format.js { render :action => "scrap", :layout => false and return }
format.xml { return }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scrap\n target_url = CGI.unescape(params[:target_url])\n css_selector = CGI.unescape(params[:css_selector])\n @element_id = params[:ele_id]\n\n @scrapped_text = QuickScrapper.scrap(target_url, css_selector)\n first_word_index = params[:first_word_index] || 0\n last_word_index = params[:last_w... | [
"0.67932236",
"0.66783774",
"0.6636916",
"0.6622841",
"0.65262365",
"0.65173715",
"0.6498611",
"0.64275295",
"0.63732743",
"0.63636744",
"0.6354494",
"0.63435",
"0.6343397",
"0.63291085",
"0.6305021",
"0.63038",
"0.62529355",
"0.6230974",
"0.6214712",
"0.6199106",
"0.6199106"... | 0.6803512 | 0 |
ScrapsController > new : Render new scrap form to browser | def new
return if !scrap_user_logged_in?(true) # check if logged in!
scrap_type = params[:type].downcase
if !scrap_type.nil?
@scrap = Definition.new if scrap_type == "definition"
@scrap = ParallelText.new if scrap_type == "parallel_text"
@scrap = Bookmark.new if scrap_type == "bookmark"
@scrap = Webscrap.new if scrap_type == "webscrap"
@scrap = Note.new if scrap_type == "note"
end
respond_to do |format|
format.html { return }
format.js { render :action => 'new', :layout => false and return }
format.xml { return }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @scrape = Scrape.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @scrape }\n end\n end",
"def new\n @scraper = Scraper.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @scraper }\n en... | [
"0.76355785",
"0.74854714",
"0.7358928",
"0.7008288",
"0.7008288",
"0.69642407",
"0.69047505",
"0.6857759",
"0.6790858",
"0.67562354",
"0.67333525",
"0.669947",
"0.6681327",
"0.667842",
"0.66541934",
"0.66541934",
"0.6627337",
"0.65997744",
"0.65436876",
"0.6542903",
"0.65172... | 0.72693706 | 3 |
ScrapsController > create : Create the new scrap and render it to browser | def create
return if cancelled?
begin
if params[:scrap][:type] == "ParallelText"
@scrap = ParallelText.new(params[:scrap])
@scrap.scrap_topic = Corpus.by_language(params[:scrap][:language_id])
else
if params[:scrap][:type] == "Definition"
@scrap = Definition.new(params[:scrap])
elsif params[:scrap][:type] == "Webscrap"
@scrap = Webscrap.new(params[:scrap])
elsif params[:scrap][:type] == "Bookmark"
@scrap = Bookmark.new(params[:scrap])
else
@scrap = Note.new(params[:scrap])
end
if @scrap_topic.nil? or @scrap_topic.id == nil
#Initiatlize a new scrap topic!
@scrap.scrap_topic = init_scrap_topic(params[:scrap_topic_title], current_user.id)
else
#Assign existing scrap topic
@scrap.scrap_topic = @scrap_topic
end
end
@scrap.save!(current_user)
if @scrap.class.to_s =="ParallelText"
respond_to do |format|
format.html { redirect_to show_scrap_path(@scrap.slug) and return }
format.js { render :action => "scrap", :layout => false and return }
format.xml { return }
end
else
respond_to do |format|
format.html { redirect_to scrap_topic_path(@scrap.scrap_topic.slug) and return }
format.js { @scraps = @scrap_topic.scraps if !@scrap_topic.scraps.nil?; render :action => "scrap_topic", :layout => false and return }
format.xml { return }
end
end
rescue
#
# Re-Display On Error
respond_to do |format|
format.html { render :action => "new" and return }
format.js { render :partial => "scrap_form", :layout => false and return }
format.xml { return }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @scrape = Scrape.new(params[:scrape])\n\n respond_to do |format|\n if @scrape.save\n @scrape.scrape\n format.html { redirect_to @scrape, notice: 'Scrape was successfully created.' }\n format.json { render json: @scrape, status: :created, location: @scrape }\n else\... | [
"0.80744475",
"0.7778039",
"0.76924783",
"0.76104885",
"0.74438995",
"0.73362845",
"0.7316132",
"0.72897065",
"0.719924",
"0.7188424",
"0.7180798",
"0.71475816",
"0.7122113",
"0.70296085",
"0.70077854",
"0.68395853",
"0.67626953",
"0.6747307",
"0.6736169",
"0.6679923",
"0.665... | 0.6914642 | 15 |
ScrapsController > edit : Updates current scrap and renders it to browser | def edit
respond_to do |format|
format.html { render :action => "edit" and return }
format.js { render :partial => "scrap_form", :layout => false and return }
format.xml { return }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @scrape = Scrape.find(params[:id])\n\n respond_to do |format|\n if @scrape.update_attributes(params[:scrape])\n format.html { redirect_to @scrape, notice: 'Scrape was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: ... | [
"0.7395853",
"0.73111856",
"0.7077767",
"0.7060149",
"0.70252997",
"0.67497605",
"0.6723607",
"0.66683567",
"0.6651717",
"0.65707445",
"0.65563023",
"0.6518461",
"0.6495175",
"0.64947253",
"0.6490674",
"0.6487269",
"0.6487269",
"0.6487269",
"0.6487269",
"0.6487269",
"0.648726... | 0.69530123 | 5 |
ScrapsController > update : Updates current scrap and renders it to browser | def update
if params[:cancel]
if @scrap.class.to_s =="ParallelText"
display_inline_scrap
else
display_inline_scrap_topic
end
return # redisplay the scrap inline
end
return if !scrap_user_logged_in? # check if logged in!
old = @scrap.attributes.to_yaml
@scrap.update_attributes(params[:scrap])
mod = @scrap.attributes.to_yaml
begin
@scrap.save!(current_user) if mod != old
if @scrap.class.to_s =="ParallelText"
display_inline_scrap
else
display_inline_scrap_topic
end
rescue
#
# Re-Display On Error
edit and return
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @scrape.update(scrape_params)\n ScrapeData.new.delay.perform(@scrape.id)\n format.html { redirect_to @scrape, notice: 'Scrape was successfully updated.' }\n format.json { render :show, status: :ok, location: @scrape }\n else\n format... | [
"0.72798944",
"0.7273655",
"0.721352",
"0.7153968",
"0.7131865",
"0.68629223",
"0.6850184",
"0.6585177",
"0.65671057",
"0.65306187",
"0.650629",
"0.650629",
"0.65022796",
"0.65022796",
"0.65022796",
"0.65022796",
"0.6497105",
"0.64826274",
"0.6477269",
"0.6477269",
"0.6477269... | 0.67377216 | 7 |
ScrapsController > display_inline_scrap : Renders the current scrap or scrap topic to the browser | def display_inline_scrap_topic
respond_to do |format|
format.html { redirect_to scrap_topic_path(@scrap.scrap_topic.slug) and return }
format.js { @scraps = @scrap_topic.scraps if @scraps.nil?; render :partial => "scrap", :layout => false and return }
format.xml { return }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scrap\n target_url = CGI.unescape(params[:target_url])\n css_selector = CGI.unescape(params[:css_selector])\n @element_id = params[:ele_id]\n\n @scrapped_text = QuickScrapper.scrap(target_url, css_selector)\n first_word_index = params[:first_word_index] || 0\n last_word_index = params[:last_w... | [
"0.61379623",
"0.59060216",
"0.5880602",
"0.57654727",
"0.5665489",
"0.5661925",
"0.5659657",
"0.56046224",
"0.55786324",
"0.5577934",
"0.5569858",
"0.556565",
"0.5555811",
"0.55445313",
"0.55406237",
"0.5535658",
"0.55289745",
"0.552309",
"0.5522136",
"0.552085",
"0.5519992"... | 0.7434202 | 0 |
(scrap_topic) init_scrap_topic : Creates a scrap topic based on the new slug | def init_scrap_topic(title, user_id)
@scrap_topic = ScrapTopic.find_or_create_by_title(:title => title, :user_id => user_id, :parent_id => 0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_topic\n if params[:id].nil?\n @topic = Topic.find_by(:permalink => params[:permalink])\n else\n @topic = Topic.find(params[:id])\n end\n end",
"def initialize(topic,prepend=\"\")\n @wiki ||= Wikipedia.find(prepend + topic)\n end",
"def create_topic!\n fora.pos... | [
"0.65486634",
"0.6187992",
"0.61843497",
"0.602363",
"0.6020988",
"0.6015673",
"0.5903364",
"0.59011114",
"0.58880544",
"0.58880544",
"0.5865893",
"0.5862448",
"0.5818125",
"0.58098865",
"0.57671744",
"0.56731987",
"0.56700873",
"0.56687266",
"0.56652015",
"0.5644188",
"0.561... | 0.7712068 | 0 |
(true) autoload_scrap_data : Loads scrap / scrap_topic data into request scope | def autoload_scrap_data
#
# Get ScrapTopic identifier from the querystring
if params[:scrap_topic_title]
scrap_topic_title = params[:scrap_topic_title]
elsif params[:scrap_topic_id]
if params[:scrap_topic_id].class == Array
scrap_topic_id = params[:scrap_topic_id][0]
else
scrap_topic_id = params[:scrap_topic_id]
end
end
#
# TRY getting @scrap_topic by id
if scrap_topic_id.to_i > 0
@scrap_topic = ScrapTopic.find_by_id(scrap_topic_id.to_i)
#
# TRY getting @scrap_topic by slug
else
scrap_topic_id = params[:scrap_topic_title] if params[:scrap_topic_title]
@scrap_topic = ScrapTopic.find_by_slug_cache(scrap_topic_id)
end
#
# TRY getting @scrap by slug/id
if params[:id]
if params[:id].to_i > 0
@scrap = Scrap.find_by_id(params[:id].to_i)
@scrap_topic = @scrap_topic if @scrap and @scrap_topic.nil?
elsif params[:id]
@scrap = Scrap.find_by_slug_cache(params[:id])
@scrap_topic = @scrap_topic if @scrap and @scrap_topic.nil?
end
end
#
# Get @scrap_topic from @scrap if @scrap_topic not set
@scrap_topic ||= @scrap.scrap_topic if @scrap
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_data\n subclass_must_define\n end",
"def eager_load; end",
"def eager_load; end",
"def eager_load; end",
"def load_data\n # @categories = Category.find(:all)\n # @infoitems = Expert.find(:all)\n end",
"def load_feed\n \n @url_data_params ||= {}\n response = Fello... | [
"0.56630254",
"0.55869997",
"0.55869997",
"0.55869997",
"0.5576264",
"0.5533455",
"0.5526879",
"0.5526879",
"0.5526879",
"0.5526879",
"0.5438506",
"0.53440136",
"0.53169787",
"0.53122896",
"0.5303988",
"0.52137566",
"0.52052563",
"0.52052563",
"0.52052563",
"0.51941466",
"0.5... | 0.79650456 | 0 |
(boolean) can_modify_scrap_topic? : Return true if current user can modify the scrap | def can_modify_scrap_topic?
return (admin? or @scrap_topic.scraps.length == 0 or (logged_in? and @scrap_topic.user_id == current_user.id))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorized_to_modify_task?\n current_user.site_admin? || can_view_all_manuscript_managers_for_journal? || can_view_manuscript_manager_for_paper? ||\n allowed_manuscript_information_task? || metadata_task_collaborator? || allowed_reviewer_task? || task_participant?\n end",
"def reseller_allow_edit(perm... | [
"0.686958",
"0.66173726",
"0.6583648",
"0.6569846",
"0.6475908",
"0.6414751",
"0.6406812",
"0.6400748",
"0.63820064",
"0.6372664",
"0.6336224",
"0.63320404",
"0.63004464",
"0.6294726",
"0.62846977",
"0.62694776",
"0.6267185",
"0.62453514",
"0.6241524",
"0.62254846",
"0.622548... | 0.86594677 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.