Sha256: 9e1cf9c08da360345a6f448d453f93fe12077eb87918ad3209df79936b5ab06a

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

# -*- encoding : utf-8 -*-
# not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES[:info]=:string

def info_show(object, attribute)
  # show the attribute. if it's a date/time, make it nicer. If it has a _presentation, show that instead
  o = object.send(attribute)
  o = o.to_s + " (" + distance_of_time_in_words_to_now(o) + ")" if o.is_a?(Time)
  o = o._presentation if o.respond_to?(:_presentation)
  o
end

def info_edit(object, attribute)
  o = object.send(attribute)
  o = o.to_s + " (" + distance_of_time_in_words_to_now(o) + ")" if o.is_a?(Time)
  o = o._presentation if o.respond_to?(:_presentation)
  o
end

def info_update(object, attribute)
  # do absolutely nothing
end

module ActionView::Helpers::DateHelper

  def distance_of_time_in_words_to_now_with_future(from_time, include_seconds = false)
    if from_time > Time.now()
      'in ' + distance_of_time_in_words_to_now_without_future(from_time, include_seconds)
    else
      distance_of_time_in_words_to_now_without_future(from_time, include_seconds) + ' ago'
    end
  end

  alias_method_chain :distance_of_time_in_words_to_now, :future

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
inline_forms-1.6.18 lib/app/helpers/form_elements/info.rb
inline_forms-1.6.17 lib/app/helpers/form_elements/info.rb
inline_forms-1.6.16 lib/app/helpers/form_elements/info.rb
inline_forms-1.6.15 lib/app/helpers/form_elements/info.rb
inline_forms-1.6.12 lib/app/helpers/form_elements/info.rb
inline_forms-1.6.11 lib/app/helpers/form_elements/info.rb
inline_forms-1.6.10 lib/app/helpers/form_elements/info.rb
inline_forms-1.6.9 lib/app/helpers/form_elements/info.rb