Sha256: 11d530f1e85d2a1890eca1c153aca525dc01148f8f96cf21fdb29e9f608b9965

Contents?: true

Size: 854 Bytes

Versions: 14

Compression:

Stored size: 854 Bytes

Contents

module Liquid
  module StandardFilters

    private

    # Fixme: Handle DateTime, Date and Time objects, convert them
    # into seconds (integer)
    def to_number(obj)
      case obj
      when Numeric
        obj
      when String
        (obj.strip =~ /^\d+\.\d+$/) ? obj.to_f : obj.to_i
      when DateTime, Date, Time
        obj.to_time.to_i
      else
        0
      end
    end

  end
end

module Liquid
  module OptionsBuilder

    private

    def parse_options_from_string(string)
      string.try(:strip!)

      return nil if string.blank?

      string = string.gsub(/^(\s*,)/, '')
      Solid::Arguments.parse(string)
    end

    def interpolate_options(options, context)
      if options
        options.interpolate(context).first
      else
        {}
      end
    end

  end
end

Liquid::Tag.send(:include, Liquid::OptionsBuilder)

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
locomotivecms_steam-1.0.0.rc9 lib/locomotive/steam/liquid/patches.rb
locomotivecms_steam-1.0.0.rc8 lib/locomotive/steam/liquid/patches.rb
locomotivecms_steam-1.0.0.rc6 lib/locomotive/steam/liquid/patches.rb
locomotivecms_steam-1.0.0.rc4 lib/locomotive/steam/liquid/patches.rb
locomotivecms_steam-1.0.0.rc3 lib/locomotive/steam/liquid/patches.rb
locomotivecms_steam-1.0.0.rc2 lib/locomotive/steam/liquid/patches.rb
locomotivecms_steam-1.0.0.rc1 lib/locomotive/steam/liquid/patches.rb
locomotivecms_steam-1.0.0.pre.beta.3 lib/locomotive/steam/liquid/patches.rb
locomotivecms_steam-1.0.0.pre.beta.2 lib/locomotive/steam/liquid/patches.rb
locomotivecms_steam-1.0.0.pre.beta.1 lib/locomotive/steam/liquid/patches.rb
locomotivecms_steam-1.0.0.pre.alpha.3 lib/locomotive/steam/liquid/patches.rb
locomotivecms_steam-1.0.0.pre.alpha.2 lib/locomotive/steam/liquid/patches.rb
locomotivecms_steam-1.0.0.pre.alpha.1 lib/locomotive/steam/liquid/patches.rb
locomotivecms_steam-1.0.0.pre.alpha lib/locomotive/steam/liquid/patches.rb