class ArtGun::OrderItem

Public Instance Methods

as_json(opts = {except: :attrs}) click to toggle source
Calls superclass method
# File lib/art_gun/order_item.rb, line 22
def as_json opts = {except: :attrs}
  hash = super opts
  hash['attributes'] = attrs.map(&:as_json) # to avoid name conflict in model
  hash.inject({}) do |h, (k,v)|
    h[k] = v unless v.nil?
    h
  end
end
attributes() click to toggle source
# File lib/art_gun/order_item.rb, line 18
def attributes
  self.class.attrs.inject({}){|h,k| h[k.to_s] = nil; h}
end