Module: ParanoidDummy::ClassMethods

Defined in:
lib/paranoid_dummy/paranoid_dummy.rb

Instance Method Summary collapse

Instance Method Details

#define_paranoid_dummy(options = {}, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/paranoid_dummy/paranoid_dummy.rb', line 8

def define_paranoid_dummy options = {}, &block
  if not options.is_a?(Hash) and not options.empty?
    raise ArgumentError, "Hash expected, got #{options.class.name}"
  end

  if block_given?
    dummy.instance_eval &block

    if options[:for].present? and options[:for].is_a?(Array)
      create_paranoid_methods_from_options options[:for]
    else
      create_paranoid_methods_from_associations
    end
  end
end

#dummyObject



6
# File 'lib/paranoid_dummy/paranoid_dummy.rb', line 6

def dummy; @dummy ||= Dummy.new; end