module QuickbaseRecord::Model
Public Class Methods
new(attributes={})
click to toggle source
Calls superclass method
# File lib/quickbase_record/model.rb, line 28 def initialize(attributes={}) create_attr_accesssors assign_attributes(attributes) if attributes super() end
Public Instance Methods
_assign_attribute(k, v)
click to toggle source
# File lib/quickbase_record/model.rb, line 61 def _assign_attribute(k, v) if respond_to?("#{k}=") public_send("#{k}=", v) end end
_assign_attributes(attributes)
click to toggle source
# File lib/quickbase_record/model.rb, line 55 def _assign_attributes(attributes) attributes.each do |k, v| _assign_attribute(k, v) end end
assign_attributes(new_attributes)
click to toggle source
# File lib/quickbase_record/model.rb, line 45 def assign_attributes(new_attributes) if !new_attributes.respond_to?(:stringify_keys) raise ArgumentError, "When assigning attributes, you must pass a hash as an argument." end return if new_attributes.blank? attributes = new_attributes.stringify_keys _assign_attributes(attributes) end
create_attr_accesssors()
click to toggle source
# File lib/quickbase_record/model.rb, line 39 def create_attr_accesssors self.class.fields.each do |field_name, field| self.class.send(:attr_accessor, field_name) end end
persisted?()
click to toggle source
# File lib/quickbase_record/model.rb, line 35 def persisted? false end