Sha256: b389255aa55d39c3666f1931198a82ccc20732bf2906488b922a6d29aee2f96c

Contents?: true

Size: 704 Bytes

Versions: 6

Compression:

Stored size: 704 Bytes

Contents

module Autobots
  class Assembler
    class_attribute :serializer
    attr_reader :identifiers, :options, :objects

    def initialize(identifiers, options = {})
      @identifiers, @options = identifiers, options
      @objects = assemble(identifiers)
    end

    def data
      roll_out(objects)
    end

    private

    # builds our skeleton resources
    def assemble(identifiers)
      identifiers
    end

    # fetch any additional objects and modify our resources
    def transform(resources)
      resources
    end

    # serialize everything
    def roll_out(objects)
      transform(objects).map{|obj| serializer.new(obj).serializable_hash }
    end

    prepend Helpers::Caching

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
autobots-0.2.3 lib/autobots/assembler.rb
autobots-0.2.2 lib/autobots/assembler.rb
autobots-0.2.1 lib/autobots/assembler.rb
autobots-0.2.0 lib/autobots/assembler.rb
autobots-0.1.0 lib/autobots/assembler.rb
autobots-0.0.1 lib/autobots/assembler.rb