Class: RecordViewHelper::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/record_view_helper/config.rb

Overview

RecordViewHelper config

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



4
5
6
7
8
# File 'lib/record_view_helper/config.rb', line 4

def initialize
  @true_view = true
  @false_view = false
  @locale_namespace = "record_view_helper"
end

Instance Attribute Details

#column_nameProc

Proc which returns name for column

Examples:

in Rails

Rails.application.config.record_view_helper.column_name =
  ->(table_class, column) { "[#{column}]<br>#{table_class.columns_hash[column.to_s].comment}".html_safe }

basic

class MyView < ActionView::Base
  include RecordViewHelper
end

MyView.record_view_helper_config.locale_name =
  ->(table_class, column) { "[#{column}]<br>#{table_class.columns_hash[column.to_s].comment}".html_safe }

Returns:

  • (Proc)


61
62
63
# File 'lib/record_view_helper/config.rb', line 61

def column_name
  @column_name
end

#false_viewString

text/html(raw) which is showed when false === value

Returns:

  • (String)

    (defalut = false)



16
17
18
# File 'lib/record_view_helper/config.rb', line 16

def false_view
  @false_view
end

#locale_nameProc

Proc which returns name for t(name)

Examples:

in Rails

Rails.application.config.record_view_helper.locale_name =
  ->(table_name, column) { "columns.#{table_name}.#{column}" }

basic

class MyView < ActionView::Base
  include RecordViewHelper
end

MyView.record_view_helper_config.locale_name =
  ->(table_name, column) { "columns.#{table_name}.#{column}" }

Returns:

  • (Proc)


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

def locale_name
  @locale_name
end

#locale_namespaceString

namespace for ‘t()`

Examples:

# locale_namespace is used like below
t("#{locale_namespace}.#{table_name}.columns.#{column}")

# if you want to use another hierarchy, you should use #locale_name.

Returns:

  • (String)

    (default = “record_view_helper”)



44
45
46
# File 'lib/record_view_helper/config.rb', line 44

def locale_namespace
  @locale_namespace
end

#true_viewString

text/html(raw) which is showed when true === value

Returns:

  • (String)

    (defalut = true)



12
13
14
# File 'lib/record_view_helper/config.rb', line 12

def true_view
  @true_view
end