Sha256: fbc34bd18d28901b999495ed8964c23f56e8ad12665b725fa3fddf80b9936c5f

Contents?: true

Size: 922 Bytes

Versions: 4

Compression:

Stored size: 922 Bytes

Contents

module ActiveList
  module Helpers
    def recordify!(value, record_name)
      if value.is_a?(Symbol)
        record_name + '.' + value.to_s
      elsif value.is_a?(CodeString)
        '(' + value.gsub(/RECORD/, record_name) + ')'
      else
        raise ArgumentError, 'CodeString or Symbol must be given to be recordified)'
      end
    end

    def recordify(value, record_name)
      if value.is_a?(Symbol)
        record_name + '.' + value.to_s
      elsif value.is_a?(CodeString)
        '(' + value.gsub(/RECORD/, record_name) + ')'
      else
        value.inspect
      end
    end

    def urlify(key, value, record_name, namespace = nil)
      return value.inspect unless value.is_a?(CodeString)
      if key == :controller && namespace
        '(' + "'/#{namespace}/' + " + value.gsub(/RECORD/, record_name) + ')'
      else
        '(' + value.gsub(/RECORD/, record_name) + ')'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_list-8.1.0 lib/active_list/helpers.rb
active_list-7.3.0 lib/active_list/helpers.rb
active_list-8.0.0 lib/active_list/helpers.rb
active_list-7.2.0 lib/active_list/helpers.rb