text stringlengths 10 2.61M |
|---|
class DNA
attr_accessor :strand
def initialize(strand)
@strand = strand
end
def hamming_distance(distance)
return 0 if @strand == '' || distance == ''
sizes = [strand, distance].map {|wrd| wrd.size}
small_idx, big_idx = sizes.find_index(sizes.min), sizes.find_index(sizes.max)
if distance.s... |
require 'test_helper'
class SubscriptionTest < ActiveSupport::TestCase
def setup
@cposting = cpostings(:one) #has one spot
@customer = users(:customer)
@customer2 = users(:customer2)
@subscription = Subscription.new(post_id: @cposting.id, subscriber_id: @customer.id)
end
test "should be valid" ... |
class EntriesController < ApplicationController
before_filter :authorize, only: [:edit, :update, :destroy]
def new
@user = User.find(params[:user_id])
@entry = Entry.new
end
def create
@user = User.find(params[:user_id])
@entry = Entry.new(entry_params)
if @entry.save
session[:entry_... |
class Clock < ApplicationRecord
has_secure_token
has_secure_token :slug
attribute :public, :boolean, default: true
attribute :human_time, :string, default: '24 hours from now'
before_save :parse_human_time
after_initialize :set_human_time
def duration
begin
raise CountdownEndedError if (DateT... |
class PopraviKrvneGrupe < ActiveRecord::Migration
def change
add_column :blood_groups, :group, :text
end
end
|
require_relative '../spec_helper'
describe Tournament do
let :positions do
[ Position.new(1,'Joao', 0, 30),
Position.new(2,'Jose', 1, 0),
Position.new(3,'Pedro', 0, 0) ]
end
subject { Tournament.new(positions) }
it 'assigns 1 point of strength to the first one on a game of three players ' do
exp... |
def find_number(num, high)
raise ArgumentError.new("First argument must be less than second argument") if high < num
raise ArgumentError.new("First argument must be between 0 and #{high}") if num < 0 || num > high
low = 0
calc = ->(x,y) { (x + y) / 2 }
mid = calc.call(low, high)
while low <= high
if mid... |
require 'rails_helper'
RSpec.describe "using the contact form" do
it "accepts valid input" do
visit '/'
fill_in 'Name', :with => 'Napa Artist'
fill_in 'Email', :with => 'iloveart@gmail.com'
fill_in 'Subject', with: 'Interest in joining'
fill_in 'Message', with: 'I would like to join Napa Valley A... |
class AddColumnsToCustomerSets < ActiveRecord::Migration
def change
add_column :customer_sets, :field, :string
add_column :customer_sets, :comparison, :string
add_column :customer_sets, :value, :int
end
end
|
class HouseSerializer < ActiveModel::Serializer
attributes :id, :name, :address
has_many :users, serializer: HouseUsersSerializer
end
|
namespace 'test:db' do
def target_database_servers
TestSupport::TargetDatabaseServers.instance
end
desc 'Create test databases'
task 'create' do
target_database_servers.create_databases
end
desc 'Drop test databases'
task 'drop' do
target_database_servers.drop_databases
end
end
|
class AddCategoryCareToUser < ActiveRecord::Migration[5.2]
def change
add_column :users, :category_care, :string
end
end
|
require "google/apis/calendar_v3"
require "googleauth"
require "googleauth/stores/file_token_store"
require "date"
require "fileutils"
module GoogleCalendar
extend ActiveSupport::Concern
OOB_URI = "urn:ietf:wg:oauth:2.0:oob".freeze
APPLICATION_NAME = "rainify".freeze
CREDENTIALS_PATH = "config/credentials.jso... |
require 'spec_helper'
describe User do
describe 'validations' do
context 'when all attributes are valid' do
it 'is valid' do
expect(FactoryGirl.build(:user)).to be_valid
end
end
context 'when username is missing' do
it 'is not valid' do
user = FactoryGirl.build(:user, username: ni... |
# frozen_string_literal: true
RSpec.describe Dry::Logic::Operations::Key do
subject(:operation) { described_class.new(predicate, name: :user) }
include_context "predicates"
let(:predicate) do
Dry::Logic::Rule::Predicate.build(key?).curry(:age)
end
describe "#call" do
context "with a plain predicat... |
# Capistrano Deploy Recipe for Git and Phusion Passenger
#
# After issuing cap deploy:setup. Place server specific config files in
# /home/#{user}/site/[staging|production]/shared
# Set :config_files variable to specify config files that should be
# copied to config/ directory (i.e. database.yml)
#
# To deploy to ... |
WIN_COMBINATIONS = [
[0, 1, 2],
[0, 4, 8],
[0, 3, 6],
[3, 4, 5],
[6, 4, 2],
[1, 4, 7],
[6, 7, 8],
[2, 5, 8]
]
board = ["X", "X", "X", "X", "X", "X", "X", "X", "X"]
def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{board[4]} | #{boa... |
class Game < ApplicationRecord
has_many :guesses
validates :number, presence: true, numericality: true
end
|
require_relative('../db/sql_runner')
# require('pry')
require 'pry-byebug'
class Lease
attr_reader :id, :equipment_id, :customer_id, :start_date, :end_date, :number_leased
def initialize(options)
# binding.pry
@id = options['id'].to_i if options['id']
@equipment_id = options['equipment_id'].to_i
@... |
json.array!(@skill_relations) do |skill_relation|
json.extract! skill_relation, :id, :skill_id, :student_id
json.url skill_relation_url(skill_relation, format: :json)
end
|
require 'spec_helper'
RSpec.describe 'time' do
subject(:a1) { [1,2,3].timed("2014") }
describe 'year_changed?' do
it "is true" do
expect(Time.new(2015,1,1,0,20).year_changed?).to be true
end
it "is false" do
expect(Time.new(2015,1,1,1,0).year_changed?).to be false
expect(Time.new(20... |
class Truck
class Destroy < Trailblazer::Operation
step Model(::Truck, :find)
step TrailblazerHelpers::Steps::Destroy
end
end
|
class Constant < Expression
attr_accessible :name, :value
def to_s
name
end
def to_html
name
end
end
|
Pod::Spec.new do |s|
s.name = 'CEPubnub'
s.version = '0.0.1'
s.license = 'MIT'
s.summary = 'iOS objective-c wrapper for Pubnub real-time messaging service.'
s.homepage = 'https://github.com/jazzychad/CEPubnub'
s.author = { 'Chad Etzel' => 'http://jazzychad.net/' }
s.source = { :git => 'git://gi... |
# frozen_string_literal: true
RSpec.describe ProcessVideoDataJob do
describe '.perform' do
let(:video) { create(:video) }
subject(:perform) do
described_class.perform_now(video_id: video.id)
end
it 'calls service' do
expect_any_instance_of(ProcessVideoDataService).to receive(:call).with... |
class Meme < ApplicationRecord
belongs_to :user
has_many :tag_taggables, as: :taggable, dependent: :destroy
has_many :tags, through: :tag_taggables
def tags=(tags_or_tags_attributes)
tags_ids = if tags_or_tags_attributes.is_a? Array
tags_or_tags_attributes.each do |tag|
... |
class EditColumnPaymentTypeToTransferIns < ActiveRecord::Migration[5.1]
def change
rename_column :transfer_ins, :payment_type, :transfer_type
end
end
|
#unique instances
require 'date'
require_relative '../../mongo_conn'
require_relative '../../filter'
require_relative '../../../../src/lib/splice_reports/report_query'
#setup the db
db = MongoConn.new()
mpu = db.get_coll_marketing_report_data()
Given(/^there is a populated database with one instance where the last c... |
require 'spec_helper'
describe Station do
it 'initializes an instance of Station with a location name' do
test_station = Station.new({'location' => 'Rose Quarter'})
test_station.should be_an_instance_of Station
end
it 'gives us the location and id' do
test_station = Station.new({'location' => 'Rose ... |
module DocumentsHelper
def render_markdown(document)
body = document.body
# Show signatures
employee_signature = document.signatures.employee.first
if employee_signature
body.gsub!(/(\[%)signature_employee_date(\])/, employee_signature.signed_on.strftime('%d/%m/%Y'))
body.gsub!(/(\[%)sign... |
require 'json'
require_relative './tfc'
require_relative './delivery'
module CallObserver
class StackRecorder
def initialize(ruler)
@ruler = ruler
end
def log_file
@log ||= make_new_log_file
end
def make_new_log_file
File.join(Dir.mktmpdir, 'calls.log')
end
def log(re... |
Gem::Specification.new do |s|
s.name = 'malware_api'
s.version = '0.1'
s.date = '2009-12-26'
s.summary = "Google Safe Browsing API for Rails"
s.author = 'Jorge Bernal'
s.email = 'koke@amedias.org'
s.homepage = 'http://github.com/koke/malware_api'
s.has_rdoc = false
s.extra_rdoc_fil... |
require './spec/support/file_helpers'
RSpec.configure do |c|
c.include FileHelpers
end
describe ManageIQ::Providers::Kubevirt::Inventory::Parser do
describe '#process_vms' do
it 'parses a vm' do
storage_collection = double("storage_collection")
storage = FactoryBot.create(:storage)
allow(sto... |
Rails.application.routes.draw do
resources :about, only: :index
root "about#index"
end
|
class GrFosphor < Formula
homepage "http://sdr.osmocom.org/trac/wiki/fosphor"
url "git://git.osmocom.org/gr-fosphor.git", :revision => "3fdfe7cf812238804f25f5cdfe39f848fd657b33"
revision 2
depends_on "cmake" => :build
depends_on "gnuradio"
depends_on "glfw3"
def install
mkdir "build" do
p... |
require 'rails_helper'
describe SendComplaintJob, type: :job do
describe '#perform_later' do
it 'queues a job' do
expect do
described_class.perform_later
end.to have_enqueued_job.on_queue('send_complaints').exactly(:once)
end
end
describe '#perform' do
subject(:jobs) { described_... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
class Voucher
attr_reader :discount
def initialize()
@discount = 10
end
end |
require 'test_helper'
class NonCampusSchoolTotalsControllerTest < ActionDispatch::IntegrationTest
setup do
@non_campus_school_total = non_campus_school_totals(:one)
end
test "should get index" do
get non_campus_school_totals_url
assert_response :success
end
test "should get new" do
get new_... |
class CreateAlunos < ActiveRecord::Migration
def change
create_table :alunos do |t|
t.string :nome
t.string :link_html
t.string :link_github
t.text :mini_curriculo
t.timestamps
end
end
end
|
#!/usr/bin/env ruby -W0
require "yaml"
require File.join(File.dirname(__FILE__), '..', 'lib', "rails_bundle_tools")
require File.join(File.dirname(__FILE__), '..', 'lib', "search_utilities")
require File.join(ENV['TM_SUPPORT_PATH'], 'lib', 'progress')
require File.join(ENV['TM_SUPPORT_PATH'], 'lib', 'current_word')
m... |
class PartiesController < ApplicationController
before_action :authorize_user!
def index
party = Party.find_by(user_id: @current_user.id)
if party
serialized_data = ActiveModelSerializers::Adapter::Json.new(PartySerializer.new(party)).serializable_hash
maps = party.party_maps.map { |map| {map... |
require 'tem_ruby'
require 'test/unit'
# Helper methods for TEM tests.
#
# This module implements setup and teardown methods that provide an initialized
# @tem instance variable holding a Tem::Session. Just the right thing for
# testing :)
class TemTestCase < Test::Unit::TestCase
def setup
@tem = Tem.auto_tem... |
require 'docking_station'
RSpec.describe DockingStation do
bike = Bike.new
describe '#release_bike' do
it {is_expected.to respond_to(:release_bike)}
it "returns an existing bike object" do
subject.dock(bike)
expect(subject.release_bike).to be_instance_of(Bike)
end
i... |
Rails.application.routes.draw do
root "series#index"
resources :series do
resources :game
end
end
|
# Question 11
# What will the following code output?
class Animal
def initialize(name)
@name = name
end
def speak
puts sound
end
def sound
"#{@name} says "
end
end
class Cow < Animal
def sound
super + "moooooooooooo!"
end
end
daisy = Cow.new("Daisy")
daisy.speak
# Answer
# Cow inh... |
class Post < ActiveRecord::Base
acts_as_votable
belongs_to :user
has_many :comments, dependent: :destroy
belongs_to :category
default_scope -> { order(created_at: :desc) }
self.per_page = 4
#This method removes the default scope before the query
def self.random_top_story
Post.unscoped {
... |
# write your reps here
# makes sure to either `p my_output` or `puts my_output`.
# `p _variablename_` prints the full Object
# `puts _variablename_` prints the Object.to_s (.toString())
# to run, just `ruby reps.rb`
#Write a function `lengths` that accepts a single parameter as an argument, namely an array of strings. ... |
# -*- encoding : utf-8 -*-
require 'rails_helper'
RSpec.describe Completion, type: :model do
describe 'sorted_certificates' do
let!(:completion) { FactoryGirl.create(:completion) }
let!(:certificate) { FactoryGirl.create(:certificate, completion: completion) }
let!(:record_of_achievement) { FactoryGirl.c... |
class Word < ActiveRecord::Base
has_many :game_words
has_many :games, :through => :game_words
end
|
class EARMMS::UserSettingsGroupController < EARMMS::ApplicationController
helpers EARMMS::GroupHelpers
get '/' do
unless logged_in?
flash(:error, "You must be logged in to access this page.")
next redirect('/auth')
end
@user = current_user
@profile = EARMMS::Profile.for_user(@user)
... |
module E9Crm::PageViewsHelper
def page_view_campaign_select_options
@_page_view_campaign_select_options ||= begin
opts = Campaign.all.map {|campaign| [campaign.name, campaign.id] }
opts.unshift ['Any', nil]
options_for_select(opts)
end
end
def page_view_new_visit_select_options
opti... |
require 'spec_helper'
describe Factual::Query::Monetize do
include TestHelpers
before(:each) do
@token = get_token
@api = get_api(@token)
@monetize = Factual::Query::Monetize.new(@api)
@base = "http://api.v3.factual.com/places/monetize?"
end
it "should be able to use filters" do
@monetize... |
class Artist
extend Memorable::ClassMethods
extend Findable::ClassMethods
extend Createable::ClassMethods
attr_accessor :name, :songs, :genres
@@instances = []
def initialize(name = nil)
@name = name
@@instances << self
@songs = []
@genres = []
end
def self.all
@@instances
end
... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.ca... |
module Jsonapi
class UserResource < JSONAPI::Resource
attributes :avatar_url, :email, :first_name, :last_name,
:middle_name, :password
has_many :scorecards
has_many :courses
filter :id_not, apply: lambda { |records, value, _options|
# TODO: Is there a way to filter without this?
... |
# frozen_string_literal: true
RSpec.describe Api::V1::UserSerializer, type: :serializer do
let(:user) { build_stubbed(:user) }
subject(:result) { serialize_entity(user, class: {User: described_class}) }
describe 'type' do
it 'returns proper type' do
expect(result.dig(:data, :type)).to eq :users
e... |
require './utils/string'
class Inventory
# E.g. F123245, F123245Q, F123245Q12
def self.anonymize_inventory_number(inventory_number)
return "" if (inventory_number || "").blank?
prefix = inventory_number.scan(/^[A-Za-z]/).join
prefix = "X" if prefix.blank?
suffix = inventory_number.scan(/[Qq]{1}\d*... |
# author: Kevin M
# Teacher model, validates the presence of various properties, but nothing else
# right now.
class Teacher < ApplicationRecord
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
validates :user_name, presence: true
validates :teacher_icon_name, presence: true, length: { m... |
require_relative '../db/sql_runner.rb'
class Item
attr_accessor :type, :id
def initialize(options)
@id = options['id'].to_i if options['id']
@type = options['type']
end
def save()
sql = "INSERT INTO items (type) VALUES ('#{@type}') RETURNING * ;"
result = SqlRunner.run(sql)
@id = result[... |
class RemoveCachedDetailsFromWants < ActiveRecord::Migration
def change
remove_column :wants, :seller, :string
remove_column :wants, :game_id, :integer
end
end
|
class Notification < ApplicationRecord
belongs_to :user
after_create :att_saw_notifications
enum kind: [ :bell, :ticket, :cash]
def att_saw_notifications
self.user.sawnotifications = false
self.user.save
end
end
|
require 'zlib'
require 'rack/request'
require 'rack/response'
require 'rack/utils'
require 'redis'
require 'time'
require 'fileutils'
require 'scrolls'
module Sokoban
class Receiver
include Scrolls
ROUTES =
[["POST", :service_rpc, /(.*?)\/git-upload-pack$/, 'upload-pack'],
["POST", :service_rp... |
# cd /var/www/test/headfirstpatterns/ch03/Starbuzz02
# ruby -I lib starbuzz_coffee.rb
Beverages = ['beverage', 'espresso', 'dark_roast', 'house_blend', 'decaf']
Condiments = ['condiment_decorator', 'mocha_decorator', 'whip_decorator', 'soy_decorator']
(Beverages + Condiments).each do |lib_file|
require lib_file
end... |
class BooksController < ApplicationController
def index
@book = Book.get_random
if current_user
@favorite_books = current_user.books
end
end
def show
@book = Book.find(params[:book_id])
end
def new
if current_user && current_user.admin
@book = Book.new
else
redirect... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'middleman-google_drive/version'
Gem::Specification.new do |spec|
spec.name = 'middleman-google_drive'
spec.version = Middleman::GoogleDrive::VERSION
spec.platform = Gem:... |
module Api
module V1
class SessionsController < Devise::SessionsController
respond_to :json
protected
def sign_in_params
params.require(:user).permit(:email, :password)
end
end
end
end
|
require 'test_helper'
class WheelDeflectionsControllerTest < ActionDispatch::IntegrationTest
setup do
@wheel_deflection = wheel_deflections(:one)
end
test "should get index" do
get wheel_deflections_url
assert_response :success
end
test "should get new" do
get new_wheel_deflection_url
a... |
class TimeCard < ApplicationRecord
belongs_to :user
validates :year, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 1 }
validates :month, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 1 }
validates :day, presence: true, numericality: { only_integer... |
module MotionBuild ; module Rules
class LipoRule < MultifileRule
def input_extension
'.o'
end
def output_extension
'.o'
end
def run
project.builder.notify('lipo', sources, destination)
project.builder.run('lipo', ['-create', *sources, '-output', destination])
end
e... |
class PriceSerializer < ActiveModel::Serializer
attributes :id, :currency, :value
end
|
class Api::EvaluationsController < Api::BaseController
skip_before_action :authenticate_user!, only: [ :index, :show, :specified, :aggregate ]
include EvaluationsConcern
def specified
@evaluations = Evaluation.where(evaluationable_type: params[:evaluationable_type], evaluationable_id: params[:evaluationable... |
require 'oauth2'
require 'cortex/connection'
require 'cortex/request'
require 'cortex/resource'
require 'cortex/content_items'
require 'cortex/posts'
require 'cortex/users'
require 'cortex/webpages'
require 'cortex/result'
module Cortex
class Client
attr_reader :posts, :users, :webpages, :content_items
attr... |
class AuditProblem::MissingAgency < AuditProblem::EntrySpecific
def self.run(options={})
field :agency_names, :type => String
problems = []
Entry.find_each(:joins => "JOIN agency_name_assignments ON agency_name_assignments.assignable_id = entries.id AND agency_name_assignments.assignable_type = 'Entry' L... |
# frozen_string_literal: true
class LocationsController < ApplicationController
include Locations::Refresh
include Concerns::Application::RedirectWithStatus
secure!(:event, :course, :seminar)
title!('Locations')
before_action :update_form_data, only: %i[edit update]
def list
@locations = Location.a... |
require_relative 'spec_helper.rb'
describe ChefAB::BaseUpgrader do
it 'should have an integer hash' do
up = ChefAB::BaseUpgrader.new(node_id: 5)
expect(up.hash).to be_a_kind_of(Integer)
end
it 'should have an integer hash in any case' do
up = ChefAB::BaseUpgrader.new(node_id: "testing node")
expe... |
class Team < ApplicationRecord
has_many :home_games, foreign_key: "home_team_id", class_name: "Game"
has_many :away_games, foreign_key: "away_team_id", class_name: "Game"
def total_points
home_games.sum(:team1points) + away_games.sum(:team2points)
end
end
|
describe "Datoki.db Schema_Conflict" do
before {
CACHE[:schema_conflict] ||= begin
reset_db <<-EOF
CREATE TABLE "datoki_test" (
id serial NOT NULL PRIMARY KEY,
ti... |
class GameEvent < ApplicationRecord
belongs_to :game, touch: true, optional: true
validates_inclusion_of :state, in: Game::STATES
def self.latest_state(state)
where("game_events.id IN (SELECT MAX(id) FROM game_events GROUP BY game_id)").where(:state => state)
end
end
|
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
module TwitterCldr
module Localized
class LocalizedString < LocalizedObject
include Enumerable
# Uses wrapped string object as a format specification and returns the result of applying it to +args+ (see
... |
require "minitest/autorun"
require "nidyx"
require "nidyx/parse_constants"
require "nidyx/property"
require "nidyx/objc/property"
include Nidyx::ParseConstants
class TestObjCProperty < Minitest::Test
def test_is_obj
assert_equal(true, simple_property("array").is_obj?)
assert_equal(false, simple_property("b... |
class Room < ActiveRecord::Base
belongs_to :sponsor, class_name: "User", foreign_key: "sponsor_id"
belongs_to :audience, class_name: "User", foreign_key: "audience_id"
has_many :talks, dependent: :destroy
end
|
class MessageBroadcastJob < ApplicationJob
include ActionView::RecordIdentifier
queue_as :default
def perform(message:)
channel = "messages_#{message.user.id}_#{message.client.id}"
message_html = render_message_partial(message)
status_html = render_message_status_partial(message)
message_dom_id =... |
require 'rails_helper'
RSpec.describe Task, type: :model do
describe "#toggle_complete!" do
it "should switch complete to false if it began as true" do
task = Task.new(complete: true)
task.toggle_complete!
expect(task.complete).to eq(false)
end
it "should switch complete to true if it ... |
class AddUuidToMessages < ActiveRecord::Migration[5.0]
enable_extension 'uuid-ossp'
def change
drop_table :messages
create_table :messages, id: :uuid do |t|
t.text :content
t.string :location
t.string :password
t.float :latitude
t.float :longitude
t.timestamps
en... |
class CartItem < ApplicationRecord
belongs_to :item
belongs_to :customer
end
|
class AssignmentCollectionsController < ApplicationController
before_action :set_assignment_collection, only: [:edit, :edit_api, :update, :destroy]
before_action :require_admin, only:[:edit, :create, :destroy]
# INDEX [HTTP GET]
#================================================================================... |
class CreateNvsDepts < ActiveRecord::Migration
def change
create_table :nvs_depts do |t|
t.string :name, :limit => 50, :default => "", :null => false
t.string :email, :limit => 300, :default => "", :null => false
t.integer :project_id, :null => false
t.timestamps
end
en... |
require_relative 'spec_helper.rb'
describe RPS::Session do
it "exists" do
expect(RPS::Session).to be_a(Class)
end
describe ".initialize" do
it "generates a unique id for each session" do
RPS::Session.class_variable_set :@@counter, 0
expect(RPS::Session.new(1).id).to eq(1)
expect(RPS::... |
class BananaStand
def initialize (colour, mr_manager, opened_in=1988, accepts_credit_cards=true)
@color = colour
@mr_manager = mr_manager
@opened_in = opened_in
@accepts_credit_cards = accepts_credit_cards
end
attr_accessor :color, :mr_manager #gets and set... |
##
# This file adapted from activerecord gem
#
module Pools
class Handler
attr_reader :pools
def initialize(pools = {})
@pools = pools
end
# Add a new connection pool to the mix
def add(pool, name = nil)
key = name || pool.object_id
raise(%Q(Pool "#{name}" already exists)) if ... |
class Couriers::OrdersController < Couriers::BaseController
def index
@orders = Order.unassigned
end
end |
# == Schema Information
#
# Table name: taggings
#
# id :integer not null, primary key
# taggable_type :string
# taggable_id :integer
# tag_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_taggings_on_tag_id ... |
class Comment
include DataMapper::Resource
property :id, Serial
end |
# spec/requests/requests_spec.rb
RSpec.describe 'Requests API' do
# Initialize the test data
let!(:template) { create(:template) }
let!(:workflow) { create(:workflow, :template_id => template.id) }
let(:workflow_id) { workflow.id }
let!(:requests) { create_list(:request, 2, :workflow_id => workflow.id) }
l... |
class Ability
include CanCan::Ability
def initialize(user)
can :read, :all
if user
can :create, :all
can [:update, :destroy], Post do |post|
post.nil? ? false : post.user == user
end
end
end
end
|
class AddBodyWeightToSports < ActiveRecord::Migration[5.1]
def change
add_column :sports, :body_weight, :string
end
end
|
class AddColumnToStockHolds < ActiveRecord::Migration[5.0]
def change
add_column :stock_holds, :stock_type, :string
add_column :stock_holds, :stock_name, :string
end
end
|
# Author: Hiroshi Ichikawa <http://gimite.net/>
# The license of this source is "New BSD Licence"
require "rubygems"
require "oauth2"
module GoogleDrive
class OAuth2Fetcher #:nodoc:
class Response
def initialize(raw_res)
@raw_res = raw_res
end
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.