Module: MultiAuthHelper

Included in:
ApplicationHelper
Defined in:
lib/multi_auth_helper.rb

Overview

TODO: 不要なメソッドを削除する

Instance Method Summary collapse

Instance Method Details

#add_iconObject



58
59
60
# File 'lib/multi_auth_helper.rb', line 58

def add_icon
  return icon16("icons/fam/add.png", "追加")
end

#additional_head(&block) ⇒ Object



23
24
25
26
# File 'lib/multi_auth_helper.rb', line 23

def additional_head(&block)
  @additional_head_html ||= ""
  @additional_head_html  += capture(&block)
end

#csv_iconObject



78
79
80
# File 'lib/multi_auth_helper.rb', line 78

def csv_icon
  return icon16("icons/fam/table_save.png", "CSV")
end

#delete_iconObject



66
67
68
# File 'lib/multi_auth_helper.rb', line 66

def delete_icon
  return icon16("icons/fam/bin.png", "削除")
end

#disable_iconObject



50
51
52
# File 'lib/multi_auth_helper.rb', line 50

def disable_icon
  return icon16("icons/fam/stop.png", "無効")
end

#edit_iconObject



62
63
64
# File 'lib/multi_auth_helper.rb', line 62

def edit_icon
  return icon16("icons/fam/cog.png", "編集")
end

#enable_iconObject



46
47
48
# File 'lib/multi_auth_helper.rb', line 46

def enable_icon
  return icon16("icons/fam/tick.png", "有効")
end

#enable_or_disable_icon(enable) ⇒ Object



54
55
56
# File 'lib/multi_auth_helper.rb', line 54

def enable_or_disable_icon(enable)
  return (enable ? enable_icon : disable_icon)
end

#even_or_odd(index) ⇒ Object



33
34
35
# File 'lib/multi_auth_helper.rb', line 33

def even_or_odd(index)
  return %w[even odd][index % 2]
end

#feed_iconObject



74
75
76
# File 'lib/multi_auth_helper.rb', line 74

def feed_icon
  return icon16("icons/fam/feed.png", "フィード")
end

#help_icon(alt = "ヘルプ") ⇒ Object



70
71
72
# File 'lib/multi_auth_helper.rb', line 70

def help_icon(alt = "ヘルプ")
  return icon16("icons/fam/help.png", alt)
end

#icon16(path, alt = nil) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/multi_auth_helper.rb', line 37

def icon16(path, alt = nil)
  return image_tag(
    path,
    :width  => 16,
    :height => 16,
    :alt    => alt,
    :title  => alt)
end

#logged_in?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/multi_auth_helper.rb', line 10

def logged_in?
  !!@login_user
end

#mmdd_hhmm(time, null = "-") ⇒ Object



90
91
92
# File 'lib/multi_auth_helper.rb', line 90

def mmdd_hhmm(time, null = "-")
  return time.try(:strftime, "%m月%d日 %H時%M分") || null
end

#production?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/multi_auth_helper.rb', line 6

def production?
  return (RAILS_ENV == "production")
end

#rss_auto_discovery(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
# File 'lib/multi_auth_helper.rb', line 14

def rss_auto_discovery(options = {})
  options = options.dup
  title = options.delete(:title) || raise(ArgumentError)
  href  = options.delete(:href)  || raise(ArgumentError)
  raise(ArgumentError) unless options.empty?

  return %|<link rel="alternate" type="application/rss+xml" title="#{h(title)}" href="#{h(href)}" />|
end

#side_column(&block) ⇒ Object



28
29
30
31
# File 'lib/multi_auth_helper.rb', line 28

def side_column(&block)
  @side_column_html ||= ""
  @side_column_html  += capture(&block)
end

#user_nickname(user, nickname_column = :nickname) ⇒ Object



94
95
96
97
# File 'lib/multi_auth_helper.rb', line 94

def user_nickname(user, nickname_column = :nickname)
  nickname = user.__send__(nickname_column)
  return (nickname.blank? ? h("名無しさん") : h(nickname))
end

#yyyymmdd(time, null = "-") ⇒ Object



82
83
84
# File 'lib/multi_auth_helper.rb', line 82

def yyyymmdd(time, null = "-")
  return time.try(:strftime, "%Y年%m月%d日") || null
end

#yyyymmdd_hhmm(time, null = "-") ⇒ Object



86
87
88
# File 'lib/multi_auth_helper.rb', line 86

def yyyymmdd_hhmm(time, null = "-")
  return time.try(:strftime, "%Y年%m月%d日 %H時%M分") || null
end