File: hash_builder.rb

package info (click to toggle)
ruby-ice-cube 0.16.4-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 800 kB
  • sloc: ruby: 7,823; makefile: 6
file content (27 lines) | stat: -rw-r--r-- 378 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module IceCube

  class HashBuilder

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

    def validations
      @hash[:validations]
    end

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

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

    def to_hash
      @hash
    end

  end

end