Module: ParamsReady::Parameter::DelegatingParameter

Includes:
ComplexParameter, FromHash
Defined in:
lib/params_ready/parameter/parameter.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FromHash

#set_from_hash

Methods included from ComplexParameter

#update_child

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/params_ready/parameter/parameter.rb', line 42

def method_missing(name, *args)
  if @data.respond_to?(name)
    @data.send name, *args
  else
    super
  end
end

Class Method Details

.included(recipient) ⇒ Object



38
39
40
# File 'lib/params_ready/parameter/parameter.rb', line 38

def self.included(recipient)
  recipient.freeze_variable :data
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



70
71
72
73
# File 'lib/params_ready/parameter/parameter.rb', line 70

def ==(other)
  return false unless self.match?(other)
  data == other.data
end

#hashObject



66
67
68
# File 'lib/params_ready/parameter/parameter.rb', line 66

def hash
  [definition, data].hash
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
53
54
55
56
# File 'lib/params_ready/parameter/parameter.rb', line 50

def respond_to_missing?(name, include_private = false)
  if @data.respond_to?(name, include_private)
    true
  else
    super
  end
end

#set_value(input, context = Format.instance(:backend), validator = nil) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/params_ready/parameter/parameter.rb', line 58

def set_value(input, context = Format.instance(:backend), validator = nil)
  if self.match?(input)
    super input.unwrap, context, validator
  else
    super
  end
end