Module: Cda::StrictAttributes
- Included in:
- Base
- Defined in:
- lib/cda/strict_attributes.rb
Instance Method Summary collapse
- #check_attributes_allowed(attributes) ⇒ Object
-
#initialize(attributes = nil) ⇒ Object
noinspection RubySuperCallWithoutSuperclassInspection.
Instance Method Details
#check_attributes_allowed(attributes) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/cda/strict_attributes.rb', line 9 def check_attributes_allowed(attributes) wrong_attributes = attributes.keys.reject { |attr| allowed_writer_methods.include?("#{attr}=") } unless wrong_attributes.empty? raise ArgumentError, "You have invalid attributes in initialization hash (for #{self.class.name}): #{wrong_attributes.join(', ')}" end end |
#initialize(attributes = nil) ⇒ Object
noinspection RubySuperCallWithoutSuperclassInspection
4 5 6 7 |
# File 'lib/cda/strict_attributes.rb', line 4 def initialize(attributes = nil) check_attributes_allowed(attributes) if !attributes.nil? && attributes.is_a?(Hash) super end |