class Ember::Schema::RestPack
Public Instance Methods
camelize(serializer, klass)
click to toggle source
# File lib/ember/schema/rest_pack.rb, line 20 def camelize(serializer, klass) klass.name.camelize end
descendants(serializer)
click to toggle source
# File lib/ember/schema/rest_pack.rb, line 12 def descendants(serializer) serializer.descendants.sort_by { |s| s.name } end
get_klass(serializer)
click to toggle source
# File lib/ember/schema/rest_pack.rb, line 16 def get_klass(serializer) serializer.model_class end
schema(serializer, klass)
click to toggle source
# File lib/ember/schema/rest_pack.rb, line 24 def schema(serializer, klass) columns = if klass.respond_to? :columns_hash then klass.columns_hash else {} end attrs = {} (serializer.serializable_attributes || {}).each do |id, name| options = serializer.serializable_attributes_options[id] || {} if options[:type].present? attrs[name] = options[:type].to_s else # If no type is given, attempt to get it from the Active Model class if column = columns[name.to_s] attrs[name] = column.type else # Other wise default to string attrs[name] = "string" end end end associations = {} serializer.can_include.each do |association_name| if model_association = klass.reflect_on_association(association_name) # Real association associations[association_name] = { model_association.macro => model_association.class_name.pluralize.underscore.downcase } end end return { :attributes => attrs, :associations => associations } end
serializers()
click to toggle source
# File lib/ember/schema/rest_pack.rb, line 8 def serializers ::RestPack::Serializer.class_map.sort_by { |s| s[0] }.map { |s| s[1] } end
superclass()
click to toggle source
# File lib/ember/schema/rest_pack.rb, line 4 def superclass ::RestPack::Serializer end