text
stringlengths
10
2.61M
require 'benchmark' require_relative 'selection_sort.rb' require_relative 'insertion_sort.rb' require_relative 'bubble_sort.rb' require_relative 'merge_sort.rb' require_relative 'quick_sort.rb' require_relative 'heap_sort.rb' require_relative 'bucket_sort.rb' collection = Array.new(50) { rand(0..100) } Benchmark.bm(...
# frozen_string_literal: true unless ENV['CI'] require 'simplecov' require 'dotenv' SimpleCov.start Dotenv.load('.env') end require 'capybara' require 'capybara/dsl' require 'capybara/cucumber' require 'selenium-webdriver' $LOAD_PATH << './test_site' $LOAD_PATH << './lib' require 'site_prism' require 'test_...
# frozen_string_literal: true require 'net/http/request' RSpec.describe Api::V1::Constraints do let(:constraints) { described_class.new(version: 1, default: false) } let(:req) { double } it "doesn't match when non-default and missing headers" do expect(constraints).not_to be_matches(req) end it 'matc...
class ContentInformation < ApplicationRecord self.table_name = "files" validates_uniqueness_of :content_guid, scope: :content_type def self.get_not_uploaded_books_list path = ENV['HOST_URL'] + "/api/ops/content_request/" + "request_not_uploaded_books?key=" + ENV['TOKEN'] response = open(path,:read_timeou...
class ApplicationController < ActionController::Base protect_from_forgery def ensure_shelf_visible(shelf) visible = BookShelf.for(current_user).include? shelf not_found unless visible end def ensure_book_on_shelf(book, shelf) on_shelf = shelf.books.include? book not_found unless on_shelf end...
# frozen_string_literal: true # == Schema Information # # Table name: requirements # # id :bigint(8) not null, primary key # shift_id :bigint(8) # mandatory :integer # optional :integer # created_at :datetime not null # updated_at :datetime not null # event_id :bigint(8) # ...
class CommentsController < ApplicationController before_action :authenticate_user!, only: %i[new create edit update] def new set_commentable set_comment_full_path @comment = @commentable.comments.new end def create set_commentable set_comment_full_path @comment = @commentable.comments....
class Api::V1::PhotosController < ApplicationController protect_from_forgery unless: -> { request.format.json? } def index render json: Photo.all end def show render json: Photo.find(params[:id]) end def create photo = Photo.new(post_id: Post.last.id, photo_url: params[:photo_url]) if phot...
require 'shellwords' module RuboCop module Git # ref. https://github.com/thoughtbot/hound/blob/d2f3933/app/services/build_runner.rb class Runner def run(options) options = Options.new(options) unless options.is_a?(Options) @options = options @files = DiffParser.parse(git_diff(o...
# frozen_string_literal: true ActiveSupport.on_load(:active_record) do module ActiveRecord class Base def self.rails_admin(&block) RailsAdmin.config(self, &block) end def rails_admin_default_object_label_method new_record? ? "new #{self.class}" : "#{self.class} ##{id}" en...
# frozen_string_literal: true Sequel.migration do change do alter_table(:dynflow_delayed_plans) do long_text_type = @db.database_type == :mysql ? :mediumtext : String add_column :serialized_args, long_text_type end end end
require "base.rb" require "help.rb" require "lod.rb" require "ramrun.rb" require "scanf" require "benchmark.rb" module FastPf NOBOOTSECTORFASTPF = 0 BOOTSECTORFASTPF = 1 FULLFASTPF = 2 USE_FLASHPROG_FPCBUFFERSIZE = 1 begin @@C = CH__flash_programmer_globals ...
class User attr_writer :name end class Something attr_accessor :person end class Person < Something attr_accessor :name def initialize(n) @name = n person = User.new end def change_name(n) person.name = n end end bob = Person.new("Bob") bob.change_name("Robert") puts bob.name
class AddIsDeletedToItemOptionAddon < ActiveRecord::Migration def self.up ItemOptionAddon.reset_column_information unless ItemOptionAddon.column_names.include?('is_deleted') add_column :item_option_addons, :is_deleted, :integer, :default => 0 end end def self.down ItemOptionAddon.reset_colu...
class ChangePaidAndReceiptFromOrder < ActiveRecord::Migration def up rename_column :orders, :paid, :is_paid rename_column :orders, :receipt, :receipt_no remove_column :orders, :price end def down end end
require "set" require "ruby_parser" require "sexp_processor" module Deathnote class MethodProcessor < MethodBasedSexpProcessor attr_reader :known def initialize super @known = {} end def run(file_paths) file_paths.each do |file_path| exp = \ begin fi...
# == Schema Information # # Table name: appearances # # id :integer not null, primary key # title :string # description :text # header_logo :string # logo :string # created_at :datetime not null # updated_at :datetime not null # class Appearance < ActiveRecord::B...
require 'rails_helper' RSpec.describe TestMailer, type: :mailer do describe 'notify' do let(:mail) { PurchaseMailer.notify } it 'renders the headers' do expect(mail.subject).to eq('テストメール') expect(mail.to).to eq(['example@example.com']) end end end
# frozen_string_literal: true Dado 'o portfólio possui um bloco de Empresas para esconder perfil' do create(:block, kind: :hide_companies, side: :right, portfolio_id: @portfolio.id) end Quando 'adiciona uma nova Empresa para esconder portfólio' do @hide_company = attributes_for(:hide_company) fill_in 'hide-comp...
require 'spec_helper' describe PatientsController do describe "GET #show" do before :each do @patient = FactoryGirl.create(:patient, :id => 2) get :show, {:id => 2}, {} end it "renders the show template" do should render_template('show') end it "should have Patient with same id of params"...
require_relative "card" class EmptyDeckError < StandardError end class Deck attr_reader :cards def self.new_deck cards = [] Card::SUITS.each do |suit| Card::VALUES.keys.each do |value| cards << Card.new(suit, value) end end Deck.new(cards) end def initialize(cards) @...
module Abroaders::Controller module Onboarding extend ActiveSupport::Concern def redirect_if_not_onboarded! return if current_account.onboarded? redirect_to onboarding_survey_path true end def onboarding_survey_path case current_account.onboarding_state when "home_airpo...
class Comment < ApplicationRecord belongs_to :user belongs_to :dish scope :lastest, ->{order updated_at: :desc} validates :content, presence: true, length: {maximum: Settings.max_comment} end
class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception before_action :ensure_login helper_method :logged_in?, :current_user rescue_from ActionController::RoutingError, ...
=begin Description : Calculate my age(28) in seconds Assumption : Calcualtion does not factor in leap years in calulation =end #constants SECONDS_IN_HOUR = 3600 HOURS_IN_DAY = 24 #variables days_in_year = 365 seconds_in_year = SECONDS_IN_HOUR * HOURS_IN_DAY * days_in_year my_age = 28 second_in_my_age = my_age * seco...
module Backseat module Wrappers class ElementWrapper < AbstractWrapper def attribute(name) @element.getAttribute(name.to_s) end def_chainable_delegator :@element, :clear def_chainable_delegator :@element, :click def_chainable_delegator :@element, :submit def_c...
# frozen_string_literal: true # rubocop:todo all require 'spec_helper' describe Mongo::Server::Description::Features do let(:features) do described_class.new(wire_versions, default_address) end describe '#initialize' do context 'when the server wire version range is the same' do let(:wire_vers...
# -*- coding: utf-8 -*- module Mushikago # Hotaruへのアクセスを行うモジュール module Hotaru autoload :Client, 'mushikago/hotaru/client' # domain autoload :DomainCreateRequest, 'mushikago/hotaru/domain_create_request' autoload :DomainInfoRequest, 'mushikago/hotaru/domain_info_request' autoload :DomainListRequ...
class AddCcToToReplyAction < ActiveRecord::Migration def change add_column :reply_actions, :cc_to, :text, :default => nil end end
require 'spec_helper' require_relative '../../lib/right_branch/commands/change_pull_request_target' describe RightBranch::Commands::ChangePullRequestTarget do subject { described_class.new(StringIO.new) } describe '#run!' do let(:updater) { double } before do allow(subject).to receive(:build_option...
class BloggersController < ApplicationController def new @blogger = Blogger.new end def create @blogger = Blogger.create(blogger_params) if @blogger.valid? redirect_to blogger_path(@blogger) else render :new end end def show @blogger = Blogger.find(params[:id]) end...
require 'rails_helper' RSpec.describe Game do let(:x_player) {Player.create(:email => "test")} let(:game) {GamesService.create_game(x_player.id)} describe "#new_game?" do context "game with no moves" do it "returns true" do expect(game.new_game?).to be true end end context "gam...
require 'csv' module GhBbAudit class UsersList def initialize(path_to_csv_file) @user_csv_file_path = path_to_csv_file end def all_users #Not rescuing here, as we should crash if we can not get userlist @users ||= ::CSV.read(@user_csv_file_path).flatten.uniq end end end
json.array!(@bill_orders) do |bill_order| json.extract! bill_order, :id, :folio, :issued, :status json.url bill_order_url(bill_order, format: :json) end
module ApplicationHelper def badge_image_for(user) unless user.badges.empty? image_tag "#{user.badges.last.name}_red.svg" end end def badge_title_for(user) unless user.badges.empty? "#{user.badges.last.name.split('_').join(" ").titleize}" end end def student_progress_percentage(u...
CheckUp::Application.routes.draw do devise_for :users get '/routines/get_event', to: 'events#show', as: 'event_show' post '/routines/tag_event', to: 'tags#tag_event', as: 'tag_event' patch '/setup/tag', to: 'tags#update', as: 'update_tag' post '/setup/tag', to: 'tags#create', ...
require File.dirname(__FILE__) + '/../../spec_helper' describe Admin::EventsController do dataset :users integrate_views before(:each) do login_as :existing end def mock_event mock_model(Event, { :name => "Happy Fun Time", :scheduled_at => Time.now }) end context 'index' do ...
class ProPublicaService def initialize @conn = Faraday.new(url: "https://api.propublica.org") do |faraday| faraday.headers["X-API-KEY"] = ENV["propublica_key"] faraday.adapter Faraday.default_adapter end end def filter_by_state(state) response = get_response(state) pars...
require 'jsonapi/formatter' module JSONAPI class Configuration attr_reader :json_key_format, :link_format, :key_formatter, :link_formatter def initialize # :underscored, :camelized, :dasherized, or custom self.json_key_format = :dasherized #...
class Api::V2::LecturesController < ApplicationController before_action :set_lecture, only: [:show, :edit, :update, :destroy] @LECTURE_UPDATE_TIME = "com.planningdev.kyutech.update" def allLectures @campus_id = params[:campus_id] @server_time = params[:server_time] if @campus_id == nil @lecture...
require 'spec_helper' describe 'assignments/edit' do it "contains a form" do stub_template 'assignments/_form' => "<form></form>" render expect(page).to have_selector 'form' end end
module ReportsKit module Reports module Data class PopulateTwoDimensions attr_accessor :serieses, :dimension, :second_dimension, :sparse_serieses_dimension_keys_values def initialize(sparse_serieses_dimension_keys_values) self.serieses = sparse_serieses_dimension_keys_values.keys ...
class Incollection < ActiveRecord::Base has_many :publications, through: :publication_incollections validates :author, :title, :booktitle, :publisher, :year, presence: true def required_fields %w(author title publisher year booktitle) end def self.required_fields %w(author title publisher year book...
unless File.exist?('./Gemfile') raise <<-MESSAGE Could not find a Gemfile. Please run any of: thor rails:use 3-0-stable thor rails:use master thor rails:use VERSION (where VERSION is any released version) MESSAGE end require "bundler" Bundler.setup #Bundler::GemHelper.install_tasks require 'rake' require 'yaml...
module MTMD module FamilyCookBook class MenuItem < Sequel::Model(:menu_items) SLOTS = %w'empty MTMD::FamilyCookBook::Slot::Breakfast MTMD::FamilyCookBook::Slot::Lunch MTMD::FamilyCookBook::Slot::Dinner' plugin :timestamps, :update_on_create => true many_to_many :menus, :clas...
require_relative 'traac' require_relative 'raac' module Parameters TIME_STEPS = 500 RUNS = 10 # how many data owners to use and evaluate OWNER_COUNT = 200 # experimental condition (RAAC classes) MODELS = [Raac,TraacSTOnly,TraacSTOT] # settings for the data owners, data objects and policies # i...
module RestoreAgent::Handler class Agent require 'restore_agent/object/base' require 'restore_agent/object/root' require 'restore_agent/object/filesystem' require 'restore_agent/object/file' require 'restore_agent/object/directory' require 'restore_agent/object/mysql_server' require 'rest...
module LookerSDK # Authentication methods for {LookerSDK::Client} module Authentication attr_accessor :access_token_type, :access_token_expires_at # This is called automatically by 'request' def ensure_logged_in authenticate unless token_authenticated? || @skip_authenticate end def wit...
class Api::UsersController < ApplicationController before_action :ensure_authorization, only: [:update] def show @user = User.find(params[:id]) render 'api/users/show' end def create @user = User.new(user_params) demo_id = User.find_by(username: "Guest").id if @user.save Follow.crea...
# # Exodus::SeatTable # # 席の位置と苗字のデータを持ったテキストエントリをGtk::Tableに格納する $:.unshift File.dirname(__FILE__) require 'rubygems' require 'gtk2' require './lib/new_seat_generator' require './gui/exit_button' module Exodus class SeatTable def initialize(width, height, target_name) @width = width @height = height @ta...
WIN_COMBINATIONS = [ [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6], ] def move(board, index, current_player) board[index] = current_player end def valid_move?(board, index) index.between?(0, 8) && !position_taken?(board, index) end def turn(board) puts "...
Rails.application.routes.draw do devise_for :users root to: 'pages#home' # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html resources :restaurants do resources :dishes, only: [ :index, :show] end resources :offers, only: [ :new, :create, :show ] res...
RSpec.feature 'Rich Editor Settings', :js do stub_authorization! context '#edit' do scenario 'have default elements' do visit spree.edit_admin_editor_settings_path within('legend') do expect(page).to have_text 'Rich Editor' end expect(page).to have_field 'ids', with: 'product_d...
module Call::Operation class Create < Trailblazer::Operation class Present < Trailblazer::Operation pass :populate_errors step :build_model step Contract::Build(constant: Call::Contract::Form) def populate_errors(ctx, **) ctx[:errors] = [] end def build_model(ctx, **)...
# encoding: utf-8 class RedactorRailsDocumentUploader < CarrierWave::Uploader::Base include RedactorRails::Backend::CarrierWave if Rails.env.test? || Rails.env.development? storage :file else storage :fog end def store_dir "#{Rails.env}/system/redactor_assets/documents/#{model.id}" end def ...
# Write a method that takes a positive integer as an argument and returns that # number with its digits reversed. def reversed_number(num) new_num = num.to_s.split('') result = [] loop do break if new_num.length.zero? result << new_num.pop end p result.join.to_i end p reversed_number(12345) == 5432...
class RemoveProviderColumnFromPlayers < ActiveRecord::Migration def change remove_column :players, :provider end end
class ChangeCompletedAtTodoItems < ActiveRecord::Migration def change #missing the 'l' needed to re migrate remove_column :todo_items, :competed_at, :datetime add_column :todo_items, :completed_at, :datetime end end
class Order def initialize(config, order_hash) @order_hash = order_hash @config = config end def address address_type = @config['twilio_address_type'] || "billing" @order_hash["#{address_type}_address"] end def customer_phone address['phone'] end def number @order_hash['numb...
module Api module V1 class AuthController < ApplicationController def create user = User.find_by( username: user_params[:username] ) if user.blank? render json: { error: 'Invalid username' }, status: :unauthorized elsif user.authenticate( user_params[:password] ) ...
require 'spec_helper' require 'immutable/vector' describe Immutable::Vector do let(:v) { V[1, 2, V[3, 4]] } describe '#dig' do it 'returns value at the index with one argument' do expect(v.dig(0)).to eq(1) end it 'returns value at index in nested arrays' do expect(v.dig(2, 0)).to eq(3) ...
module ApplicationHelper def isUserAdmin?(group_id) current_user == Group.find(group_id).admin.user end end
class CreateParticipants < ActiveRecord::Migration def change create_table :participants do |t| t.string :sex t.string :fname t.string :mname t.string :lname t.decimal :age t.string :occupation t.string :introducer t.string :guarantor t.string :address t...
module FeatureBox class Suggestion < ActiveRecord::Base attr_accessible :title, :description, :status belongs_to :user, :class_name=>"FeatureBox::User" belongs_to :category has_many :votes, :dependent => :destroy has_many :comments, :dependent => :destroy validates :title, :presenc...
class LookingForAJob < ActiveRecord::Migration def change create_table :candidates do |t| t.string :first_name t.string :last_name t.string :email t.text :about_me t.string :experience_level t.string :github_name t.string :twitter_name t.text :looking_for t.bo...
class EmailValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i record.errors[attribute] << (options[:message] || "is not an email") end end end class Member < ActiveRecord::Base validates :prename, presence...
# 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 rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Ch...
class Currency_Converter def initialize(conversion_rate = 1.0, country_code = :USD) @conversion_rate = conversion_rate @country_code = country_code end def conversion_rate @conversion_rate = conversion_rate end def country_code @country_code = country_code end def to_s "#{@country_...
class Api::V1::Transactions::InvoiceController < ApplicationController def index transaction = Transaction.find_by(id: params[:transaction_id]) invoice = Invoice.find_by(id: transaction.invoice_id) render json: InvoiceSerializer.new(invoice) end end
require 'rails_helper' RSpec.describe "phrases/show", type: :view do before(:each) do @phrase = assign(:phrase, Phrase.create!( :english_text => "English Text", :audio => "", :image => "" )) end it "renders attributes in <p>" do render expect(rendered).to match(/English Text/) ...
class Event < ActiveRecord::Base acts_as_commentable has_many :occurrences belongs_to :sponsor has_many :performances belongs_to :category, :class_name => 'Attribute' has_many :places , :through => :occurrences has_many :campaigns, :through => :promotions has_many :performers , :through => :performance...
class Printer # вывод версии игры def version(version) puts version puts end # Вывод приветствия def welcome(name) puts "#{name}," puts "Ответьте, пожалуйста, честно на 16 " \ "вопросов, чтобы узнать насколько вы общительный человек." puts end # вывод последовательно всех вопро...
# frozen_string_literal: true class CancelUnpaidReservationWorker include Sidekiq::Worker def perform Reservation.where(status: 'pending') .where('screening_time < ?', Time.current + 30.minutes) .joins(:screening) .update_all(status: 'cancelled') ReservationMa...
if defined?(ChefSpec) def create_consul_template(message) ChefSpec::Matchers::ResourceMatcher.new(:consul_template, :create, resource_name) end def remove_consul_template(message) ChefSpec::Matchers::ResourceMatcher.new(:consul_template, :create, resource_name) end def create_consul_template_config(...
class Account < ActiveRecord::Base validates :emailId , presence: true , length: {minimum: 5 ,maximum:100} validates :userName , presence:true , length: {minimum: 3, maximum:15} validates :password , presence:true , length: {minimum:6 , maximum: 20} end
namespace :parse do desc "Parsing of events based on Berlin events" task :other_event_creator => :environment do # Scraper for Categories Film, Theater and Concert available_categories = {movie: "film", theater: "theaterperformance", concert: "konzert"} available_categories.each do |cat| 3.times do |d| @event =...
FactoryBot.define do factory :patient_phone_number do id { SecureRandom.uuid } number { Faker::PhoneNumber.phone_number } phone_type { "mobile" } active { [true, false].sample } device_created_at { Time.current } device_updated_at { Time.current } dnd_status { true } patient end end ...
class MicropostsController < ApplicationController before_action :signed_in_user def create @micropost = curent_user.microposts.build(micropost_params) if @micropost.save flash[:succes] = "Micropost created!" redirect_to root_path else render 'static_pages/home' end end def destroy end pr...
# frozen_string_literal: true # == Schema Information # # Table name: room_users # # id :integer not null, primary key # user_id :integer not null # room_id :integer not null # last_read_message_id :integer # unread_message_count :integer ...
class HumanFactor < ActiveHash::Base self.data = [ { id: 1, name: '--' }, { id: 2, name: '気分(高揚/沈潜)' }, { id: 3, name: '欲得/(経済的/地位)' }, { id: 4, name: '自失(無判断/未知遭遇)' }, { id: 5, name: '思い入れが逆に働いた(生きがい/使命感)' }, { id: 6, name: '横着(手抜き/責任転嫁)' }, { id: 7, name: 'プライド(体裁/ええ格好)' }, { id: 8, ...
# # Cookbook Name:: gpg # Recipe:: default # require 'etc' chef_gem 'gpgme' require 'gpgme' package "gnupg" do action :nothing end.run_action(:upgrade) directory gpg_home do owner node['gpg']['user'] action :nothing end.run_action(:create) search(node[:gpg][:keys_data_bag]) do |key| ruby_block "Import and ...
class Award < ApplicationRecord belongs_to :rifa_id belongs_to :ticket_drawn end
namespace :lock do desc 'check lock' task :check do on roles(:db) do if test("[ -f #{lock_path} ]") require 'time' lock_mtime = Time.parse capture("stat --format '%z' #{lock_path}") time_now = Time.parse capture('date') time_diff = Time.at(time_now - lock_mtime).utc.strftim...
class Smartphone #属性の定義 #インスタンス変数を読み書きするためのアクセサメソッド attr_accessor :manufacture, :color, :storage #initializeメソッド…インスタンスが生成される時に自動的に呼び出されるメソッド # 必ず実行したい処理(初期化など)を、メソッドを呼び出すことなく実行できる def initialize(manufacture,color,storage) # インスタンス生成時に与えられた値(属性の内容)をインスタンス変数に保存 @manufacture = manufacture @color...
class CreateSubscriptions < ActiveRecord::Migration def change create_table :subscriptions do |t| t.references :partner, null: false t.references :noun, polymorphic: true, null: false t.timestamps end add_index :subscriptions, :partner_id add_index :subscriptions, [:noun_id, :noun_...
class UserMethod < ApplicationRecord validates :user_level, :controller_method_id, presence: true belongs_to :controller_method end
# == Schema Information # # Table name: user_submission_votes # # id :integer not null, primary key # user_id :integer # scholarship_submission_id :integer # created_at :datetime not null # updated_at :datetime not null # ...
require './app/doubles/calculator_display' require 'test/unit' require 'test/unit/notify' require 'mocha/test_unit' class CalculatorDisplaySpyTest < Test::Unit::TestCase def test_shows_default_separator() # Arrange resultToInject = 100 expectedOutput = "100.00" mockedCalculator = mock() mocked...
class Role < ActiveRecord::Base attr_accessible :name has_many :user_roles has_many :users, :through => :user_roles validates :name, :presence => true, :length => {:minimum => 5} end
class User < ApplicationRecord # devise :database_authenticatable, :registerable, # :recoverable, :rememberable, :validatable # Make omniauthable devise :omniauthable, :omniauth_providers => [:google_oauth2] def self.from_omniauth(auth) # Either create a User record or update it based on the provider (...
class CreateRequisitions < ActiveRecord::Migration def self.up create_table :requisitions do |t| t.string :req_no t.text :description t.integer :priority_id # req_priority fixed -> Operation, Emergency, Safety, Other t.integer :status_id # req_status fixed -> New, Open, Pre-Approved, Appro...
require 'rspec' require './enumerables' describe Enumerable do let(:ary) { %w[a b c] } let(:rng) { (1..5) } let(:block) { |item| print item, '--' } let(:sym_ary) { %i[foo bar sym] } let(:words) { %w[ant bear cat] } let(:numbers) { [1, 3.14, 42] } describe '#my_each' do let(:block) { proc { |item| pr...
class RemoveMedicationFromMedicationInteractions < ActiveRecord::Migration[5.1] def change remove_reference :medication_interactions, :medication end end
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base include AuthenticatedSystem before_filter :adjust_for_group before_filter :adjust_format_for_iphone befo...
class Instrument < ApplicationRecord has_many :albums has_many :artists, through: :albums end
require 'date' require 'active_support/core_ext/integer/inflections' # rspec should is deprecated # Formats date range class DateRangeFormatter def initialize(from, to, from_time = nil, to_time = nil) @from = Date.parse(from) @to = Date.parse(to) @from_time = from_time @to_time = to_time end de...
FactoryGirl.define do factory :exercise_task do title 'Test Exercise Task' description 'Test Description' instructions 'Test instructions' end end
class Encounter < ApplicationRecord include Mergeable extend SQLHelpers belongs_to :patient, optional: true belongs_to :facility has_many :observations has_many :blood_pressures, through: :observations, source: :observable, source_type: "BloodPressure" has_many :blood_sugars, through: :observations, sou...
class RemoveAfpIdfromWorkers < ActiveRecord::Migration def change remove_column :workers, :afp_id remove_column :workers, :afptype remove_column :workers, :afpnumber end end
class Site include Singleton attr_accessor :root_directory def initialize(root_directory) @root_directory = root_directory end def self.file_data(path) path = self.instance.resolve_path(path) self.instance.read_file(path) end def resolve_path(path) file_read_path = "#{@root_direct...