Class: Bhf::Platform::Attribute::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/bhf/platform/attribute/column.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(props, options = {}) ⇒ Column

Returns a new instance of Column.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/bhf/platform/attribute/column.rb', line 6

def initialize(props, options = {})
  @name = props.name
  @title = options[:title]
  @info = options[:info]
  @type = props.type

  @options_form_type = options[:form_type].to_sym if options[:form_type]
  @options_display_type = options[:display_type].to_sym if options[:display_type]
  @options_show_type = options[:show_type].to_sym if options[:show_type]

  @pk = options[:primary_key]
end

Instance Attribute Details

#infoObject (readonly)

Returns the value of attribute info.



4
5
6
# File 'lib/bhf/platform/attribute/column.rb', line 4

def info
  @info
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/bhf/platform/attribute/column.rb', line 4

def name
  @name
end

#titleObject (readonly)

Returns the value of attribute title.



4
5
6
# File 'lib/bhf/platform/attribute/column.rb', line 4

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/bhf/platform/attribute/column.rb', line 4

def type
  @type
end

Instance Method Details

#db_nameObject



59
60
61
# File 'lib/bhf/platform/attribute/column.rb', line 59

def db_name
  name
end

#display_typeObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bhf/platform/attribute/column.rb', line 35

def display_type
  return @options_display_type if @options_display_type

  if name == @pk
    :primary_key
  elsif name == 'type'
    :type
  else
    supported_types(@type)
  end
end

#form_typeObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bhf/platform/attribute/column.rb', line 23

def form_type
  return @options_form_type if @options_form_type

  if name == @pk || name == 'updated_at' || name == 'created_at'
    :static
  elsif name == 'type'
    :type
  else
    supported_types(@type)
  end
end

#macroObject



19
20
21
# File 'lib/bhf/platform/attribute/column.rb', line 19

def macro
  :column
end

#reflectionObject



55
56
57
# File 'lib/bhf/platform/attribute/column.rb', line 55

def reflection
  false
end

#reorderbleObject



63
64
65
# File 'lib/bhf/platform/attribute/column.rb', line 63

def reorderble
  true
end

#show_typeObject



51
52
53
# File 'lib/bhf/platform/attribute/column.rb', line 51

def show_type
  @options_show_type || display_type
end

#type_ignore_emtpy?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/bhf/platform/attribute/column.rb', line 47

def type_ignore_emtpy?
  display_type == :boolean || display_type == :toggle
end