Class: Bhf::Data::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/bhf/data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(props, options = {}, pk = 'id') ⇒ Field

Returns a new instance of Field.



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

def initialize(props, options = {}, pk = 'id')
  @props = props
  @info = options[:info]

  @overwrite_type = options[:overwrite_type].to_sym if options[:overwrite_type]
  @overwrite_display_type = options[:overwrite_display_type].to_sym if options[:overwrite_display_type]
  @overwrite_show_type = options[:overwrite_show_type].to_sym if options[:overwrite_show_type]

  @primary_key = pk
end

Instance Attribute Details

#infoObject (readonly)

Returns the value of attribute info.



21
22
23
# File 'lib/bhf/data.rb', line 21

def info
  @info
end

#overwrite_display_typeObject (readonly)

Returns the value of attribute overwrite_display_type.



21
22
23
# File 'lib/bhf/data.rb', line 21

def overwrite_display_type
  @overwrite_display_type
end

#overwrite_show_typeObject (readonly)

Returns the value of attribute overwrite_show_type.



21
22
23
# File 'lib/bhf/data.rb', line 21

def overwrite_show_type
  @overwrite_show_type
end

Instance Method Details

#display_typeObject



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/bhf/data.rb', line 58

def display_type
  return @overwrite_display_type if @overwrite_display_type
  
  if name == @primary_key
    :primary_key
  elsif name == 'updated_at' || name == 'created_at'
    :date
  else
    supported_types(@props.type)
  end
end

#form_typeObject



48
49
50
51
52
53
54
55
56
# File 'lib/bhf/data.rb', line 48

def form_type
  return @overwrite_type if @overwrite_type

  if name == @primary_key || name == 'updated_at' || name == 'created_at'
    :static
  else
    supported_types(@props.type)
  end
end

#macroObject



34
35
36
# File 'lib/bhf/data.rb', line 34

def macro
  :column
end

#nameObject



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

def name
  @props.name
end

#show_typeObject



44
45
46
# File 'lib/bhf/data.rb', line 44

def show_type
  return @overwrite_show_type if @overwrite_show_type
end

#typeObject



38
39
40
41
42
# File 'lib/bhf/data.rb', line 38

def type
  return @overwrite_type if @overwrite_type

  @props.type
end