Sha256: 9eb267dae05f7b1a9192fb64ee0d3bf8a3d6dfcd752a6965292b93d5d8daed75

Contents?: true

Size: 838 Bytes

Versions: 5

Compression:

Stored size: 838 Bytes

Contents

module Danica
  module Common extend ::ActiveSupport::Concern
    included do
      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.new(value)) if value.is_a?(Numeric)
      return wrap_value(Variable.new(value)) if value.is_a?(Hash)
      return wrap_value(Variable.new(name: value)) if [ String, Symbol ].any? { |c| value.is_a?(c) }
      return wrap_value(Variable.new) if value.nil?
      value
    end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
danica-2.2.1 lib/danica/common.rb
danica-2.2.0 lib/danica/common.rb
danica-2.1.1 lib/danica/common.rb
danica-2.1.0 lib/danica/common.rb
danica-2.0.6 lib/danica/common.rb