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/booking.rb | |
class Booking < AR::Base | |
# ... | |
end | |
# app/models/booking/create.rb | |
class Booking::Create | |
def initialize(attributes) |
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 Workflow | |
extend ActiveSupport::Concern | |
included do | |
extend ActiveModel::Naming | |
include ActiveModel::Validations | |
end | |
def call | |
if valid? |
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
# Thanks to http://www.paulirish.com/2009/random-hex-color-code-snippets for the idea | |
module ColorSupport | |
# yields a random color | |
def self.random_color | |
color_for((rand() * ((0xFFFFFF + 1) << 0)).to_i.to_s(16)) | |
end | |
# yields a random color based on the given color | |
# credit: http://stackoverflow.com/a/43235 |
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
# | |
# | |
# Rails 4 concern for specifying default attribute values on models | |
# | |
# E.g. The following user has defaults defined for `active` and `manager` attributes | |
# | |
# class User < ActiveRecord::Base | |
# include Concerns::DefaultValues | |
# | |
# default_value :active, 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
require 'active_support/concern' | |
module NationBuilderApi | |
extend ActiveSupport::Concern | |
def token | |
self.class.token | |
end | |
def nationbuilder(to, data) |
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 SomeLib | |
module Utilities | |
module HttpRequest | |
#send get request to sensor | |
def send_get_request(url = nil) | |
send_data url | |
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 SshBase | |
attr_accessor :host, :username, :password, :timeout | |
class SSHException < Exception; end; | |
# Callbacks storage for Channel Execute Callbacks | |
class ChannelExecCallBacks | |
attr_accessor :on_success, :on_failure, :on_data, :on_extended_data, :on_close | |
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 Devices | |
module Common | |
class Reports < Devices::Common::Notifiers; end | |
class Warnings < Devices::Common::Notifiers; end | |
class Errors < Devices::Common::Notifiers; end | |
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
# event.rb | |
class Event < ActiveRecord::Base | |
belongs_to :eventable, polymorphic: true | |
end | |
# migration | |
class CreateEvents < ActiveRecord::Migration | |
def change |
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 JasmineFixtures | |
extend ActiveSupport::Concern | |
# Saves the markup to a fixture file using the given name | |
def save_fixture(name) | |
response.should be_success | |
fixture_path = File.join(Rails.root, '/spec/javascripts/fixtures') | |
fixture_file = File.join(fixture_path, name) | |
fixture = case name | |
when /\.html$/ |