class FormStalker::Data::Base
Attributes
parser[R]
Public Class Methods
inherited(base)
click to toggle source
Calls superclass method
# File lib/form_stalker/data/base.rb, line 14 def self.inherited(base) base.type_cast_schema.merge! type_cast_schema.clone super end
new(attributes = nil)
click to toggle source
Calls superclass method
# File lib/form_stalker/data/base.rb, line 37 def initialize(attributes = nil) attributes ||= {} instance_variable_set('@table', attributes) @parser = Parser.new(self, self.class.type_cast_schema, attributes) super(@parser.parse_attributes) end
schema(options = nil)
click to toggle source
# File lib/form_stalker/data/base.rb, line 6 def self.schema(options = nil) type_cast_schema.merge! options end
tap_into(response)
click to toggle source
# File lib/form_stalker/data/base.rb, line 20 def self.tap_into(response) return response unless response.ok? response.data = if response.data.is_a?(Array) response.data.map { |subset| new(subset) } else new(response.data) end response end
type_cast_schema()
click to toggle source
# File lib/form_stalker/data/base.rb, line 10 def self.type_cast_schema @type_cast_schema ||= { id: :integer } end
Public Instance Methods
attributes_before_type_cast()
click to toggle source
# File lib/form_stalker/data/base.rb, line 47 def attributes_before_type_cast parser.attributes_before_type_cast end