Sha256: c05ec33c36b2c23e70adcdb039db9cb7db608f558f50d7a2436f452eaa2f31f6

Contents?: true

Size: 526 Bytes

Versions: 1

Compression:

Stored size: 526 Bytes

Contents

require 'rules/parameters/parameter'

module Rules::Parameters
  class Constant < Parameter
    attr_accessor :evaluation_method, :casting_method, :input_type

    def initialize(key)
      self.name = key.to_s
    end

    def evaluate(attributes = {})
      raise 'Unknown evaluation method' unless evaluation_method
      evaluation_method.call
    end

    def input_type
      @input_type || :string
    end

    def cast(value)
      return value unless casting_method
      casting_method.call(value)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rules-0.0.1 lib/rules/parameters/constant.rb