module Devtunnel::ApiModel
Public Class Methods
included(base)
click to toggle source
# File lib/devtunnel/api_model.rb, line 4 def self.included(base) base.extend ClassMethods end
new(params = {})
click to toggle source
# File lib/devtunnel/api_model.rb, line 8 def initialize(params = {}) populate(params) end
Public Instance Methods
attrs()
click to toggle source
# File lib/devtunnel/api_model.rb, line 33 def attrs {}.tap {|h| instance_variables.each { |var| h[var[1..-1]] = instance_variable_get(var) } } end
errors()
click to toggle source
# File lib/devtunnel/api_model.rb, line 23 def errors; @errors; end
errors=(arr)
click to toggle source
# File lib/devtunnel/api_model.rb, line 22 def errors=(arr); @errors = arr; end
new_record?()
click to toggle source
# File lib/devtunnel/api_model.rb, line 25 def new_record? @new_record.nil? ? true : @new_record end
populate(params = {})
click to toggle source
# File lib/devtunnel/api_model.rb, line 12 def populate(params = {}) params.each do |k,v| instance_variable_set "@#{k}", v end end
success?()
click to toggle source
# File lib/devtunnel/api_model.rb, line 29 def success? @errors.nil? end