Class: Bhf::Data::Field
- Inherits:
-
Object
- Object
- Bhf::Data::Field
- Defined in:
- lib/bhf/data.rb
Instance Attribute Summary collapse
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#overwrite_display_type ⇒ Object
readonly
Returns the value of attribute overwrite_display_type.
Instance Method Summary collapse
- #display_type ⇒ Object
- #form_type ⇒ Object
-
#initialize(props, options = {}, pk = 'id') ⇒ Field
constructor
A new instance of Field.
- #macro ⇒ Object
- #name ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(props, options = {}, pk = 'id') ⇒ Field
Returns a new instance of Field.
20 21 22 23 24 25 26 27 28 |
# File 'lib/bhf/data.rb', line 20 def initialize(props, = {}, pk = 'id') @props = props @info = [:info] @overwrite_type = [:overwrite_type].to_sym if [:overwrite_type] @overwrite_display_type = [:overwrite_display_type].to_sym if [:overwrite_display_type] @primary_key = pk end |
Instance Attribute Details
#info ⇒ Object (readonly)
Returns the value of attribute info.
18 19 20 |
# File 'lib/bhf/data.rb', line 18 def info @info end |
#overwrite_display_type ⇒ Object (readonly)
Returns the value of attribute overwrite_display_type.
18 19 20 |
# File 'lib/bhf/data.rb', line 18 def overwrite_display_type @overwrite_display_type end |
Instance Method Details
#display_type ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/bhf/data.rb', line 50 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_type ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/bhf/data.rb', line 40 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 |
#macro ⇒ Object
30 31 32 |
# File 'lib/bhf/data.rb', line 30 def macro :column end |
#name ⇒ Object
62 63 64 |
# File 'lib/bhf/data.rb', line 62 def name @props.name end |
#type ⇒ Object
34 35 36 37 38 |
# File 'lib/bhf/data.rb', line 34 def type return @overwrite_type if @overwrite_type @props.type end |