Class: Veto::Conditions

Inherits:
Object
  • Object
show all
Defined in:
lib/veto/conditions.rb

Constant Summary collapse

CONDITION_KEYS =
[:if, :unless].freeze

Class Method Summary collapse

Class Method Details

.merge(dest_hash, source_hash) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/veto/conditions.rb', line 13

def self.merge dest_hash, source_hash
	CONDITION_KEYS.inject({}) do |m, k|
		c = []
		c << dest_hash[k]
		c << source_hash[k]
		m[k] = c.flatten.compact
		m
	end
end

.reject(hash = {}) ⇒ Object



5
6
7
# File 'lib/veto/conditions.rb', line 5

def self.reject hash={}
	hash.reject{|k,v| CONDITION_KEYS.include?(k) }
end

.select(hash = {}) ⇒ Object



9
10
11
# File 'lib/veto/conditions.rb', line 9

def self.select hash={}
	hash.select{|k,v| CONDITION_KEYS.include?(k) }
end