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
<?php | |
/** | |
* Table Definition for admintype | |
*/ | |
class InvalidMatrixException extends Exception | |
{ | |
} |
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 EventCanvas::Base | |
class << self | |
attr_reader :matrix | |
def context *context_classes | |
@context_classes = context_classes | |
end | |
def subscribers *subscribers_classes | |
@context_classes.each do |kls| |
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 ReviewsController < ApplicationController | |
def edit | |
@review = Reviews::Submitter.new(params).model | |
end | |
def update | |
submitter = Reviews::Submitter.new(params) | |
@review = submitter.model | |
submitter.on(:success) { |review| redirect_to success_reviews_path } |
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
# #+TITLE: Macros and Modules | |
# #+SETUPFILE: ../defaults.org | |
# Our client, the colonial fleet command, has asked us for a Ruby | |
# library to help them use the Observer pattern in tactical | |
# software. Here's how they'd like it to work: given a class =Dradis= | |
# which includes the module =Eventful=, they'd like to be able to | |
# declare an =#event= named =:new_contact=. They should then be able to | |
# instantiate an instance of the =Dradis= class and add listener objects |
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
#!/usr/bin/env ruby | |
# vim: set syntax=ruby | |
flag = false | |
Dir.glob("spec/**/*_spec.rb") do |file| | |
results = `cat #{file} | grep -E "(\:focused => true)|(focused\: true)"`.split("\n").map { |r| r.sub(/^\+[\s\t]*/, '') } | |
if $? == 0 | |
puts file |
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 HashMemoize | |
def memoized_value key | |
@memo_hash ||= Hash.new { |hsh, new_key| hsh[new_key] = some_heavy_computation new_key } | |
@memo_hash[key] | |
end | |
private | |
def some_heavy_computation key | |
puts "heavy duty for #{key} !" | |
key * 2 |
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
Feature: interfaces in Ruby | |
As a developer that wants to use interfaces in Ruby, | |
I want a DSL that emulates the following features: | |
* interfaces are constantized | |
* you cannot inherit from an interface | |
* you cannot instanciate an interface | |
* classes that implement interfaces MUST implement the methods defined in the interface | |
* instances of classes that implement interfaces are of the kind of the interface names. | |
Background: |
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
1.8.7 :001 > string = "Bacon, lettuce and tomato" | |
=> "Bacon, lettuce and tomato" | |
1.8.7 :002 > string[1] | |
=> 97 | |
******************************************************************** | |
2.0.0p0 :001 > string = "Bacon, lettuce and tomato" | |
=> "Bacon, lettuce and tomato" |
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
<?php | |
class ActionListTest extends PHPUnit_Framework_TestCase | |
{ | |
public function setup() | |
{ | |
$this->subject = $this->getMock('MOfficeActionLister',array('allActions')); | |
$this->subject->expects($this->any()) | |
->method('allActions') |
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
= simple_form_for resource, as: resource_name, url: registration_path(resource_name), html: { class: 'form-horizontal'} do |f| | |
%fieldset | |
= f.input :email | |
= f.input :password, label: t('users.choose_password') | |
= f.input :password_confirmation | |
= f.input :terms_of_service, as: :boolean, wrapper: :fullwidth_checkbox | |
.form-actions | |
= f.button :submit, t("devise.shared.sign_up"), class: 'btn btn-primary btn-large' |
NewerOlder