Project

let

0.0
No commit activity in last 3 years
No release in over 3 years
Same as RSpec's let
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
~> 1.5.1
>= 0
~> 2.1.0
 Project Readme

Let

Memoized methods for objects, like rspec's let.

class Foo
  include Let
  let(:field1) { rand }
end

foo = Foo.new
foo.field1 # =>
foo.instance_variable_get("@field1") == foo.field1

Rails

Let is automatically included into ActiveRecord and ActionController

So for example, if you are using AuthLogic, and you have a method in your ApplicationController that looks like this:

def current_user_session
  return @current_user_session if defined?(@current_user_session)
  @current_user_session = UserSession.find
end

You can rewrite that as:

let(:current_user_session) { UserSession.find }

Copyright

Copyright (c) 2010 Howard Yeh. See LICENSE.txt for further details.