This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.configure do |config| | |
config.around(:all, callbacks: true) do |example| | |
ActiveRecord::Base.skip_callbacks = false | |
example.run | |
ActiveRecord::Base.skip_callbacks = true | |
end | |
end | |
ActiveRecord::Base.skip_callbacks = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/base.rb | |
module Base | |
def some_method | |
ImpClass.test | |
end | |
end | |
# app/models/impl_class | |
class ImlClass | |
include Base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> c = [1,2,[1,2]] | |
1,2,1,2 | |
>>> c.sort() | |
1,1,2,2 | |
>>> c.join('--') | |
1--1,2--2 | |
>>> c.length | |
3 | |
>>> c[0] | |
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Company < AR | |
has_many :users | |
has_many :discounts | |
end | |
class User < AR | |
belongs_to :company | |
has_many :discounts | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def raise_not_implemented | |
raise NotImplementedError.new("Define ##{caller_locations(1,1)[0].label} for #{self.class}") | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class << true | |
def !@ | |
true | |
end | |
end | |
class << false | |
def !@ | |
false | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Publisher | |
extend self | |
# delegate to ActiveSupport::Notifications.instrument | |
def broadcast_event(event_name, payload={}) | |
if block_given? | |
ActiveSupport::Notifications.instrument(event_name, payload) do | |
yield | |
end | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateUserForm | |
include ActiveModel::Model | |
attr_accessor :email | |
attr_accessor :name | |
def initialize | |
@user = User.new | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'delegate' | |
require 'benchmark' | |
class User | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
smartctl 6.3 2014-07-26 r3976 [x86_64-linux-4.0.0-0.rc3.git2.1.fc23.x86_64] (local build) | |
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org | |
=== START OF INFORMATION SECTION === | |
Device Model: Samsung SSD 850 PRO 256GB | |
Serial Number: S1SUNSAFA06649M | |
LU WWN Device Id: 5 002538 8a0713409 | |
Firmware Version: EXM01B6Q | |
User Capacity: 256,060,514,304 bytes [256 GB] | |
Sector Size: 512 bytes logical/physical |