text stringlengths 10 2.61M |
|---|
class CentralDeAlarmesController < ApplicationController
before_action :set_central_de_alarme, only: [:show, :edit, :update, :destroy]
# GET /central_de_alarmes
# GET /central_de_alarmes.json
def index
@central_de_alarmes = CentralDeAlarme.all
end
# GET /central_de_alarmes/1
# GET /central_de_alarme... |
class Cart < ApplicationRecord
belongs_to :customer
has_and_belongs_to_many :products
end
|
require 'test_helper'
class CommentsControllerTest < ActionDispatch::IntegrationTest
setup do
@post = posts(:one)
@comment = comments(:one)
# @post = posts(@comment.post_id)
end
test "should get index" do
get post_comment_url(@post, @comment)
assert_response :success
end
test "should ge... |
# Source: http://www.secg.org/collateral/sec2_final.pdf
module ECDSA
class Group
Secp128r2 = new(
name: 'secp128r2',
p: 0xFFFFFFFD_FFFFFFFF_FFFFFFFF_FFFFFFFF,
a: 0xD6031998_D1B3BBFE_BF59CC9B_BFF9AEE1,
b: 0x5EEEFCA3_80D02919_DC2C6558_BB6D8A5D,
g: [0x7B6AA5D8_5E572983_E6FB32A7_CDEBC14... |
require ("minitest/autorun")
require ("minitest/rg")
require_relative("../sports_team.rb")
class TestSportsTeam < MiniTest::Test
def setup
@scotland = SportsTeam.new("Scotland", ["Smith", "Brown", "White", "Jones", "Irvine"], "Mr Coach")
end
# getter methods below
def test_get_team_name
assert_equal("Scotland",... |
class AdddTimeZoneOffsetToArticles < ActiveRecord::Migration
def change
add_column :articles, :timeZoneOffset, :integer, :default => 0
end
end
|
# encoding: UTF-8
require "knapsack/recipe"
require "knapsack/utils"
require "knapsack/logger"
module Knapsack
def logger
@logger ||= Knapsack::Logger.new(STDOUT)
end
module_function :logger
def activated_recipes
@activated_recipes ||= {}
end
module_function :activated_recipes
def root
@ro... |
require 'pathname'
Puppet::Type.newtype(:dehydrated_pfx) do
desc 'pkcs12 / pfx files for dehydrated'
ensurable
newparam(:path, namevar: true) do
validate do |value|
path = Pathname.new(value)
unless path.absolute?
raise ArgumentError, "Path must be absolute: #{path}"
end
end
... |
module SupplyTeachers
class Journey::PayrollProvider
include Steppable
attribute :payroll_provider
validates :payroll_provider, inclusion: ['school', 'agency']
def next_step_class
case payroll_provider
when 'school'
Journey::FTACalculatorContractStart
when 'agency'
... |
require 'net/imap'
require 'mail'
require 'yaml'
#Retrieve settings from external file
settings = YAML.load_file('settings.yml')
#Start the actual work
imap = Net::IMAP.new(settings['imap_host'], settings['imap_port'], settings['imap_ssl'], nil, false)
if settings['imap_auth_mechanism'].nil?
imap.login(settings['im... |
class CoversController < ApplicationController
before_filter :set_image_filter
def index
@files = new_files({quality: selectable_qualities.last, filter: :no_op})
end
def show
@isbn13 = params['isbn13']
@original = filename_from_isbn(params['isbn13'])
if @filter == :all
@files = image... |
class ChangePhotoUrlNameWeddingPhotos < ActiveRecord::Migration[5.2]
def change
rename_column :wedding_photos, :photo_url, :photo
end
end
|
class AddEventUserToEventItems < ActiveRecord::Migration
def change
add_reference :event_items, :event_user, index: true, foreign_key: true
end
end
|
require 'spec_helper'
require 'helpers/property'
require 'dm-core/property/legacy/uri_text'
describe DataMapper::Property::Legacy::URIText do
include Helpers::Property
before(:all) do
property(DataMapper::Property::Legacy::URIText)
end
let(:raw_text) { 'one two' }
let(:uri_text) { 'one%20two' }
des... |
# frozen_string_literal: true
require "spec_helper"
require "decrease"
require "single_crochet"
RSpec.describe Decrease, type: :model do
subject { described_class.new([SingleCrochet.new]) }
describe "#make" do
it "returns dec" do
expect(subject.make).to eq "sc dec"
end
end
describe "#abbrev" do... |
require 'rspec'
require_relative '../lib/perro.rb'
require_relative '../lib/gris.rb'
require_relative '../lib/blanco.rb'
require_relative '../lib/negro.rb'
require_relative '../lib/marron.rb'
describe 'PerroTest' do
it'deberia poder instanciar un Perro'do
Perro.new()
end
it'deberia poder instanciar un Perr... |
# Implement octal to decimal conversion. Given an octal input string, your program should produce a decimal output.
# The rightmost digit gets multiplied by 100 = 1
# The next number gets multiplied by 101 = 10
# ...
# The n*th number gets multiplied by 10n-1*.
# All these values are summed.
class Octal
BA... |
class Api::FeedController < ApplicationController
before_action :login_required_api
params_required :url , only: :discover
params_required :feedlink, only: :subscribe
params_required :subscribe_id, only: [:unsubscribe, :update, :move]
params_required [ :subscribe_id, :rate ], only: :set_rate
par... |
class DirectionDecorator < Draper::Decorator
delegate_all
def to_jsonable(options={})
{
direction: step,
image: image
}
end
end
|
module SequelSpec
module Matchers
module Validation
class ValidateMatcher < Base
def valid?(db, instance, klass, attribute, options)
additionnal_param_check if self.respond_to?(:additionnal_param_check)
instance = instance.dup
instance.class.columns
called =... |
require 'omniauth-oauth2'
module OmniAuth
module Strategies
class Pinterest < OmniAuth::Strategies::OAuth2
option :client_options, {
:site => 'https://api.pinterest.com/',
:authorize_url => 'https://api.pinterest.com/oauth/',
:token_url => 'https://api.pinterest.com/v1/oauth/token'
... |
module Sinatra::Helpers
# URL Helpers
def link_to(title, path, *args)
options = args.extract_options!
html_options = options.delete(:html) || {}
"<a href='%s' %s>%s</a>" % [url_for(path, options), html_options.to_attributes, title]
end
def image_tag(path, *args)
options = args.extract_option... |
class AddCompanyUrlToResponses < ActiveRecord::Migration
def change
add_column :responses, :companyURL, :string
end
end
|
#navigation
When(/^I visit "(.*?)"$/) do |path|
visit path
end
#debug
When(/^I print$/) do
print page.html
end
When /^I debug$/ do
p current_path
p page.response_headers
end
When /^I wait (.*?) seconds?/ do |seconds|
sleep(seconds.to_i)
end
When /^I take a screenshot( named "(.+)")?$/ do |has_name, name... |
puts 'Hello, world!'
puts ''
puts 'Good-bye.'
puts 'You\'re swell!'
puts 'backslash at teh end of a string: \\'
puts 'up\\down'
puts 'up\down'
puts 'up/down'
|
if true # << Make false to disable script, true to enable.
#===============================================================================
#
# ☆ Dekita - Resolution Setter
# -- Author : Dekita
# -- Version : 1.0
# -- Level : Very Easy
# -- Requires : N/A
# -- Engine : RPG Maker VX Ace.
#
#====================... |
class UsersController < ApplicationController
before_action :verify_user_logged_in, except: [:new, :create]
before_action :verify_is_admin, only: [:admin_page, :destroy, :edit_user, :update]
def new
end
def create
req = SwaggerClient::RegistrationRequest.new user_params
data = @@api_auth.register re... |
# Read about factories at https://github.com/thoughtbot/factory_bot
FactoryBot.define do
factory :calibration do
offset { -1 }
start_at { 1.year.ago }
end_at { 1.year.from_now }
name { 'cell' }
end
end
|
class Task < ApplicationRecord
has_many :project_tasks
has_many :projects, through: :project_tasks, dependent: :destroy
has_many :project_tasks
has_many :users, through: :project_tasks, dependent: :destroy
end
|
require 'test_helper'
class UsersLoginTest < ActionDispatch::IntegrationTest
def setup
@user = users(:michael)
end
test "Test on SNS login function" do
get info_path
assert_template 'static_pages/info'
assert_select "a[href=?]", '/auth/facebook'
assert_select "a[href=?]", login_path
... |
class ApplicationController < ActionController::Base
rescue_from CanCan::AccessDenied do |exception|
logger.debug exception
redirect_to root_url, :alert => exception.message
end
before_filter :set_locale
def set_locale
#logger.debug current_user
I18n.locale = params[:locale] || I18n.default_l... |
class Drug < ActiveRecord::Base
has_many :manufacturers, foreign_key: 'product_ndc', primary_key: 'product_ndc'
has_many :pharma_class_chemicals, foreign_key: 'product_ndc', primary_key: 'product_ndc'
has_many :pharma_class_establisheds, foreign_key: 'product_ndc', primary_key: 'product_ndc'
has_... |
Rails.application.routes.draw do
root "home#index"
scope :profile do
get "/", to: "profile#show", as: :profile
get "postings", to: "postings#all", as: :profile_postings
end
devise_for :accounts,
sign_out_via: [:get, :delete],
skip: [:sessions, :passwords, :registrations],
... |
FactoryGirl.define do
factory :delivery do |f|
f.website "Http://delivery.com"
f.image_url "delivery.jpg"
f.extra1 "Express"
f.extra2 ""
f.extra3 ""
end
factory :delivery_params, class:Hash do
delivery_id "1"
city_from "москва"
city_to "москва"
index_from "101000"
index_to "101000"
weight "3"
... |
class User
class ProfileAuthSerializer < ActiveModel::Serializer
include Rails.application.routes.url_helpers
attributes User::Profile.auth_columns
def cover_photo
object.cover_photo.present? ? object.cover_photo : ApplicationHelper.data_default[:cover_photo]
end
end
end
|
#!/usr/bin/env ruby
compile '/**/*.haml' do
filter :haml
filter :rubypants
layout '/default.*'
end
# This is an example rule that matches Markdown (.md) files, and filters them
# using the :kramdown filter. It is commented out by default, because kramdown
# is not bundled with Nanoc or Ruby.
#
#compile '/**/*.m... |
module CCS
module FM
# CCS::FM::Supplier.all
def self.table_name_prefix
'fm_'
end
class Supplier < ApplicationRecord
# usage:
# CCS::FM::Supplier.supplier_name('Shields, Ratke and Parisian')
def self.supplier_name(name)
select { |s| s['data']['supplier_name'] == name ... |
require 'httparty'
require 'hashie'
require 'base64' # <--- had to change this from "require 'Base64'"; getting "load error"
require 'addressable/uri'
module Kraken
class Client
include HTTParty
def initialize(api_key=nil, api_secret=nil, options={})
@api_key = api_key
@api_secret = api_... |
class UsersController < ApplicationController
def tweet
@user = User.find(params[:id])
@food_truck = FoodTruck.find(truck_params[:id])
content = tweet_params[:tweet_content]
@tweet = @user.tweet("@#{@food_truck.handle} #{content}")
flash[:notice] = "You tweeted at @#{@food_truck.handle}."
fla... |
class HttpResponse
def initialize(status_line, headers, body)
@status_line = status_line
@headers = headers
@body = body
end
def self.build(stream)
status_line = stream.gets
headers = {}
while (line = stream.gets)
break if line.strip.empty?
tokens = line.strip.split(':')
... |
require 'rails_helper'
RSpec.describe Communication, type: :model do
it 'has a valid factory' do
expect(create :bidding).to be_valid
end
describe 'Relations' do
it { should belong_to :user }
it { should belong_to :communication_status }
it { should belong_to :department_notified }
it { should belong_to :... |
name 'unjava'
maintainer 'Spanlink Communications, Inc.'
maintainer_email 'dschlenk@converge-one.com'
license 'apache2'
description 'Installs/Configures unjava'
long_description 'Installs/Configures unjava'
version '0.1.1'
depends 'java'
recipe "unjava::default", "Includes unjava::unjava."
recipe "unjava::unjava", "Pr... |
class Rating < ApplicationRecord
validates :rating, inclusion: {in: 0..5}
belongs_to :user
belongs_to :story
end
|
=begin
Date: 09/26/2017
Class: CS5310
Assignment: Assignment 3
Author: Rohit Bandooni
=end
class RecursiveMatrixMul
attr_accessor :arrSize,:a,:b
def initialize(a,b,arrSize)
@arrSize = arrSize
# @arr1 = Array.new(@arrSize) { |i| Random.rand(10...42) }
@arr1 = a
@arr2 = b
@arr3 = Array.new(@arrSize/2) { Ar... |
require 'bundler/setup'
require 'gamey'
# Define some components to use in the game
class PositionComponent
include Gamey::Component
attr_accessor :position
def initialize(position = Gamey::Vector2.new)
@position = position
end
end
class VelocityComponent
include Gamey::Co... |
class CharactersController < ApplicationController
before_filter :authenticate_user!, only: [:new, :create, :update]
def new
@character =
Presenters::Character.new(BuildCharacter.new.build(params[:character_kind]))
end
def create
@character =
Presenters::Character.new(current_user.charact... |
require 'rspec'
require 'towers'
describe "Towers" do
subject(:game) { Towers.new }
describe "#initialize" do
it "creates towers" do
expect(game.towers).to eq([[3, 2, 1], [], []])
end
end
describe "#won?" do
it "returns false if all pieces on 1st tower" do
expect(game.won?).to be fals... |
class Statement
attr_reader :transactions
def initialize(transactions)
@transactions = transactions
end
end
|
# frozen_string_literal: true
module Decidim
module Opinions
module Admin
# A form object to be used when admin users want to answer a opinion.
class OpinionAnswerForm < Decidim::Form
include TranslatableAttributes
mimic :opinion_answer
translatable_attribute :answer, String
... |
class ApplicationController < ActionController::API
acts_as_token_authentication_handler_for User, fallback: :none
before_action :authenticate_user!
def current_user
@current_user ||= User.find_by(id: session["warden.user.user.key"][0])
end
end
|
# frozen_string_literal: true
require 'ascii85'
class Document
class Attachment
TEMP_PATH = Rails.root.join('tmp', 'files')
RESIZE_PERCENTAGE = '50%'
include Mongoid::Document
field :original_file, type: String
field :preview_file, type: String
field :filename, type: String
embedded_in ... |
class Cardiotype < ActiveRecord::Base
has_many :cardiosessions
validates_presence_of :description
validates_uniqueness_of :description
def self.all
self.find(:all)
end
end
|
require 'i18n'
LOCALE = :en # set your locale
# Create folder "_locales" and put some locale file from https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale
module Jekyll
module I18nFilter
# Example:
# {{ post.date | localize: "%d.%m.%Y" }}
# {{ post.date | localize: ":short" }}
def l... |
require './lib/gpx/gpx' # load this just to get GPX::VERSION
require 'rake' # For FileList
Gem::Specification.new do |s|
s.name = 'gpx'
s.version = GPX::VERSION
s.summary = %q{A basic API for reading and writing GPX files.}
s.description = %q{A basic API for reading and writing GPX files.}
s.files = Fi... |
class SessionController < ApplicationController
def create
user = User.find_by(email: params[:email])
if user && user.authenticate(params[:password])
log_in(user) #cf. session_helper
remember user #cf. session_helper
redirect_to root_path
else
flash.now[:danger] = 'Email et/ou password non val... |
class Bot
attr_accessor :x, :y
def initialize(grid)
@x = (grid.size - 1) / 2
@y = (grid.size - 1) / 2
end
def updated_coords
[@x, @y]
end
end
|
class AddIndexOnEmployeeLeaveBalance < ActiveRecord::Migration
def self.up
add_index :employee_leave_balances, :action, :name => "index_by_action"
end
def self.down
remove_index :employee_leave_balances, :name => "index_by_action"
end
end
|
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rspec/core/rake_task'
begin
require 'rubocop/rake_task'
rescue LoadError
puts 'can not use rubocop in this environment'
else
RuboCop::RakeTask.new
end
task default: [:test_behaviors]
task test_behaviors: [:spec]
RSpec... |
class PledgeMailer < ApplicationMailer
include ActionView::Helpers::TextHelper
include PledgeHelper
def pledge_ended(pledge)
@user = pledge.user
@pledge = pledge
@feedback = feedback_for pledge
@request_count = Request.not_granted.count
subject = case pledge.status
when :exceeded
"... |
# -*- encoding : utf-8 -*-
class ::Module
############################
# instances_identify_as! #
############################
# Cause instances of receiver to identify as specified objects.
# @param [Array<Object>] objects Other objects self should identify as.
# @return [Object] Self.
def insta... |
require 'spec_helper'
describe Attendance do
it { should belong_to(:game) }
it { should belong_to(:user) }
it { should validate_presence_of(:status) }
it { should validate_presence_of(:user_id) }
it { should validate_presence_of(:game_id) }
end
|
FactoryGirl.define do
factory :user do
first_name "John"
last_name "Doe"
password "12345sixSevenEight"
sequence(:email) { |n| "email#{n}@apps.com" }
trait :as_gov_user do
type "GovernmentUser"
end
trait :as_product_owner do
type "ProductOwner"
end
trait :verified do
... |
module Api
module V1
class ArticlesController < ApplicationController
before_action :doorkeeper_authorize!
skip_before_action :authenticate_user!
protect_from_forgery with: :null_session
def index
articles =Article... |
class ToleranceAction < ActiveRecord::Base
COLOURS = [['Red', '#9d2613'], ['Orange', '#f89406'], ['Yellow', '#ffc40d']]
has_many :min_standards, foreign_key: :min_tolerance_action_id, class_name: "Standard"
has_many :max_standards, foreign_key: :max_tolerance_action_id, class_name: "Standard"
attr_acce... |
class Destination < ApplicationRecord
has_many :posts
has_many :bloggers, through: :posts
validates :name, uniqueness: true
end
|
class PolyTreeNode
attr_reader :value
attr_accessor :parent, :children
def initialize(value)
@value = value
@children = []
@parent = nil
end
def parent=(parent)
@parent.children.delete(self) unless @parent.nil?
if parent.nil?
@parent = nil
else
@parent = parent
... |
require_relative ('../db/sql_runner')
require_relative('./ticket.rb')
require_relative('./film.rb')
class Customer
attr_reader :id
attr_accessor :funds, :name
def initialize(options)
@id = options['id'].to_i if options['id']
@name = options['name']
@funds = options['funds'].to_i()
end
def sa... |
class MessageRoutesController < ApplicationController
before_action :set_message_route, only: [:show, :edit, :update, :destroy]
# GET /message_routes
# GET /message_routes.json
def index
@message_routes = MessageRoute.all
end
# GET /message_routes/1
# GET /message_routes/1.json
def show
end
#... |
class CreateChallenges < ActiveRecord::Migration
def change
create_table :challenges do |t|
t.text :goal
t.date :accomplish_by
t.boolean :is_completed
t.date :completed_on
t.text :challenge_update
t.text :challenge_comment
t.references :user, index: true
t.integer :... |
module FedenaInventory
def self.attach_overrides
Dispatcher.to_prepare :fedena_inventory do
::FinancialYear.instance_eval {
has_many :grns
has_many :invoices
}
end
end
def self.dependency_check(record,type)
if type == "permanant"
if record.class.to_s == "Employee"
... |
# frozen_string_literal: true
class SearchBuilder < Blacklight::SearchBuilder
include Blacklight::Solr::SearchBuilderBehavior
include Arclight::SearchBehavior
include BlacklightRangeLimit::RangeLimitBuilder
self.default_processor_chain += [:remove_grouping, :boost_collections, :strip_quotes]
def remove_grou... |
# frozen_string_literal: true
class Account < ApplicationRecord
include Transferable
belongs_to :user, inverse_of: :account
has_many :events, inverse_of: :account, dependent: :destroy
def balance
events.sum(:amount).to_f
end
end
|
require 'rails_helper'
RSpec.describe 'LoansController', type: :request do
describe 'GET /loans/:id' do
let(:loan) { create(:loan) }
let(:url) { "/loans/#{loan.id}" }
it 'return requested loan' do
get url
expected = loan.as_json(only: %i[id pmt])
expected['pmt'] = expected['pmt'].to_f
... |
class Reward < ApplicationRecord
belongs_to:user
validates :amount, numericality: true
validates :user_id, presence: true
end
|
class TrademarksController < ApplicationController
before_action :set_trademark, only: [:show, :update, :destroy]
before_action :check_grants
# GET /trademarks
# GET /trademarks.json
def index
@title = @header = "Торговые марки"
@trademarks = Trademark.all
end
# GET /trademarks/1
# GET /tradema... |
# =========================================================================
# These are the tasks that are available to help with deploying web apps,
# and specifically, Rails applications. You can have cap give you a summary
# of them with `cap -T'.
# ===================================================================... |
# Model : Ninja
class Ninja < ApplicationRecord
belongs_to :user
has_and_belongs_to_many :weapons
has_and_belongs_to_many :battles
validates :name, presence: true, length: { in: 3..30 }
validates :hp, presence: true, numericality: { only_integer: true }
validates :user_id, presence: true, numericality: { o... |
module AnnualReports
class BuildAnnualReportJob < ApplicationJob
queue_as :reports_builders
def perform
Create::Service.new(timestamp: yesterday_timestamp).call
end
def yesterday_timestamp
DateTime.now - 1.day
end
end
end
|
class Users::FavoritesController < ApplicationController
before_action :set_post
def create
favorite = current_user.favorites.build(post_id: params[:post_id])
favorite.save
#redirect_to request.referer
@post.create_notification_like!(current_user)
end
def destroy
favorite = Favorite.find_by(... |
# Bubble Sort
def bubble_sort!(arr)
i = 0
loop do
if arr[i] > arr[i + 1]
# Swap if first comparison value is greater than the second
arr[i], arr[i+1] = arr[i+1], arr[i]
end
i += 1
break if i == (arr.length - 1)
end
return arr
end
#arr = [5,3]
arr = [6,2,7,1,4]
#arr = %w(Sue Pete ... |
require 'spec_helper'
describe UserController do
describe "Signup Page" do
it 'loads the signup page' do
get '/signup'
expect(last_response.status).to eq(200)
end
it 'signup directs user to Reel Reviews home' do
params = {
:username => "skittles123",
:password =... |
source "http://rubygems.org"
# Declare your gem's dependencies in pointless_feedback.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
group :test do
gem 'test-unit'
gem 'pry'
gem 'minitest-spec-r... |
# require "pry"
class Movie < ActiveRecord::Base
has_many :reviews
mount_uploader :image, ImageUploader
validates :title,
presence: true
validates :director,
presence: true
validates :runtime_in_minutes,
numericality: { only_integer: true }
validates :description,
presence: true
vali... |
class AddCreatedAtToMeetups < ActiveRecord::Migration
def change
add_column :meetups, :created_at, :datetime
end
end
|
require 'test_helper'
class BeefsControllerTest < ActionDispatch::IntegrationTest
setup do
@beef = beefs(:one)
end
test "should get index" do
get beefs_url
assert_response :success
end
test "should get new" do
get new_beef_url
assert_response :success
end
test "should create beef" ... |
# frozen_string_literal: true
# Наивная загрузка данных из json-файла в БД
# rake reload_json[fixtures/small.json]
require 'benchmark'
task :reload_json, [:file_name] => :environment do |_task, args|
time = Benchmark.measure do
json = Oj.load(File.read(args.file_name))
ActiveRecord::Base.transaction do
... |
require('minitest/autorun')
require_relative('../bar')
require_relative('../drinks')
require_relative('../patrons')
class PatronTest < MiniTest::Test
def setup
@patron1 = Patron.new("Simon", 2000)
@patron2 = Patron.new("Garthak the Destroyer", 12)
@drink1 = Drink.new("Martini", 6)
@drink2 = Drink.n... |
require 'spec_helper'
describe Comment, :type => :model do
it { should validate_presence_of(:name) }
it { should validate_presence_of(:email) }
it { should validate_presence_of(:body) }
end
|
class WordGuesserGame
# add the necessary class methods, attributes, etc. here
# to make the tests in spec/wordguesser_game_spec.rb pass.
attr_accessor :word, :guesses, :wrong_guesses, :working_word
# Get a word from remote "random word" service
def initialize(word)
@word = word
@guesses = ''
@w... |
###################### More Options ######################
# If you want to have even more control, check out the documentation
# https://github.com/fastlane/fastlane/blob/master/deliver/Deliverfile.md
###################### Automatically generated ######################
# Feel free to remove the following line if yo... |
require './lib/card'
class Guess
attr_reader :response,
:card,
:response_boolean
def initialize(response, card)
@response = response
@card = card
@response_boolean
end
def correct?
response = []
@response.split.each_with_index do |string, index|
if index... |
require 'forwardable'
module Skype
class FakeApi < Api
class << self
extend Forwardable
def_delegator :instance, :recorded_messages
end
def attach
end
def invoke(message)
recorded_messages << message
end
def recorded_messages
@recorded_messages ||= []
end
... |
class CreateSpots < ActiveRecord::Migration[5.0]
def change
create_table :spots do |t|
t.text :text
t.string :user_name
t.integer :user_id
t.string :tags, array: true, default: []
t.timestamps
end
add_index :spots, :tags, using: 'gin'
add_index :spots, :created_at
end... |
class Subscribe < ApplicationRecord
# Schema Subscribes table
# t.bigint "user_id"
# t.bigint "repo_id"
# t.datetime "created_at", null: false
# t.datetime "updated_at", null: false
# t.index ["repo_id"], name: "index_subscribes_on_repo_id"
# t.index ["user_id"], name: "index_subscribes_on_use... |
class PromotionsController < ApplicationController
before_action :set_promotion, only: [:show, :edit, :update, :destroy]
# GET /promotions
# GET /promotions.json
def index
if !current_user.retailer.nil?
@promotions = Promotion.all.where(retailer_id: current_user.retailer_id).order('active desc, name'... |
class DatacenterNodeRackAssignment < ActiveRecord::Base
acts_as_authorizable
acts_as_audited
named_scope :def_scope
acts_as_reportable
belongs_to :datacenter
belongs_to :node_rack
validates_presence_of :datacenter_id, :node_rack_id
validates_uniqueness_of :node_rack_id
def self.default... |
class ChangeStartDateAndEndDateToBeDateInDogs < ActiveRecord::Migration[6.0]
def change
change_column :dogs, :start_date, :date
change_column :dogs, :end_date, :date
end
end
|
FactoryGirl.define do
factory :comment do
association :user
association :review
body "Great review"
end
end
|
class Api::OauthController < ApplicationController
def create
@state = JSON.parse(params[:state], {:symbolize_names=>true}) unless !params[:state]
@result = HTTParty.post("https://app.deco.network/oauth/token",
:body => { :code => params[:code],
:client_id => '2d6dbffdce9d62562f2fe8c0b... |
require "primes/version"
require "primes/sieve"
require "primes/multiplication_table"
module Primes
def self.multiplication_table(options)
sieve = Sieve.new
return sieve.nth(Integer(options[:number])) if options[:number]
size = Integer(options[:size])
MultiplicationTable.new(sieve.first(size))
en... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.