class RealPage::Model::Base

Base class for models, which are the return values from Requests

Attributes

attribute_store[RW]

Public Class Methods

new(attrs = {}) click to toggle source

Initialize a new model with the response hash from RealPage. Attribute values are parsed into their configured data types.

@param attrs [Hash<String, Object>] the response hash from RealPage.

Attribute keys are case insensitive.
# File lib/real_page/model/base.rb, line 51
def initialize(attrs = {})
  attrs.each do |attr, value|
    attribute = self.class.attribute_store.find(attr)
    next unless attribute
    parser = AttributeParser.new(value: value, type: attribute.type)
    instance_variable_set("@#{attribute.name}", parser.parse)
  end
end