Base progress

This commit is contained in:
2015-09-16 11:50:55 +02:00
parent ef894f9e02
commit 6a085b1ca2
52 changed files with 3686 additions and 1818 deletions
+1
View File
@@ -7,6 +7,7 @@ module Qwaiter
autoload :UserBaseSerializer
autoload :SupplierBaseSerializer
autoload :EmployeeBaseSerializer
autoload :WaiterBaseSerializer
autoload :Counter
autoload :Broadcaster
autoload :Couchbase
+2
View File
@@ -1,3 +1,4 @@
=begin
module Qwaiter
class Serializer < ActiveModel::Serializer
def self.root=(val)
@@ -34,6 +35,7 @@ module Qwaiter
end
end
end
=end
# require 'active_model/array_serializer'
# module ActiveModel
+10 -2
View File
@@ -3,8 +3,8 @@ module Qwaiter::SupplierBaseSerializer
include JSONAPI::Serializer
included do
class_attribute :related_link_for_attributes
attribute :created_at
attribute :updated_at
timestamp_attribute :created_at
timestamp_attribute :updated_at
end
def base_url
@@ -25,6 +25,7 @@ module Qwaiter::SupplierBaseSerializer
super
end
def relationship_self_link(attribute_name)
end
@@ -35,6 +36,13 @@ module Qwaiter::SupplierBaseSerializer
end
end
def timestamp_attribute(attr)
attribute attr do
return unless timestamp = object.public_send(attr)
timestamp.iso8601
end
end
def related_link_for(*attributes)
self.related_link_for_attributes = attributes
end
+50
View File
@@ -0,0 +1,50 @@
module Qwaiter::WaiterBaseSerializer
extend ActiveSupport::Concern
include JSONAPI::Serializer
included do
class_attribute :related_link_for_attributes
timestamp_attribute :created_at
timestamp_attribute :updated_at
end
def base_url
nil
end
def format_name(attribute_name)
attribute_name.to_s.dasherize
end
def unformat_name(attribute_name)
attribute_name.to_s.underscore
end
#alias_method :default_relationship_related_link, :relationship_related_link
def relationship_related_link(attribute_name)
#super if related_link_for_attributes.include?(attribute_name)
super
end
def relationship_self_link(attribute_name)
end
module ClassMethods
def attributes(*attrs)
attrs.each do |attr|
attribute attr
end
end
def timestamp_attribute(attr)
attribute attr do
return unless timestamp = object.public_send(attr)
timestamp.iso8601
end
end
def related_link_for(*attributes)
self.related_link_for_attributes = attributes
end
end
end