Exception: SmartProperties::InitializationError

Inherits:
Error
  • Object
show all
Defined in:
lib/smart_properties/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sender, properties) ⇒ InitializationError

Returns a new instance of InitializationError.



99
100
101
102
103
104
105
106
107
108
# File 'lib/smart_properties/errors.rb', line 99

def initialize(sender, properties)
  @sender = sender
  @properties = properties
  super(
    "%s requires the following properties to be set: %s" % [
      sender.class.name,
      properties.map(&:name).sort.join(', ')
    ]
  )
end

Instance Attribute Details

#propertiesObject

Returns the value of attribute properties.



97
98
99
# File 'lib/smart_properties/errors.rb', line 97

def properties
  @properties
end

#senderObject

Returns the value of attribute sender.



96
97
98
# File 'lib/smart_properties/errors.rb', line 96

def sender
  @sender
end

Instance Method Details

#to_hashObject



110
111
112
# File 'lib/smart_properties/errors.rb', line 110

def to_hash
  properties.each_with_object({}) { |property, errors| errors[property.name] = "must be set" }
end