Class: IceCube::HashBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ice_cube/builders/hash_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(rule = nil) ⇒ HashBuilder

Returns a new instance of HashBuilder.



3
4
5
# File 'lib/ice_cube/builders/hash_builder.rb', line 3

def initialize(rule = nil)
  @hash = {validations: {}, rule_type: rule.class.name}
end

Instance Method Details

#[]=(key, value) ⇒ Object



11
12
13
# File 'lib/ice_cube/builders/hash_builder.rb', line 11

def []=(key, value)
  @hash[key] = value
end

#to_hashObject



19
20
21
# File 'lib/ice_cube/builders/hash_builder.rb', line 19

def to_hash
  @hash
end

#validationsObject



7
8
9
# File 'lib/ice_cube/builders/hash_builder.rb', line 7

def validations
  @hash[:validations]
end

#validations_array(type) ⇒ Object



15
16
17
# File 'lib/ice_cube/builders/hash_builder.rb', line 15

def validations_array(type)
  validations[type] ||= []
end