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-2.1.1 spec/support/models/default_value.rb
sinclair-2.1.0 spec/support/models/default_value.rb
sinclair-2.0.1 spec/support/models/default_value.rb
sinclair-2.0.0 spec/support/models/default_value.rb
sinclair-1.16.3 spec/support/models/default_value.rb
sinclair-1.16.2 spec/support/models/default_value.rb
sinclair-1.16.1 spec/support/models/default_value.rb
sinclair-1.16.0 spec/support/models/default_value.rb
sinclair-1.15.0 spec/support/models/default_value.rb
sinclair-1.14.2 spec/support/models/default_value.rb
sinclair-1.14.1 spec/support/models/default_value.rb
sinclair-1.14.0 spec/support/models/default_value.rb
sinclair-1.13.0 spec/support/models/default_value.rb
sinclair-1.12.1 spec/support/models/default_value.rb
sinclair-1.12.0 spec/support/models/default_value.rb
sinclair-1.11.0 spec/support/models/default_value.rb
sinclair-1.10.0 spec/support/models/default_value.rb
sinclair-1.9.0 spec/support/models/default_value.rb
sinclair-1.8.0 spec/support/models/default_value.rb
sinclair-1.7.0 spec/support/models/default_value.rb