Sha256: bd8f607a2c5d76b45f8eb31810a178e907af2a188a95be8c8d04627c72822f13

Contents?: true

Size: 652 Bytes

Versions: 7

Compression:

Stored size: 652 Bytes

Contents

module Webmate::Presenters
  module Scoped
    extend ActiveSupport::Concern

    def build_serialized(*args, &block)
      object = args.first
      if object.is_a?(Array)
        object.map do |obj|
          get_serializable_attributes(obj, &block)
        end
      else
        get_serializable_attributes(object, &block)
      end
    end

    private

    def get_serializable_attributes(object, &block)
      serializer = serializable_class.new(object)
      instance_exec do
        serializer.instance_exec(object, &block)
      end
      serializer.attrs
    end

    def serializable_class
      Webmate::Presenters::Base
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
webmate-0.1.6 lib/webmate/presenters/scoped.rb
webmate-0.1.5 lib/webmate/presenters/scoped.rb
webmate-0.1.4 lib/webmate/presenters/scoped.rb
webmate-0.1.3 lib/webmate/presenters/scoped.rb
webmate-0.1.2 lib/webmate/presenters/scoped.rb
webmate-0.1.1 lib/webmate/presenters/scoped.rb
webmate-0.1.0 lib/webmate/presenters/scoped.rb