Sha256: 8727dafd0c9e1cab8079ddeec292b270867b93000a26d59d1b8baf00a114d051

Contents?: true

Size: 837 Bytes

Versions: 2

Compression:

Stored size: 837 Bytes

Contents

module Danica
  module Common extend ::ActiveSupport::Concern
    included do
      include DSL

      class << self
        def default_value(name, value)
          define_method(name) { value }
        end
      end
    end

    def to_f
      raise 'Not IMplemented yet'
    end
  
    def valued?
      to_f.present?
    rescue Exception::NotDefined
      false
    end
  
    private

    def wrap_value(value)
      return wrap_value(number(value)) if value.is_a?(Numeric)
      return wrap_value(variable(value)) if value.is_a?(Hash)
      return wrap_value(variable(name: value)) if [ String, Symbol ].any? { |c| value.is_a?(c) }
      return wrap_value(variable) if value.nil?
      value
    end

    def wrap_as_group(value)
      return value if is_grouped? || value.priority >= priority
      group(value)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
danica-2.3.1 lib/danica/common.rb
danica-2.3.0 lib/danica/common.rb