text stringlengths 10 2.61M |
|---|
module Intent
class Craft < Action
attr_accessor :entity
attr_reader :recipe
def initialize(entity, recipe)
super entity
@recipe = recipe
# Add conventional costs
recipe.costs.each do |type, delta|
@costs[type.to_sym] = delta.to_i
end
debug recipe
end
def remaining
compile_costs if... |
class Duck
def swim
puts "swimming..."
end
# abstract
def display
raise "# abstract: Should be defined in the Subclass!"
end
end
|
# frozen_string_literal: true
require "spec_helper"
Class.new(LiteCable::Channel::Base) do
identifier "subscription_test"
def subscribed
reject if params["reject"] == true
@subscribed = true
end
def subscribed?
@subscribed == true
end
def unsubscribed
@unsubscribed = true
end
def u... |
class Sinatra::ContentFor2::SlimHandler < Sinatra::ContentFor2::BaseHandler
class << self
def setup_slim
return if @slim_set
if defined?(Slim)
Slim::Engine.set_default_options(:buffer => '@_out_buf', :generator => Temple::Generators::StringBuffer)
@slim_set = true
end
end
e... |
class Api::ProjectsController < ApplicationController
def index
@projects = Project.all
render :index
end
def create
@project = Project.new(project_params)
@project.author_id = current_user.id
if @project.save
@steps = @project.steps
@photos = @project.photos
render :show... |
class UseBigintForWastedTime < ActiveRecord::Migration
def up
change_column :users, :wasted_time, :bigint, :default => 0, :null => false
end
def down
change_column :users, :wasted_time, :integer, :default => 0, :null => false
end
end
|
module ByPreference
def self.included(base)
base.instance_eval do
has_many :prefs, class_name: "Preference", conditions: "preferences.owner_type = '#{self.class_name}'", foreign_key: :owner_id
end
base.class_eval do
def self.by_preference(name, value)
joins(:prefs).where(preferences... |
# frozen_string_literal: true
module Validators
module ChecklistOptionsValidatorHelper
CHECKED_FIELD_NOT_VALID = I18n.t error.checklist_option.checked_field.not_valid
CHECKLIST_NOT_PRESENT = I18n.t error.checklist_option.checklist.not_present
POSITION_NOT_PRESENT = I18n.t error.checklist_option.position.... |
require 'rails_helper'
RSpec.describe Abuse, :type => :model do
context 'associations' do
it { should belong_to(:user) }
it { should belong_to(:abusable) }
end
end
|
require "test_helper"
class Users::ReportsControllerTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
test "should create" do
commissioner = users(:commissioner)
sign_in(commissioner)
artist = users(:artist)
assert_difference("Report.count") do
post user_repor... |
require_relative '../platform.rb'
# Device Config
class ExampleDeviceConfig < DeviceConfig
# For illustration we'll add an additional 'username' property.
attr_reader :username
def initialize(config)
super(config)
@username = config['username']
raise "Version check definition for platform '#{Exa... |
# Enter your object-oriented solution here!
class Multiples
attr_accessor :limit
def initialize(limit)
@limit = limit
end
def collect_multiples
ar = []
(@limit-1).downto(1) do |num|
if num%3 == 0 || num%5 == 0
ar <<... |
class Room < ApplicationRecord
has_many :messages, dependent: :destroy
has_many :entries, dependent: :destroy
belongs_to :user, optional: true
end
|
unless defined? Grayskull::VERSION
$:.unshift File.expand_path("../lib", __FILE__)
require "grayskull/version"
end
Gem::Specification.new do |s|
s.name = "grayskull"
s.version = Grayskull::VERSION
s.summary = "Validates data files based on a provided schema"
s.description = "Will validate YAML and JSON fil... |
get '/' do
if session.has_key?(:credentials)
erb :logged_in
else
erb :index
end
end
|
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :email
t.string :username
t.string :password_hash
t.string :password_salt
t.boolean :admin, default: false
t.string :avatar, default: "http://image.shutterstock.com/display_pic_with_logo/... |
require 'rake/clean'
require 'rake/rdoctask'
require 'rake/packagetask'
# project configuration
require 'version'
PROJECT_ID = :rassmalog
PROJECT_SSH_URL = File.expand_path("~/www/lib/#{PROJECT_ID}")
PROJECT_VERSION = Rassmalog[:version]
desc "Show a list of available tasks."
task :default do
Rake.application.op... |
module StrokeDB
module Repositories
module MetadataHashLayer
Cuuid = "uuid".freeze
Cversion = "version".freeze
Cprevious_version = "previous_version".freeze
# Adds "version" fields to a hash before save.
# Returns version
def put(doc)
# Opera... |
class FoodGroupPairing < ApplicationRecord
belongs_to :food_group
belongs_to :food
validates :food_id, :serving_qty, presence: true
end
|
class AddFileSizeToPrice < ActiveRecord::Migration
def change
add_column :prices, :file_size, :integer
add_column :prices, :file_name, :string
add_column :prices, :human_size, :string
end
end
|
class User < ApplicationRecord
before_save { self.email.downcase! }
validates :name, presence: true, length: { maximum: 50 }
validates :email, presence: true, length: { maximum: 255 },
format: { with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i },
uniqueness: { case_sensitive: fal... |
require 'test_helper'
class ProductTest < ActiveSupport::TestCase
def setup
@product = products(:iPhone)
end
test "should not save product without name" do
@product.name = nil
assert_not @product.save
end
test "should not save product without product category" do
@product.product_category =... |
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the RoverHelper. For example:
#
# describe RoverHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# ... |
# frozen_string_literal: true
module Slack
module BlockKit
module Layout
# A block that collects information from users - it can hold a plain-text
# input element, a select menu element, a multi-select menu element, or a
# datepicker.
#
# https://api.slack.com/reference/block-kit/bl... |
#require "./lib/Concerns"
require "./Monster.rb"
require "./Equipment.rb"
require "./Room.rb"
require "./Parent.rb"
class Character < Parent
attr_accessor :name, :health, :status, :wealth, :weapon, :light, :armor
@@all = []
def initialize(name)
@weapon = nil
@armor = nil
@light = "Dark... |
require 'rubygems'
require 'rubygems/gem_runner'
require 'rubygems/exceptions'
module ChickenLittle
Uncommented_Line = "deprecate :default_executable"
class Patch
extend Commandable
command "Tries to fix your gems so they stop giving the deprication warning.", :default
def install
describ... |
class UpdateEnrollmentsStatus < ActiveRecord::Migration
def change
gi = Edu::Ugroup.where("created_at < ?", Time.new('2014/1/1')).ids
en = Acn::Enrollment.where(ugroup_id: gi)
en.update_all(status: "done")
end
end
|
# An example of how we would try and implement a simple ORM-like mapping using pseudo-ruby code
# Assumes a pg gem is available and the table is already created separarely.
# Goal: Have a class that represents our table and instances of that class represent rows/records.
class User
attr_accessor :email,
... |
class ObjectionListObjection < ApplicationRecord
belongs_to :objection_list
belongs_to :objection
end
|
# == Schema Information
#
# Table name: venues
#
# id :integer not null, primary key
# name :string
# address :string
# image_url :string
# created_at :datetime not null
# updated_at :datetime not null
# slug ... |
class User < Mongomatic::Base
def self.collection_name
'users'
end
def add_authentication(hash)
auths = (self['authentications'] ||= [])
auths << hash
end
def add_authentication_from_authinfo(auth)
self.add_authentication(
'provider' => auth['provider'],
'uid' => auth['uid'],... |
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::Schema::Member::BuildType do
describe ".parse_type" do
it "resolves a string type from a string" do
assert_equal GraphQL::Types::String, GraphQL::Schema::Member::BuildType.parse_type("String", null: true)
end
it "resolves an int... |
#
# Cookbook Name:: Sixpack
# Recipe:: default
#
# Copyright (C) 2014 Rick Saenz
#
# All rights reserved - Please Redistribute
#
include_recipe "python::default"
include_recipe "redisio::install"
include_recipe "redisio::enable"
include_recipe "python::default"
include_recipe "redisio::install"
include_recipe "redisi... |
class Api::V1::SongListSongsController < ApplicationController
# before_action :set_song_list, only: [:show, :update, :destroy]
# GET /song_list_songs
def index
@song_list_songs = SongListSong.all
render json: @song_list_songs
end
# GET /song_list_songs/1
def show
render json: @song_list_song... |
class RemoveAndAddColumns < ActiveRecord::Migration
def change
remove_column(:users, :curr_bets)
add_column(:bets, :match_starts_at, :datetime)
end
end
|
require 'rails_helper'
describe User do
it 'validates uniqueness of email' do
User.create!(
firstname: "Test",
lastname: "name",
password: "test",
email: "test@test.com"
)
user = User.new
user.firstname = "Test"
user.lastname = "Test"
user.password = "Test"
user.passwor... |
module Backup
module Adapters
class MySQL < Backup::Adapters::Base
attr_accessor :user, :password, :database, :skip_tables, :host, :port, :socket, :additional_options, :tables
private
# Dumps and Compresses the MySQL file
def perform
log system_messages[:mysql... |
class BatchClassTimingSet < ActiveRecord::Base
belongs_to :weekday
belongs_to :batch
belongs_to :class_timing_set
validate :class_timing_set_exists #, :presence => true
named_scope :default,:conditions=>"batch_id IS NULL"
def class_timing_set_exists
if ClassTimingSet.find_by_id(self.class_timing_set_id... |
class Product < ActiveRecord::Base
has_many :skinconditions
end |
#! /usr/bin/ruby
require 'rubygems'
require 'git-bro'
require 'sinatra'
require 'haml'
require 'sass'
require 'git-bro/sinatra/helpers'
require 'json'
set :run, true
begin
exit(1) if ARGV.size != 1
repository = GitBro::Repository.new(File.expand_path(ARGV.first))
rescue ArgumentError
puts "Cannot locate a repo... |
require 'socket'
require 'timeout'
require 'securerandom'
'''
keygenme server for CSAW CTF 2013
Jeffrey Crowell
Users must get 10 correct serials
within 5 seconds each
'''
server = TCPServer.open(80085) # Socket to listen on port 2000
loop { # Servers run forever
Thread.start(server.... |
class AddAttachmentCaipinimgToCaipins < ActiveRecord::Migration
def self.up
change_table :caipins do |t|
t.attachment :caipinimg
end
end
def self.down
remove_attachment :caipins, :caipinimg
end
end
|
class EARMMS::SystemDebuggingController < EARMMS::SystemController
before do
@appconfig_hidden = [
:session_secret,
]
end
get '/' do
next halt 404 unless logged_in?
next halt 404 unless has_role? 'system:debugging'
@title = "Debugging info"
haml :'system/debug/index'
end
post ... |
require 'faraday'
require 'json'
class Connection
BASE = ENV['ZYPE_API_URL']
def self.api
Faraday.new(url: BASE) do |faraday|
faraday.response :logger
faraday.adapter Faraday.default_adapter
faraday.params[:app_key] = ENV['ZYPE_API_APP_KEY']
faraday.headers['Content-Type'] = 'applicati... |
require "middleman-core"
require "pathname"
require "padrino-helpers"
require_relative "image"
module Middleman
module Images
class Extension < ::Middleman::Extension
option :optimize, false, "Whether to optimize images by default"
option :image_optim, {}, "Default options for image_optim"
opti... |
# 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 bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# ... |
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'helper'
require 'ostruct'
class TestQueueBundle < Test::Unit::TestCase
def test_simple_index
queue = QueueBundle.new(5, :hash_algorithm => :simple_index)
assert_equal :simple_index... |
class Book < ActiveRecord::Base
attr_accessible :isbn, :title, :author
validates :isbn, :title, :author, :presence => true
validates_uniqueness_of :title, :message => ": Título já cadastrado!"
end |
class Api::V1::ProductSerializer < ActiveModel::Serializer
attributes :id,
:name,
:description,
:price,
:created_at,
:provider_id
embed :ids, include: true
has_one :provider, key: :providers, root: :providers, serializer: Api::V1::ProviderSe... |
class CreateUsers < ActiveRecord::Migration[5.1]
def change
create_table :users do |t|
t.string :email, null: false, default: ""
t.string :display_name, null: false, default: ""
t.timestamps
end
add_column :users, :playlists, :string, null: false, default: [''], array: true
end
end
|
class AddKanbanIdToKanbanMilestones < ActiveRecord::Migration[5.0]
def change
add_column :kanban_milestones, :kanban_id, :integer
add_index :kanban_milestones, :kanban_id
end
end
|
require 'lita'
module Lita
module Handlers
class Fortune < Handler
route(/fortune/, :fortune, command: true, help: {
'fortune' => 'Returns your fortune.'
})
def self.default_config(handler_config)
end
def run_cmd(cmd)
`#{cmd}`
end
def fortune(response)... |
class Passenger < ActiveRecord::Base
has_many :rides
has_many :drivers, through: :rides
# def drivers
# self.rides.map { |ride_instance| ride_instance.driver }
# end
def most_expensive_ride
self.rides.order("price DESC").first
end
end
|
class ShopsController < ApplicationController
before_action :authenticate_user!, except: :index
def index
@category_parents = Category.where(ancestry: nil)
@brands = Brand.all
@items = Item.includes(:category).where(item_status: false).order("created_at DESC").limit(3)
end
end
|
# == Informacion de la tabla
#
# Nombre de la tabla: *dbm_descriptor_generico*
#
# idDescriptorGenerico :integer(11) not null, primary key
# descriptorGenerico :string(100) default(""), not null
#
# Clase que representa a la tabla dbm_cargo
# Tiene relaciones con las siguientes clases:
class DescriptorGener... |
class CustomRole < ActiveRecord::Base
has_many :user_custom_roles
has_one :user_permission
def self.orderRanking
order("ranking ASC, role_name ASC")
end
end
|
#!/usr/bin/env ruby
# encoding: UTF-8
#
# htdocs/hermesdemo.rb -- Build the CSS
#
require "hermeneutics/css"
require "hermeneutics/color"
module HermesDemo
class MainCss < Hermeneutics::Css
BG_BLUE = "dfdfff".to_rgb
def build
body :background_color => BG_BLUE
end
end
end
Hermeneutics:... |
module WorkoutsHelper
def new_workout_score_path(workout)
"/scores/new/#{workout.id}" unless workout.nil?
end
def workout_name(workout)
workout.name.empty? ? workout.created_at.to_s(:long) : workout.name
end
end
|
module Common
class SeedGrowPhase
prepend SimpleCommand
def initialize(args = {})
@args = args
end
def call
seed_grow_phase!
nil
end
private
def seed_grow_phase!
grow_phase_templates.each do |phase|
Common::GrowPhase.find_or_create_by!(phase)
end
... |
class Cell
attr_reader :x, :y, :index
def initialize(x, y, board_id)
@x = x
@y = y
@index = Cells.index(x, y)
@color = nil
@board_id = board_id
end
def set(color)
raise index + ': This cell is already filled.' if filled?
@color = color.to_sym
end
def reverse
raise index + ... |
require 'rails_helper'
describe "Publishers to collections relationship" do
before(:all) do
@avrail = FactoryGirl.create(:collection, :name => 'Les Aventuriers')
@wonders = FactoryGirl.create(:collection, :name => 'Merveilles')
@dow = FactoryGirl.create(:publisher, :name => 'Days of Wonder')
end
it... |
require "rails_helper"
RSpec.describe RecurringEvent, type: :model do
it "can create a recurring event" do
recurring_event = RecurringEvent.create(name: "plant watering", start_date: Date.new(2017, 3, 11), number_months: 1)
expect(recurring_event).to_not be_nil
end
it "has a calculated date based on the... |
# encoding: utf-8
#! /usr/bin/env ruby
##
# Auteur CrakeTeam
# Version 0.1 : Date : Mon Mar 17 09:42 2013
#
require_relative 'Fenetre'
class FenetreChoixGrille < Fenetre
@texteChoixGrille
@boutonToutesGrilles
@boutonGrillesPerso
@boutonGrilleAleatoire
@boutonPrecedent
attr_reader :texteChoixGrille,
... |
require 'pry'
module FuzzyClock
TIME_WORDS = {
1 => 'one',
2 => 'two',
3 => 'three',
4 => 'four',
5 => 'five',
6 => 'six',
7 => 'seven',
8 => 'eight',
9 => 'nine',
10 => 'ten',
11 => 'eleven',
12 => 'twelve',
15 => 'fifteen',
20 => 'twenty',
25 => 'twenty-f... |
# the purpose of this module is to give names to each hand, such as
# full house, three of a kind, etc. Also to compare two hands by description.
module HandDescribable
def ranks
cards.map {|c| c.rank }
end
def suits
cards.map {|c| c.suit }
end
def rank_count
ranks.uniq.count
end
def suit... |
#!/usr/bin/env ruby
# yes i put ruby1.9 instead of ruby because of debian, i know
#i need to fix that, i'll do it later
#require "sandbox"
require 'cgi'
require 'popup.rb'
require 'stringio'
require 'cgi/session'
require 'cgi/session/pstore' # provides CGI::Session::PStore
require 'tryruby_runner.rb'
class TryRub... |
cask :v1 => 'iphoto-library-manager' do
version '4.1.10'
sha256 '2ab9ec177b2c6ee94847ea6c2164a51f86e2c9e288433f9f7a4f20ab175be519'
url "https://s3.amazonaws.com/fatcatsoftware/iplm/iPhotoLibraryManager_#{version.gsub('.', '')}.zip"
name 'iPhoto Library Manager'
homepage 'http://www.fatcatsoftware.com/iplm/'
... |
class CreateSolveStatuses < ActiveRecord::Migration
def change
create_table :solve_statuses do |t|
t.references :user, :null => false
t.references :problem, :null => false
t.json :tasks, :default => {}, :null => false
t.index [:user_id, :problem_id], :unique => true
t.index [:proble... |
require 'spec_helper'
describe 'Resumen' do
before(:each) do # rubocop:disable Metrics/BlockLength
@plan = Plan.new(nombre: 'Juventud', costo: 1000,
cobertura_visitas: CoberturaVisita.new(0, 0),
cobertura_medicamentos: CoberturaMedicamentos.new(0),
c... |
class CreateLocationShares < ActiveRecord::Migration[6.1]
def change
create_table :location_shares do |t|
t.references :user, foreign_key: true
t.string :address, :default => ""
t.decimal :lat, :precision => 15, :scale => 10
t.decimal :long, :precision => 15, :scale => 10
t.boolean :is_p... |
require 'spec_helper'
describe 'circus::manager' do
it do
should contain_file('/etc/circus.ini') \
.with_content(/check_delay = 5/)
end
# test the defaults work
it do
should contain_package('circus').with({
'ensure' => '0.8.1-1',
'alias' => 'circus'
})
end
co... |
class AddTeacherToUsers < ActiveRecord::Migration
def change
add_column :users, :teacher, :int
end
end
|
class User < ActiveRecord::Base
validates :username, :presence => true, :uniqueness => true
validates :real_name, :presence => true
validates :password, :presence => true, :confirmation => true
has_many :registrations
has_many :courses, through: :registrations
has_one :quiz
has_many :groop_registrations
... |
# Written by Samuel Burns Cohen
# Jan 24, 2019
#
# Parameter.rb
#
# This file defines the Parameter class
class Parameter
attr_reader :name
def initialize(name, value)
@name, @value = name, value
end
def value=(value)
@value = value
end
def value()
if @value.respond_t... |
# Require the dependencies file to load the vendor libraries
require File.expand_path(File.join(File.dirname(__FILE__), 'dependencies'))
class VmwareVsphereVirtualmachineCloneV1
# Include the necessary Java classes to be used for this handler
include_class java.net.URL
include_class com.vmware.vim25.mo.Folder
... |
class Item < ActiveRecord::Base
belongs_to :user
belongs_to :event
has_many :payments
before_save :escape_tag
validates :memo, presence: true, length: { maximum: 20 }
validates :price, presence: true, numericality: { only_integer: true, greater_than: 0 }
validates :user_id, presence: true
validates :e... |
class CreateBids < ActiveRecord::Migration
def change
create_table :bids do |t|
t.integer :job
t.integer :helper
t.datetime :jobdatetime
t.string :note
t.timestamps null: false
end
end
end
|
class Alumnos::RegistrationsController < Devise::RegistrationsController
before_filter :configure_permitted_parameters
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) do |u|
u.permit(:email, :password, :password_confirmation,:carrera, :no_cuenta, :CURP, :RFC, :se... |
class User < ActiveRecord::Base
belongs_to :tenant
attr_accessible :email, :password, :password_confirmation,:tenantId,:status,:perishable_token
acts_as_authentic do |c|
c.login_field = :email
end
def lock email
user = User.find_by_email(email)
if user
user.status = User_status::LOCKED
... |
# frozen_string_literal: true
## --- BEGIN LICENSE BLOCK ---
# Copyright (c) 2016-present WeWantToKnow AS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including wit... |
require File.expand_path('../test_helper', File.dirname(__FILE__))
class UserTest < ActiveSupport::TestCase
test "creates a valid mark" do
time = Time.now
mark = Mark.new( {:last_updated => time,
:marks_data => []})
assert_equal time, mark.last_updated
end
test "creates a valid mark... |
# Cookbook Name:: ant
# Attributes:: default
default['ant']['install_method'] = 'package'
# Needed when installation is done using source mathod.
default['ant']['version'] = '1.9.7'
default['ant']['home'] = '/usr/local/ant'
default['ant']['url'] = 'http://archive.apache.org/dist/ant/binari... |
require "helper"
require "multi_json"
module Neovim
RSpec.describe Logging do
around do |spec|
old_logger = Logging.logger
begin
Logging.send(:remove_instance_variable, :@logger)
spec.run
ensure
Logging.logger = old_logger
end
end
describe ".logger" do
... |
class AddProximityToEntitiesList < ActiveRecord::Migration[5.1]
def change
add_column :entities_lists, :proximity, :integer, default: EntitiesList.proximities['glued']
end
end
|
# frozen_string_literal: true
class AddPublicToBlog < ActiveRecord::Migration[5.2]
def change
add_column :blogs, :public, :boolean, default: true
end
end
|
class FontPraise < Formula
head "https://github.com/google/fonts/raw/main/ofl/praise/Praise-Regular.ttf", verified: "github.com/google/fonts/"
desc "Praise"
desc "Versatile script with variations from casual (non-connecting) to formal appeal"
homepage "https://fonts.google.com/specimen/Praise"
def install
... |
require './core/tetrimino'
require './core/block'
require './core/player'
require './utility/point'
class Board
attr_reader :width, :height, :tetriminos, :array
attr_accessor :current_tetrimino
def initialize(player, width, height, nextpieces, *tetriminos)
@player = player
@width = width
@height = ... |
#!/bin/env ruby
# encoding: utf-8
require 'rubygems'
require 'rspec'
require 'watir-webdriver'
require_relative 'rspec_helper'
require_relative '../lib/pages/login_page'
require_relative '../lib/pages/common_test'
describe 'Story#1101: Pilot_login.rb', :acceptance => true do
include DriverUtility
before(:all) d... |
class EnquetesController < ApplicationController
before_filter :admin_login
def index
@surveys = Enquete.all()
respond_to do |format|
format.html
format.json { render json: @surveys }
end
end
def show
@survey = Enquete.find(params[:id])
respond_to do |format|
format.html
... |
=begin
#Rakam API Documentation
#An analytics platform API that lets you create your own analytics services.
OpenAPI spec version: 0.5
Contact: contact@rakam.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file e... |
require 'rails_helper'
RSpec.describe SessionAuthenticator do
let(:user){
FactoryGirl.create :user,
:email => 'user@email.com',
:password => 'password'
}
context 'when credentials are valid' do
let(:session_auth){
SessionAuthenticator.new(
:email => 'user@email.com',
... |
require 'openid/store/interface'
module OpenID
module Store
class Mongo < OpenID::Store::Interface
class Association
include MongoMapper::Document
set_collection_name :open_id_authentication_associations
key :issued, Integer
key :lifetime, Integer
key :handl... |
require 'aws/broker/base'
module Aws
class Broker
class Subscriber < Base
def initialize(topic, queue=nil)
@topic = topic
@queue = queue || queue_name
end
def subscribe
return unless enabled?
create_queue
find_queue_arn
create_topic
sns.... |
# Sum of Digits
# Write a method that takes one argument, a positive integer, and returns the sum of its digits.
def sum(num, base = 10)
num.digits(base).sum
end
puts sum(23) == 5
puts sum(496) == 19
puts sum(123_456_789) == 45
|
class Soy < CondimentDecorator
attr_reader :beverage
def get_size
beverage.get_size
end
def get_description
"#{beverage.get_description}, Soy"
end
def cost
beverage_cost = beverage.cost
if get_size == :small
0.1 + beverage_cost
elsif get_size == :big
0.2 + beverage_cost
... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
class PresentationParentTestClass
include Vedeu::Presentation::Parent
def initialize(attributes = {})
@colour = attributes[:colour]
@name = attributes[:name]
@parent = attributes[:parent]
end
end # PresentationPar... |
class Game
include Mongoid::Document
field :name, type: String
field :game_type, type: String
field :location, type: String
field :city, type: String
field :state, type: String
field :zip, type: String
field :date, type: String
field :time, type: String
field :player_max, type: String
field :equi... |
module Rhouse::Models
class CommandGroup < ActiveRecord::Base
set_table_name 'CommandGroup'
set_primary_key "PK_#{CommandGroup.table_name}"
# relationships...
belongs_to :array,
:foreign_key => "FK_Array",
:class_name => "Rhouse::Models::Array"
belongs_to :installation,
... |
class Intent < ApplicationRecord
serialize :locales, JSON
end
class AddLocalesToAgent < ActiveRecord::Migration[5.1]
def up
ActiveRecord::Base.record_timestamps = false
begin
add_column :agents, :locales, :jsonb
Agent.reset_column_information
Agent.all.each do |agent|
intents_loca... |
class GroupBuysController < ApplicationController
before_filter :authorize
respond_to :json
def index
@group_buys = GroupBuy.all
end
def show
@group_buy = GroupBuy.find(params[:id])
end
def new
@group_buy = GroupBuy.new
end
def create
@group_buy = GroupBuy.new(params[:group_buy])
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.