Sha256: 6d316815d1081c103359b67f7382fd83fdd1f328701a7fddbb40556f94320c31

Contents?: true

Size: 722 Bytes

Versions: 28

Compression:

Stored size: 722 Bytes

Contents

require "uber/builder"

module Disposable
  class Twin
    # Allows building different twin classes.
    #
    #   class SongTwin < Disposable::Twin
    #     include Builder
    #     builds ->(model, options) do
    #       return Hit       if model.is_a? Model::Hit
    #       return Evergreen if options[:evergreen]
    #     end
    #   end
    #
    #   SongTwin.build(Model::Hit.new) #=> <Hit>
    module Builder
      def self.included(base)
        base.class_eval do
          include Uber::Builder

          def self.build(model, options={}) # semi-public.
            class_builder.call(model, options).new(model, options) # Uber::Builder::class_builder.
          end
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
disposable-0.4.0 lib/disposable/twin/builder.rb
disposable-0.3.2 lib/disposable/twin/builder.rb
disposable-0.3.1 lib/disposable/twin/builder.rb
disposable-0.3.0 lib/disposable/twin/builder.rb
disposable-0.2.6 lib/disposable/twin/builder.rb
disposable-0.2.5 lib/disposable/twin/builder.rb
disposable-0.2.4 lib/disposable/twin/builder.rb
disposable-0.2.3 lib/disposable/twin/builder.rb
disposable-0.2.2 lib/disposable/twin/builder.rb
disposable-0.2.1 lib/disposable/twin/builder.rb
disposable-0.1.15 lib/disposable/twin/builder.rb
disposable-0.2.0 lib/disposable/twin/builder.rb
disposable-0.2.0.rc2 lib/disposable/twin/builder.rb
disposable-0.2.0.rc1 lib/disposable/twin/builder.rb
disposable-0.1.14 lib/disposable/twin/builder.rb
disposable-0.1.13 lib/disposable/twin/builder.rb
disposable-0.1.12 lib/disposable/twin/builder.rb
disposable-0.1.11 lib/disposable/twin/builder.rb
disposable-0.1.9 lib/disposable/twin/builder.rb
disposable-0.1.8 lib/disposable/twin/builder.rb