Class: Hashmake::HashArgSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/hashmake/hash_arg_spec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hashed_args = {}) ⇒ HashArgSpec

Returns a new instance of HashArgSpec.



8
9
10
11
# File 'lib/hashmake/hash_arg_spec.rb', line 8

def initialize hashed_args = {}
  hashed_args = { :default => ->(){ {} } }.merge hashed_args
  @arg_spec = ArgSpec.new hashed_args
end

Instance Attribute Details

#arg_specObject (readonly)

Returns the value of attribute arg_spec.



6
7
8
# File 'lib/hashmake/hash_arg_spec.rb', line 6

def arg_spec
  @arg_spec
end

Instance Method Details

#defaultObject



25
26
27
# File 'lib/hashmake/hash_arg_spec.rb', line 25

def default
  @arg_spec.default
end

#hash_make_if_needed(val) ⇒ Object



29
30
31
32
33
34
# File 'lib/hashmake/hash_arg_spec.rb', line 29

def hash_make_if_needed val
  val.each_key do |item_key|
    item = val[item_key]
    val[item_key] = @arg_spec.hash_make_if_needed item
  end
end

#make_hash_if_possible(hash) ⇒ Object



42
43
44
45
46
# File 'lib/hashmake/hash_arg_spec.rb', line 42

def make_hash_if_possible hash
  hash.each_key do |key|
    hash[key] = @arg_spec.make_hash_if_possible hash[key]
  end
end

#reqdObject



21
22
23
# File 'lib/hashmake/hash_arg_spec.rb', line 21

def reqd
  @arg_spec.reqd
end

#typeObject



13
14
15
# File 'lib/hashmake/hash_arg_spec.rb', line 13

def type
  @arg_spec.type
end

#validate_value(val) ⇒ Object



36
37
38
39
40
# File 'lib/hashmake/hash_arg_spec.rb', line 36

def validate_value val
  val.each do |key, item|
    @arg_spec.validate_value item
  end
end

#validatorObject



17
18
19
# File 'lib/hashmake/hash_arg_spec.rb', line 17

def validator
  @arg_spec.validator
end