class Ansr::Base

Public Class Methods

method() click to toggle source
# File lib/ansr/base.rb, line 14
def self.method
  @method ||= :get
end
method=(method) click to toggle source
# File lib/ansr/base.rb, line 18
def self.method=(method)
  @method = method
end
new(doc={}) click to toggle source
Calls superclass method
# File lib/ansr/base.rb, line 22
def initialize doc={}, options={}
  super(filter_source_hash(doc), options)
  @source_doc = doc
end

Public Instance Methods

[](key) click to toggle source
# File lib/ansr/base.rb, line 60
def [](key)
  @source_doc[key]
end
columns(name=self.name) click to toggle source
Calls superclass method
# File lib/ansr/base.rb, line 56
def columns(name=self.name)
  super(name)
end
core_initialize(attributes = nil, options = {}) { |self| ... } click to toggle source
# File lib/ansr/base.rb, line 27
def core_initialize(attributes = nil, options = {})
  defaults = self.class.column_defaults.dup
  defaults.each { |k, v| defaults[k] = v.dup if v.duplicable? }

  @attributes   = self.class.initialize_attributes(defaults)
  @column_types_override = nil
  @column_types = self.class.column_types

  init_internals
  init_changed_attributes
  ensure_proper_type
  populate_with_current_scope_attributes

  # +options+ argument is only needed to make protected_attributes gem easier to hook.
  # Remove it when we drop support to this gem.
  init_attributes(attributes, options) if attributes

  yield self if block_given?
  run_callbacks :initialize unless _initialize_callbacks.empty?
end
filter_source_hash(doc) click to toggle source
# File lib/ansr/base.rb, line 48
def filter_source_hash(doc)
  fields = self.class.model().table().fields()
  filtered = doc.select do |k,v|
    fields.include? k.to_sym 
  end
  filtered.with_indifferent_access
end