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.



8
9
10
11
12
13
14
15
# File 'lib/bhf/data.rb', line 8

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

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

  @primary_key = pk
end

Instance Attribute Details

#infoObject (readonly)

Returns the value of attribute info.



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

def info
  @info
end

Instance Method Details

#display_typeObject



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

def 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



27
28
29
30
31
32
33
34
35
# File 'lib/bhf/data.rb', line 27

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



17
18
19
# File 'lib/bhf/data.rb', line 17

def macro
  :column
end

#nameObject



47
48
49
# File 'lib/bhf/data.rb', line 47

def name
  @props.name
end

#typeObject



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

def type
  return @overwrite_type if @overwrite_type

  @props.type
end