Skip to content

Instantly share code, notes, and snippets.

View brianknapp's full-sized avatar

Brian Knapp brianknapp

View GitHub Profile
@brianknapp
brianknapp / sign_in_user.rb
Created February 5, 2013 18:38
This is a overly simplistic sign in user action that demonstrates roughly how a sign in might work in Obvious with users and user sessions
require_relative '../entities/user'
require_relative '../entities/user_session'
class SignInUser
def initialize user_jack, user_session_jack
@user_jack = user_jack
@user_session_jack = user_session_jack
end
@brianknapp
brianknapp / example_action.yml
Created December 24, 2012 02:11
Example Obvious Descriptor
Action: ExampleAction
Description: should do something awesome
Code:
- c: validate input
- c: set default id and values for new Thing entity
- c: create/populate Thing object
requires: Thing.populate
- c: save thing to jack
requires: ThingJack.save, Thing.to_hash
- c: return the result
@brianknapp
brianknapp / gist:4150482
Created November 26, 2012 20:40
Self contained knockout error bubble with close button
<div class="alert error" data-bind="css: { hidden: !errorMessage() }">
<span data-bind="text: errorMessage"></span>
<button class="close" data-bind="click: function(data, event){ errorMessage(null); } ">&times;</button>
</div>
@brianknapp
brianknapp / gist:3756197
Created September 20, 2012 14:14
clean tweet gateway contract tests
require_relative '../../contracts/tweet_gateway_contract'
class TG < TweetGatewayContract
def save input
return input
end
end
class TGoutput < TweetGatewayContract
def save input
@brianknapp
brianknapp / tweet contract thingy.rb
Created September 14, 2012 18:32
tweet pre-post condition contract
class Contract
@@disable_override = false
@@contracts = []
def self.method_added name
unless @@disable_override
@@contracts.each do |method|
if name == method.to_sym
method_alias = "#{method}_alias".to_sym