Sha256: 5183c1a38e4e4fd7d14e42db4a4c158456798ebb8f9c94d71e4eae454448114d

Contents?: true

Size: 361 Bytes

Versions: 43

Compression:

Stored size: 361 Bytes

Contents

# frozen_string_literal: true

module InitialValuer
  extend ActiveSupport::Concern

  class_methods do
    def initial_value_for(attribute, value)
      builder = Sinclair.new(self, initial_value: value)
      builder.eval_and_add_method(attribute) do
        "@#{attribute} ||= #{options_object.initial_value}"
      end
      builder.build
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
sinclair-2.1.1 spec/support/models/initial_valuer.rb
sinclair-2.1.0 spec/support/models/initial_valuer.rb
sinclair-2.0.1 spec/support/models/initial_valuer.rb
sinclair-2.0.0 spec/support/models/initial_valuer.rb
sinclair-1.16.3 spec/support/models/initial_valuer.rb
sinclair-1.16.2 spec/support/models/initial_valuer.rb
sinclair-1.16.1 spec/support/models/initial_valuer.rb
sinclair-1.16.0 spec/support/models/initial_valuer.rb
sinclair-1.15.0 spec/support/models/initial_valuer.rb
sinclair-1.14.2 spec/support/models/initial_valuer.rb
sinclair-1.14.1 spec/support/models/initial_valuer.rb
sinclair-1.14.0 spec/support/models/initial_valuer.rb
sinclair-1.13.0 spec/support/models/initial_valuer.rb
sinclair-1.12.1 spec/support/models/initial_valuer.rb
sinclair-1.12.0 spec/support/models/initial_valuer.rb
sinclair-1.11.0 spec/support/models/initial_valuer.rb
sinclair-1.10.0 spec/support/models/initial_valuer.rb
sinclair-1.9.0 spec/support/models/initial_valuer.rb
sinclair-1.8.0 spec/support/models/initial_valuer.rb
sinclair-1.7.0 spec/support/models/initial_valuer.rb