Module: Saki::GeneralHelpers::ClassMethods

Defined in:
lib/saki.rb

Instance Method Summary collapse

Instance Method Details

#where(executable, *opts, &block) ⇒ Object



125
126
127
128
129
130
# File 'lib/saki.rb', line 125

def where(executable, *opts, &block)
  context "anonymous closure" do
    before { instance_eval &executable }
    module_eval &block
  end
end

#with_existing(resource, opts = {}, &block) ⇒ Object



106
107
108
109
110
111
112
113
# File 'lib/saki.rb', line 106

def with_existing resource, opts={}, &block
  context "with exisiting #{resource}" do
    before do
      instance_variable_set "@#{resource}", default_factory(resource, opts)
    end
    module_eval &block
  end
end

#with_signed_in(resource, opts = {}, &block) ⇒ Object



115
116
117
118
119
120
121
122
123
# File 'lib/saki.rb', line 115

def with_signed_in resource, opts={}, &block
  context "with signed in #{resource}" do
    before do
      instance_variable_set "@#{resource}", default_factory(resource, opts)
      eval "sign_in @#{resource}"
    end
    module_eval &block
  end
end