This file contains hidden or 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 VersionStruct | |
| class << self | |
| def build_from(version, args = {}) | |
| object = deserialize(version.object) | |
| args[:changes] = deserialize(version.object_changes) | |
| args[:version] = version | |
| version_struct = new(object, args) | |
| version_struct.mimic | |
| end |
This file contains hidden or 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 NumberTest < ActiveSupport::TestCase | |
| def setup | |
| @number = 4 | |
| end | |
| def test_number_is_four | |
| assert_equal 4, @number | |
| end |
This file contains hidden or 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 WorkRequest < ActiveRecord::Base | |
| # Attributes include :state_history (text) and :state (string) | |
| serialize :state_history, Array | |
| after_find :restore_process | |
| after_initialize :restore_process | |
| def rollback_state_to_previous |
This file contains hidden or 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 ClassFinder | |
| attr_reader :pid | |
| def initialize(pid) | |
| @pid = pid | |
| end | |
| def object | |
| @object ||= self.class.source_objects.select{|x| x.pid =~ /#{pid}/}.first | |
| end |
This file contains hidden or 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
| APACHE_ROOT = 'path/to/apache' | |
| def apache(location) | |
| File.join APACHE_ROOT, location | |
| end | |
| def apachectl(command) | |
| "#{apache 'bin/apachectl'} -k #{command}" | |
| end |
This file contains hidden or 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 Parent | |
| def self.to_be_over_ridden | |
| raise "Class method `#{__method__}` must be defined in #{name}" | |
| end | |
| def to_be_over_ridden | |
| raise "Instance method `#{__method__}` must be defined in #{self.class.name}" | |
| end | |
| end |
This file contains hidden or 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 'active_support/concern' | |
| module UseUuid | |
| extend ActiveSupport::Concern | |
| included do | |
| before_save :generate_uuid | |
| end | |
| def to_param | |
| uuid |
This file contains hidden or 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
| # Resistence settings for cartidge loads | |
| settings = [1.1, 33.0, 100.0, 1000.0] | |
| # Combination of resistors switched in via panel under dino | |
| # Equation is: 1/Rtotal = 1/R1 + 1/R2 ... + 1/Rn | |
| (1..4).collect do |i| | |
| settings.combination(i).each do |combination| | |
| label = combination.inspect | |
| fractions = combination.collect{|c| 1/c} |
This file contains hidden or 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 ContentsOf | |
| def contents_of(file_path, location: Rails.root) | |
| File.read File.expand_path(file_path, location) | |
| end | |
| end |
This file contains hidden or 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 Address | |
| attr_accessor :address, :flat, :house_number, :house_name, :street, :street2, :street3, :town, :county | |
| def initialize(address) | |
| self.address = address | |
| end | |
| def parts | |
| @parts ||= address.split(/\s?\,\s?/).collect(&:strip) | |
| end |