Module: Winch::Base::ClassMethods

Defined in:
lib/winch/base.rb

Instance Method Summary collapse

Instance Method Details

#must_have(name, options = {}) ⇒ Object



3
4
5
6
7
8
# File 'lib/winch/base.rb', line 3

def must_have(name, options={})
  #Either :default, or :faux can be anything including false and '', just not nil
  raise "%s can have either a default or a faux value, but not both." % name unless options.values_at(:default, :faux).select { |v| !v.nil? }.length == 1

  self.must_haves = (self.must_haves || {}).merge(name => options.merge(:name => name))
end