Sha256: 47498b5cf19892827f17c9efd15a1c9e02d0c6214d7f4a6484d5567db2b3e2d8

Contents?: true

Size: 513 Bytes

Versions: 30

Compression:

Stored size: 513 Bytes

Contents

# frozen_string_literal: true

class DefaultValue
  delegate :build, to: :builder
  attr_reader :klass, :method, :value, :class_method

  def initialize(klass, method, value, class_method: false)
    @klass = klass
    @method = method
    @value = value
    @class_method = class_method
  end

  private

  def builder
    @builder ||= Sinclair.new(klass).tap do |b|
      if class_method
        b.add_class_method(method) { value }
      else
        b.add_method(method) { value }
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
sinclair-1.6.7 spec/support/models/default_value.rb
sinclair-1.6.6 spec/support/models/default_value.rb
sinclair-1.6.5 spec/support/models/default_value.rb
sinclair-1.6.4 spec/support/models/default_value.rb
sinclair-1.6.3 spec/support/models/default_value.rb
sinclair-1.6.2 spec/support/models/default_value.rb
sinclair-1.6.1 spec/support/models/default_value.rb
sinclair-1.6.0 spec/support/models/default_value.rb
sinclair-1.5.2 spec/support/models/default_value.rb
sinclair-1.5.1 spec/support/models/default_value.rb