text stringlengths 10 2.61M |
|---|
module ReqresRspec
module Formatters
class Base
def initialize(records)
@records = records
@output_path = ReqresRspec.configuration.output_path
@logger = ReqresRspec.logger
end
attr_reader :logger, :output_path, :records
def process
cleanup
write
... |
class Build
include Mongoid::Document
field :clone_log, type: Array, default: []
field :dependency_log, type: Array, default: []
field :test_log, type: Array, default: []
field :clone_time, type: Integer
field :dependency_time, type: Integer
field :test_time, type: Integer
belongs_to :project
valid... |
module Git
class Author
attr_accessor :name, :email, :commits
def initialize(name)
@name = name
@commits = []
end
def lines
@commits.flat_map(&:lines)
end
end
end
|
class CreateWholesaleBooks < ActiveRecord::Migration[5.0]
def change
create_table :wholesale_books do |t|
t.string :url
t.string :isbn
t.string :status
t.string :amazon_product_id
t.text :html_src
t.timestamps
end
end
end
|
class InterestsController < ApplicationController
def new
@html_content = render_to_string :partial => "/interests/new.haml"
respond_to do |format|
format.js { render :template => "/common/new.rjs"}
end
end
def create
begin
ActiveRecord::Base.transaction do
@interest = In... |
#require "cddb_parser/version"
#require 'active_record'
require 'yaml'
#require_relative '../lib/db_stuff'
module CddbParser
class GetOpts
LIST_CODES = %w[all artist info meta track]
LIST_ABBREV = {
'a' => 'all', 'art' => 'artist', 'i' => 'info', 'm' => 'meta', 't' => 'track'
}
def self.parse(args)
#... |
# encoding: utf-8
#
# 4.4.3. REPLY-TO / RESENT-REPLY-TO
#
# Note: The "Return-Path" field is added by the mail transport
# service, at the time of final deliver. It is intended
# to identify a path back to the orginator of the mes-
# sage. The "Reply-To" field is added by... |
class RevenueSerializer
include FastJsonapi::ObjectSerializer
attribute :revenue do |object|
(object.sum.to_f / 100).to_s.ljust(2, "0")
end
end
|
class Department < ActiveRecord::Base
attr_accessible :code, :name
validates :code, :name, :presence => true
has_many :requests
end
|
# module API
module Railsapp
module V1
class Searchapi < Grape::API
include Railsapp::V1::Defaults
format :json
resource :searchapi do
desc "Return all search"
get "", root: :search do
error!({:error_message => "Please provide a valid search srting."}, 422)
end... |
Rails.application.routes.draw do
devise_for :users, controllers: {
sessions: 'users/sessions'
}
get 'not_found', to: 'not_found#index', as: :not_found
match '/404', to: 'not_found#index', via: :all
match '/500', to: 'not_found#index', via: :all
devise_scope :user do
unauthenticated :user do
... |
class Type < ActiveRecord::Base
validates :name, presence: true
validates_uniqueness_of :name, :poke_type_id
has_many :pokemon_types
has_many :pokemons, through: :pokemon_types
end
|
=begin
These plugins deal with monitoring status
as well as changing notification levels.
=end
Command.new do
name "Status"
desc "Shows basic status"
help <<-eof
This command shows you your basic status, including your notification and
message levels.
eof
syntax "+news status"
match(/^status/)
trigger do... |
FactoryGirl.define do
factory :oauth_access_token, class: Doorkeeper::AccessToken do
resource_owner_id { create(:user, :confirmed).id }
expires_in { 2.hours }
end
end
|
class Picture < ApplicationRecord
belongs_to :user
has_many :comments, dependent: :destroy
has_many :instagratifications
has_attached_file :image, :styles => { :medium => "500x500>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
validates_attachment_content_type :image, :content_type =>... |
class CategoriesController < ApplicationController
def index
@images = {
"Fashion" => "https://res.cloudinary.com/dzpgbbhmm/image/upload/v1606483237/impact/fashion_banner_lhl4gk.jpg",
"Plants" => "https://res.cloudinary.com/dzpgbbhmm/image/upload/v1606483237/impact/plants_banner_hlhohn.jpg",
"Fo... |
=begin
--------------------------------------------------------------------------------
As with convert_directory, keep the subdirectory structure and corresponding fileames.
When breaking, append to the filename __001, __002, etc.
If the file is small enough, keep the original filename and just copy.
Stupid approach... |
# This is a simple ruby script that scrapes the opt-ins from the
# LaunchRock API and prints it to Standard Out. It is an example
# of calling the raw API's rather than using the gem.
#
# example command line syntax:
# email="yoloswagdude@gmail.com" password="shredddd" site_name="Yolosite" ruby raw.rb
require './' + F... |
class RemoveFromIdToIdFromNotifications < ActiveRecord::Migration
def change
remove_column :notifications, :from_id
remove_column :notifications, :to_id
end
end
|
module ModelStack
module DSLClass
class Scope
attr_accessor :path
attr_accessor :controllers
def initialize
self.controllers = []
end
def controller_with_identifier(identifier)
rt = nil
self.controllers.each do |c|
if c.identifier == identifier
... |
class EmailList < ActiveRecord::Base
attr_accessor :remote_name
belongs_to :owner, :polymorphic => true
has_many :email_list_memberships, :dependent => :delete_all
has_many :members, :through => :email_list_memberships
named_scope :external, :conditions => { :frequency => :external }
####
# M... |
require 'rails_helper'
RSpec.describe Comment, :type => :model do
it "isn't valid without name" do
comment = Comment.new
comment.name = nil
expect(comment).not_to be_valid
end
it "isn't valid without mail_address" do
comment = Comment.new
comment.name = nil
expect(comment).not_to be_vali... |
require 'spec_helper'
describe JobSerializer do
fixtures :jobs, :job_steps, :job_templates
let(:state) { { 'status' => 'running', 'stepsCompleted' => '1' } }
let(:fake_dray_client) { double(:fake_dray_client, get_job: state) }
before do
allow(PanamaxAgent::Dray::Client).to receive(:new).and_return(fake_d... |
class RemoveStatsFromStaffMembers < ActiveRecord::Migration
def self.up
StaffMember.transaction do
StaffMember.all.each do |member|
Stat.create!(:stat => member.stats, :staff_member_id => member.id)
end
remove_column :staff_members, :stats
end
end
def self.down
add_column... |
class Person
# #name= (setter) instance method, writes the person's name, name_string, to an instance variable, @name (i.e. for setting or changing the name, name_string)
def name=(name_string)
@name = name_string
end
# #name (getter) instance method, reads the person's name, name_string, from an instance ... |
module CounterHash
class Counter
attr_reader :element
attr_accessor :count
def initialize element
@element, @count = element, 1
end
end
end
|
require 'test_helper'
class HuntGroupMembersControllerTest < ActionController::TestCase
setup do
@hunt_group_member = hunt_group_members(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:hunt_group_members)
end
test "should get new" do
get ... |
#!/usr/bin/env ruby
#@# vim: set filetype=ruby:
require_relative "./lib/similar_image_search_services_pb"
module ::SimilarImageSearch
class Client
##
# @const
#
DEFAULT_HOST = "127.0.0.1"
##
# @const
#
DEFAULT_PORT = "50051"
##
# @const
#
SEARCH_HASH_BLANK = "0" * 64... |
require 'pry'
class EventsController < ApplicationController
before_action :require_login
def rent
@event = Event.find(params[:id])
end
def new
@event = Event.new
end
def create
event = Event.create(event_params)
redirect_to "/events/#{event.id}/garages"
en... |
require "formula"
class Snap7 < Formula
homepage "http://snap7.sourceforge.net/"
url "https://downloads.sourceforge.net/project/snap7/1.2.1/snap7-full-1.2.1.tar.gz"
sha1 "1e661fea17c26586599c11a1a840f4ac013060b6"
bottle do
cellar :any
sha1 "89adc1a116219fccee8f6cc8c9bdb1632afa7069" => :mavericks
s... |
And(/^I fill in all the fields, except "([^"]*)" for dispute reason 'I was charged the wrong amount' dispute reason$/) do |exclude_this_field_data|
# puts exclude_this_field_data
DataMagic.load 'disputes.yml'
# p on(DisputesPage).i_was_charged_wrong_amount(exclude_this_field_data)
@questions, @field_type, @res... |
require_relative '../test_helper'
require_relative '../bird_factory'
class BirdTest < MyAppTest
def test_returns_welcome_message
get '/'
assert last_response.ok?
assert_equal 'Welcome to BirdList!', last_response.body
end
def retrieve_specific_bird
bird = FactoryGirl.create(:bird)
get "/api/... |
require 'spider/page'
require 'set'
module Spider
class CookieJar
include Enumerable
def initialize
@params = {}
@dirty = Set[]
@cookies = {}
end
def each(&block)
@params.each(&block)
end
def [](host)
@params[host] ||= {}
end
def []=(host,cookie... |
#
# Titanium mobile Rakefile for iOS build
#
DEV_PROVISIONING_UUID = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
DEV_SIGN = "Mystic Coders, LLC"
DEV_APP_NAME = "mobileweather"
DEV_APP_ID = 'com.mysticcoders.mobileweather'
DEV_APP_DEVICE = 'iphone'
USER_ROOT = "/your/root/path"
TITANIUM_SDK_VERSION = '2.1.3.GA'
IPHONE_SD... |
class Camlp5TransitionalModeRequirement < Requirement
fatal true
satisfy(:build_env => false) { !Tab.for_name("camlp5").with?("strict") }
def message; <<~EOS
camlp5 must be compiled in transitional mode (instead of --strict mode):
brew install camlp5
EOS
end
end
class Ssreflect < Formula
desc... |
class ProjectActivityRole < ActiveRecord::Base
self.table_name = 'projects_activity_roles'
validates :project_id, :role_id, :activity_id ,:presence => true
belongs_to :project
belongs_to :role_activity, :class_name => 'TimeEntryActivity', :foreign_key => 'activity_id'
belongs_to :role
end |
class AccrualDecorator < BaseDecorator
def parent_display_path
h.update_display_accrual_path(cfs_directory_id: cfs_directory_id, staging_path: path_up)
end
def child_display_path(child_name)
h.update_display_accrual_path(cfs_directory_id: cfs_directory_id, staging_path: path_down(child_name))
end
#... |
module VestalVersions
# Adds the ability to "reset" (or hard revert) a versioned ActiveRecord::Base instance.
module Reset
def self.included(base) # :nodoc:
Version.send(:include, VersionMethods)
base.class_eval do
include InstanceMethods
end
end
# Adds the instance methods r... |
class Event < ApplicationRecord
validates :starts_at, :ends_at, :kind, presence: :true
def self.availabilities(start_date = DateTime.now)
availabilities = []
# 1.fetch all recuring and non-recuring events for the next seven days
events = Event.where("starts_at >= ? OR weekly_recurring = ?", start_date.... |
class Node
attr_accessor :data, :left, :right
def initialize(data)
@data = data
@left = nil
@right = nil
end
end
class Tree
attr_accessor :root, :data
def initialize(array)
@data = array.sort.uniq
@root = build_tree(data)
end
def build_tree(array)
return nil if array.length ===... |
class MessagesController < ApplicationController
helper_method :sort_column, :sort_direction
before_action :set_message, only: [:show, :edit, :update, :destroy]
before_action :check_company
before_action :check_auth, only: [:edit, :update, :destroy]
# GET /messages
# GET /messages.json
def index
# Ge... |
require 'spec_helper'
feature 'Catalog dataset metadata' do
before do
@user = FactoryGirl.create(:user)
given_logged_in_as(@user)
end
scenario 'fills the dataset metadata' do
catalog = create(:catalog, organization: @user.organization)
dataset = create(:opening_plan_dataset, catalog: catalog)
... |
require 'rails_helper'
describe Review do
it { is_expected.to belong_to :user }
it { is_expected.to belong_to :business }
it { is_expected.to validate_presence_of :rating }
it do
is_expected.to validate_numericality_of(:rating)
.only_integer
.is_greater_than_or_equal_to(0)
.is_less_than_o... |
class Item < ActiveRecord::Base
belongs_to :list
validates :description,
presence: true,
length: { minimum: 1, maximum: 120 }
validates :list,
presence: true
end
|
require 'spec_helper'
describe 'etckeeper' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end
context 'managing the VCS package' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('etckeeper') }
i... |
class User < ActiveRecord::Base
has_secure_password
validates :password, length: {minimum: 7}
validates :email, presence: true, uniqueness: { case_sensitive: false }
validates :first_name, presence: true
validates :last_name, presence: true
auto_strip_attributes :email, virtual: true
before_sav... |
katz_deli = ["bob", "karl"]
def line(katz_deli)
if
katz_deli.count == 0
puts "The line is currently empty."
else
current_state = []
katz_deli.each.with_index(1) do |name, index|
current_state << "#{index}. #{name}"
end
puts "The line is currently: #{current_state.join(" ... |
class Disque < Formula
desc 'Disque is a distributed message broker'
homepage 'https://github.com/antirez/disque'
head 'https://github.com/antirez/disque.git'
devel do
url 'https://github.com/antirez/disque/archive/1.0-rc1.tar.gz'
version '1.0-rc1'
sha256 '2d6fc85d16c8009154fc24d7fb004708f86471285... |
class List < ApplicationRecord
belongs_to :user, required: false
belongs_to :listname, required: false
def self.currentlist(id)
where(listnameid: id).order("id")
end
def self.getlist(items)
list = []
items.each do |item|
list << List.find_by(id: item)
end
list
end
def self.buy(itemname,userid)
... |
require 'pact_broker/db'
require 'pact_broker/repositories/helpers'
module PactBroker
module Tags
# The tag associated with the latest verification for a given tag
class TagWithLatestFlag < Sequel::Model(:tags_with_latest_flag)
dataset_module do
include PactBroker::Repositories::Helpers
... |
namespace :db do
desc 'Reset Counter Cache!'
task :reset_counter => :environment do
puts "prepare to reset counter"
Candidate.all.each do |candidate|
Candidate.resrt_counters(candidate.id, :vote_logs)
end
puts "done!"
end
end |
class User < ActiveRecord::Base
has_secure_password
has_many :things
def self.username_check(username)
self.all.detect do |user|
user.username == username
end
end
end
|
require File.join(File.dirname(__FILE__), '../spec_helper.rb')
describe RubyTSQL::TdsCore do
def print_binary(input)
input = input.to_s unless input.kind_of? String
output = ''
input.each_byte do |char|
output += char.to_i.to_s + ' '
end
p output
end
before(:all) do
... |
class AddDesiredIntervalToUsers < ActiveRecord::Migration
def change
add_column :users, :desired_interval, :integer
add_column :entries, :total_time, :integer
end
end
|
#!/usr/bin/env ruby
require 'test/unit'
require_relative 'AwsTresholdManager'
class MyTest < Test::Unit::TestCase
def setup
@aws = AwsTresholdManager.instance
@instance_id = @aws.get_available_instance_ids[0]
end
# arguments are instance_id, optional time from
def test_cpu_average_load
cpu_average ... |
module WCC
class FilterRef
attr_reader :id, :arguments
def initialize(id, arguments = {})
@id = id
@arguments = arguments
end
def to_s; @id end
end
class Filters
@@filters = {}
# API method - register a filters code block under given ID.
# Should be called by filters the following way:
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Death, type: :model do
it 'is valid with user' do
death = create(:death)
expect(death).to be_valid
end
context 'when associating' do
it { is_expected.to belong_to(:user) }
end
context 'when calling methods' do
describe '#u... |
class Book < ActiveRecord::Base
validates :title, :author, presence: true
has_many :reviews
has_many :book_shelvings
# Use this for seeding
def self.get_book_from_api(title)
query_string = title.scan(/\w+/).join('+')
query_url = "https://www.googleapis.com/books/v1/volumes?q="\
"#{query_string... |
class CartItem < ApplicationRecord
belongs_to :item
belongs_to :customer
def subtotal
item.with_tax_price*amount
end
end
|
class Api::ListingsController < ApplicationController
def create
@listing = Listing.new(listing_params)
if @listing.save
render 'api/listings/show'
else
render json: @listing.errors.full_messages, status: 422
end
end
def edit
# @listing = Listing.find(params[:listing][:id])
... |
class PostShare < ActiveRecord::Base
attr_accessible :post_id, :friend_elipse_id
validates_uniqueness_of :post_id, scope: :friend_elipse_id
belongs_to :post,
class_name: "Post",
primary_key: :id,
foreign_key: :post_id
belongs_to :friend_elipse,
class_name: "FriendElipse",
primary_key: :id,
foreig... |
require 'spec_helper'
describe ServiceLinkExistsValidator do
let(:image_one) { Image.new(name: 'foo') }
let(:image_two) { Image.new(name: 'bar') }
let(:template) { Template.new(images: [image_one, image_two]) }
let(:record) { Image.new(template: template) }
let(:attribute) { 'links' }
subject { described... |
class RenameAuthenticationsToUserTokens < ActiveRecord::Migration
def self.up
rename_table :authentications, :user_tokens
end
def self.down
rename_table :user_tokens, :authentications
end
end
|
Dashing::Engine.routes.draw do
resources :events, only: :index
resources :dashboards, only: :index do
get '/:name', action: :show, on: :collection
end
resources :widgets, only: [] do
get '/:name', action: :show, on: :collection
put '/:name', action: :update, on: :collection
end... |
module Transferit
module V1
module Entities
class Cities < Grape::Entity
expose :title
expose :id
end
class Pages < Grape::Entity
expose :total_count
end
end
class Cities < Grape::API
format :json
resource :cities do
desc 'Get cities ... |
require 'spec_helper'
require 'authenticate/model/email'
describe Authenticate::Model::Email do
it 'validates email' do
user = build(:user, :without_email)
user.save
expect(user.errors.count).to be(2)
expect(user.errors.messages[:email]).to include('is invalid')
expect(user.errors.messages[:email... |
require 'test_helper'
class CallTest < ActiveSupport::TestCase
test 'Call updated successfully with new vmake' do
customer = Customer.create(title: 'Mr', first_name: 'Bhushan', last_name: 'Kalode', gender: 'male')
user = User.create(email: 'bhushan@gmail.com', password: 'bhushan')
call = Call.create(vmak... |
module Hookable
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def hook(method_name, hook_name)
alias_method "unhooked_#{method_name}", method_name
define_method method_name do |*args, &block|
send "unhooked_#{method_name}", *args, &block
send hook_na... |
class RemoveOfficesForeignKey < ActiveRecord::Migration
def change
remove_foreign_key 'offices', 'users'
end
end
|
require 'spec_helper'
describe MarchMadness::Engine do
let(:qualifier_rank) { (101..132).to_a.map{|id| "id: #{id}"} }
subject(:engine) { MarchMadness::Engine.new qualifier_rank }
its(:bracket_size) { is_expected.to eq qualifier_rank.size }
describe "#bracket_mapping" do
subject(:bracket_mapping) { engine... |
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "pricegem/version"
Gem::Specification.new do |spec|
spec.name = "pricegem"
spec.version = Pricegem::VERSION
spec.authors = ["marknci"]
spec.email = ["m.arkhayden@hotmail.com"... |
Rails.application.routes.draw do
resources :attachments, only: [:destroy, :index]
resources :blackouts, except: [:show]
resources :comments, only: [:create, :destroy]
resources :emails, only: [:index, :show, :update] do
collection do
get 'sent'
get 'unread'
get 'reply'
post 'rep... |
require 'rails_helper'
RSpec.describe MicropostsController, type: :controller do
render_views
describe "access control" do
it "should deny access to create" do
post :create
expect(response).to redirect_to(signin_path)
end
it "should deny access to destroy" do
delete :destroy, :id => 1
expect(r... |
class MapsController < ApplicationController
before_action :authenticate_user!
before_action :has_map?, :only => [:edit, :update]
before_action :set_twitter_client
def new
tweets = @twitter_client.user_timeline(count: 1000)
geo_tweets = only_geo_tweets(tweets)
@tweets = to_hash(geo_tweets)
end
... |
require_relative 'instance_counter'
class RailwayStation
include InstanceCounter
@@instances = []
attr_reader :name, :trains, :train_type
def initialize(name)
@name = name
@train_type = train_type
@trains = []
@@instances << self
register_instance
end
def self.all
puts @@instances.... |
class AddUpdatedByIdToTradeRestrictionPurposes < ActiveRecord::Migration
def change
add_column :trade_restriction_purposes, :updated_by_id, :integer
end
end
|
class Schedule < ActiveRecord::Base
include Concerns::Cacheable
include Concerns::Features
include Concerns::FeatureVectors
FEATURE_METHODS = {
classes_per_course: [],
season_count: [],
year_count: [],
class_count: [{ mode: :deviation }],
unit_count: [{ mode: :deviation }, { mode: :average ... |
require 'spec_helper'
describe "Employee" do
before :all do
@employee = build(:employee)
end
it "should be valid" do
@employee.should be_valid
end
it "name should be present" do
@employee.name = " "
@employee.should_not be_valid
end
it "emploee number should be present" do
@emplo... |
Gem::Specification.new do |s|
s.name = %q{jar_has_class}
s.version = "0.0.3"
s.date = %q{2016-03-02}
s.authors = ["Zp Yuan"]
s.summary = %q{find jar has XXX class in pwd recursively}
s.files = Dir.glob("bin/*") + Dir.glob("lib/*")
s.require_paths = ["lib"]
s.executables = ["jar_has_class"]
s.add_depen... |
class DevelopmentalLevel < ActiveRecord::Base
belongs_to :student
#
# V A L I D A T I O N S
#
validate :validate_date
validate :duration, presence: true
validate :student_id, presence: true
validate :recorder, presence: true
# TODO -- Create a way to warn the admin user a date is missing and defau... |
class AddStemsToTracks < ActiveRecord::Migration
def change
add_column :tracks, :stems, :string
end
end
|
class Api::CustomersController < ApplicationController
def orders
@customer = Customer.find(params[:id])
@order_details = @customer.detailed_orders.as_json if @customer
end
end
|
require 'aws-sdk'
AWS.config(:ssl_verify_peer => false)
module RedmineS3
class Connection
@@conn = nil
@@s3_options = {
:access_key_id => nil,
:secret_access_key => nil,
:bucket => nil,
:folder => '',
:endpoint => nil,
:private ... |
require 'spec_helper'
describe BasicObject do
describe '#mgrep' do
subject { [].mgrep(method_name) }
context 'method name is regexp' do
let(:method_name) { /size/ }
it { is_expected.to eq %i(size) }
end
context 'method name is string' do
let(:method_name) { 'size' }
it { i... |
class AppzipsController < ApplicationController
before_action :set_appzip, only: [:show, :edit, :update, :destroy, :serve]
before_action :authenticate_user!, except: [:serve, :bazaar, :listapps]
# GET /appzips
# GET /appzips.json
def index
@appzips = Appzip.all
end
# GET /appzips/1
# GET /appzip... |
# app/lib/ebay_service.rb
require 'net/http'
require 'nokogiri'
require 'open-uri'
class EbayService
APP_ID = ENV['EBAY_APP_ID']
LEGO_EBAY_CATEGORY_SEARCH_URL = "https://www.ebay.com/sch/19006/i.html?"
LEGO_COMPLETE_SET_CATEGORY_ID = 19006
USED_CONDITION_ID = 3000
NEW_CONDITION_ID = 1000
def self.c_to_f s... |
require 'test_helper'
describe Book do
let(:book) { books(:POODR) }
it "Books require a title" do
book.title = nil
book.valid?.must_equal false
book.errors.messages.must_include :title
end
it "If a title is given the book is valid" do
book.title = "The Wizard of Oz"
book.valid?
book... |
require_relative '../test_helper'
class ProjectMediaTrashWorkerTest < ActiveSupport::TestCase
def setup
super
require 'sidekiq/testing'
Sidekiq::Testing.inline!
end
test "should destroy trashed items" do
pm = create_project_media
id = pm.id
pm.archived = CheckArchivedFlags::FlagCodes::TR... |
require 'kachikachi/patch_body'
module Kachikachi
class Patch
attr_accessor :file_name, :body
def initialize(file_name, content, options)
@file_name = file_name || ''
@body = PatchBody.new(content, options)
end
end
end
|
require 'test_helper'
class PerformanceTest < RelixTest
def test_multi_index
m = Class.new do
include Relix
relix do
primary_key :key
multi :thing
end
attr_reader :key, :thing
def initialize(key, thing); @key, @thing = key, thing; index!; end
end
10.times do... |
require 'active_support/concern'
require 'mongoid/tree'
module Circuit
module Storage
module Nodes
# Concrete nodes store for Mongoid
class MongoidStore < BaseStore
# @param [Sites::Model] site to find path under
# @param [String] path to find
# @return [Array<Model>] array of... |
class AddShipmentInformationToUser < ActiveRecord::Migration[5.0]
def change
add_reference :users, :shipment_information, foreign_key: true
end
end
|
# encoding: UTF-8
class UsersMailer < ActionMailer::Base
default :from => '"The Village" <noreply@the-village.ru>'
def user_created(user)
@user = user
mail( :to => user.email,
:subject => 'Создание екаунта!')
end
end
|
class Cart
def initialize
@goods = []
end
def add(product)
product.amount -= 1
@goods << product
end
def empty?
@goods.empty?
end
def price_total
@goods.sum(&:price)
end
def to_s
@goods.uniq.sort_by(&:type).map do |product|
"#{product} x #{amount... |
class ApplicationController < ActionController::Base
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
private
def record_not_found
render file: Rails.root.join('public/404.html'), status: 404, layout: false, content_type: 'text/html'
end
end
|
class Customer < ActiveRecord::Base
has_many :sites
accepts_nested_attributes_for :sites, :allow_destroy => :true
has_many :circuits, through: :sites
accepts_nested_attributes_for :circuits, :allow_destroy => :true
has_many :users
end
|
class Dog
attr_reader :name,
:age,
:breed
def initialize(name, age, breed)
@name = name
@age = age
@breed = breed
end
end
|
class MarketCoinStream < ActiveRecord::Base
# dates
validates :last_broadcast_at, presence: false
# trackings
belongs_to :market_coin
validates :market_coin, presence: true
# users present
has_and_belongs_to_many :users
scope :with_users, -> do
self.joins(:users)
end
scope :broadcastable, -... |
require File.join(File.dirname(__FILE__), '..', "spec_helper")
require "rspec/matchers/dm/has_many"
describe DataMapperMatchers::HasMany do
it "should pass for for working association" do
Post.should has_many :comments
end
it "should fail if we expect existing relationships to not exist" do
lambda... |
require 'sinatra'
require 'sinatra/reloader'
require 'sqlite3'
require 'pry'
configure do
#make a new connection to our database and store it in the variable db
set :db, SQLite3::Database.new("database.db")
#make my sql query results easier to user
settings.db.results_as_hash = true
end
get "/" do
@results... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.