I hereby claim:
- I am lovehandle on github.
- I am lovehandle (https://keybase.io/lovehandle) on keybase.
- I have a public key ASByKmKGk_jDO3RfdYlvcXPvUF9r4XD_OZ7hZV6CrHdOCQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
def foo1 | |
print bar | |
end | |
def foo2 | |
print bar | |
bar = "baz" | |
end | |
def foo3 |
require "benchmark" | |
class KlassMethod | |
def self.call | |
f | |
end | |
private_class_method def self.f | |
Random.rand | |
end |
class Geo::Shape | |
def to_geojson | |
RGeo::GeoJSON.encode(geom) | |
end | |
end |
An Example DSL for building rules:
RuleBuilder.build do |rule|
rule.clearance = Clearance.first
rule.define do
all do
condition { land_use_code == 'NAB' }
any do
condition { zone_code.in ['C-2','C-3'] }
class Parcel < ActiveRecord::Base | |
after_initialize :initialize_delegate | |
before_save :set_data_from_delegate | |
def data | |
delegate.to_hash | |
end | |
def data=(data) |
class Foo | |
end | |
f = Foo.new | |
mod = Module.new | |
mod.module_eval do | |
define_method('bar') { puts 'bar' } | |
private :bar |
class Foo < Module | |
def initialize(bar) | |
@bar = bar | |
define_bar_method! | |
end | |
private | |
def define_bar_method! | |
define_method("#{@bar}") { puts 'bar!' } |
# VIEW | |
div | |
= record_link(record) | |
# HELPER | |
module RecordHelper | |
def record_link(record) | |
link_to(record.something_link) | |
end |