Module: Origin::Optional

Defined in:
lib/patches/reorder.rb,
lib/patches/only_pluck_localized.rb

Instance Method Summary collapse

Instance Method Details

#only(*args) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/patches/only_pluck_localized.rb', line 38

def only(*args)
  args = args.flatten
  puts args.inspect
  option(*args) do |options|
    options.store(
        :fields,
        args.inject({}){ |sub, field| sub.tap { sub[field] = 1 }},
        false
    )
  end
end

#reorder(*spec) ⇒ Object



8
9
10
11
# File 'lib/patches/reorder.rb', line 8

def reorder(*spec)
  options.delete(:sort)
  order_by(*spec)
end

#without(*args) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/patches/only_pluck_localized.rb', line 50

def without(*args)
  args = args.flatten
  option(*args) do |options|
    options.store(
        :fields,
        args.inject({}){ |sub, field| sub.tap { sub[field] = 0 }},
        false
    )
  end
end