Class: HashPoser

Inherits:
Proc
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rails_ext/active_record/merge_default_scope/hash_poser.rb

Overview

Hack to use dynamic default_scope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&b) ⇒ HashPoser

Returns a new instance of HashPoser.



7
8
9
10
# File 'lib/rails_ext/active_record/merge_default_scope/hash_poser.rb', line 7

def initialize &b
  @proc = b
  super &b
end

Instance Attribute Details

#procObject

Returns the value of attribute proc.



5
6
7
# File 'lib/rails_ext/active_record/merge_default_scope/hash_poser.rb', line 5

def proc
  @proc
end

Instance Method Details

#[](key) ⇒ Object



12
13
14
# File 'lib/rails_ext/active_record/merge_default_scope/hash_poser.rb', line 12

def [](key)
  call[key]
end

#each(*a, &b) ⇒ Object



16
17
18
# File 'lib/rails_ext/active_record/merge_default_scope/hash_poser.rb', line 16

def each(*a, &b)
  call.each(*a, &b)
end

#fetch(key) ⇒ Object



20
21
22
# File 'lib/rails_ext/active_record/merge_default_scope/hash_poser.rb', line 20

def fetch(key)
  call.fetch(key)
end

#keysObject



24
25
26
# File 'lib/rails_ext/active_record/merge_default_scope/hash_poser.rb', line 24

def keys
  call.keys
end

#merge(*a, &b) ⇒ Object



28
29
30
# File 'lib/rails_ext/active_record/merge_default_scope/hash_poser.rb', line 28

def merge(*a, &b)
  call.merge(*a, &b)
end

#to_hashObject



32
33
34
# File 'lib/rails_ext/active_record/merge_default_scope/hash_poser.rb', line 32

def to_hash
  call
end

#to_sObject Also known as: inspect



36
37
38
# File 'lib/rails_ext/active_record/merge_default_scope/hash_poser.rb', line 36

def to_s
  "#<HashPoser: #{call.inspect}>"
end