Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/pdf/core.rb,
lib/pdf/core.rb,
lib/pdf/core.rb
Instance Method Summary collapse
-
#assert_valid_keys(*valid_keys) ⇒ Object
raise an error if this hash has any keys that aren’t in the supplied list - borrowed from activesupport.
- #except(*keys) ⇒ Object
- #only(*keys) ⇒ Object
Instance Method Details
#assert_valid_keys(*valid_keys) ⇒ Object
raise an error if this hash has any keys that aren’t in the supplied list
-
borrowed from activesupport
8 9 10 11 |
# File 'lib/pdf/core.rb', line 8 def assert_valid_keys(*valid_keys) unknown_keys = keys - [valid_keys].flatten raise(ArgumentError, "Unknown key(s): #{unknown_keys.join(", ")}") unless unknown_keys.empty? end |
#except(*keys) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/pdf/core.rb', line 18 def except(*keys) keys.flatten! self.dup.reject { |k,v| keys.include? k.to_sym } end |
#only(*keys) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/pdf/core.rb', line 31 def only(*keys) keys.flatten! self.dup.reject { |k,v| !keys.include? k.to_sym } end |