class LSVplus::BaseContainer

Public Class Methods

new(attributes) click to toggle source
# File lib/lsv_plus/base_container.rb, line 25
def initialize(attributes)
  validate attributes
  set_attributes attributes
end

Public Instance Methods

set_attributes(attributes) click to toggle source
# File lib/lsv_plus/base_container.rb, line 34
def set_attributes(attributes)
  attributes.each do |key, value|
    raise UnknownAttribute, key unless self.class::ATTRIBUTES.include?(key)
    instance_variable_set("@#{key}", value)
  end
end
validate(attributes) click to toggle source
# File lib/lsv_plus/base_container.rb, line 30
def validate(attributes)
  validate_presence_of_required_attributes(attributes)
end
validate_presence_of_required_attributes(attributes) click to toggle source
# File lib/lsv_plus/base_container.rb, line 41
def validate_presence_of_required_attributes(attributes)
  self.class::ATTRIBUTES.each do |attribute|
    raise MissingAttribute, attribute unless attributes.key?(attribute)
  end
end