Class: Bhf::Data::Reflection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reflection, options = {}) ⇒ Reflection

Returns a new instance of Reflection.



91
92
93
94
95
96
97
98
# File 'lib/bhf/data.rb', line 91

def initialize(reflection, options = {})
  @reflection = reflection
  @info = options[:info]
  @link = options[:link].downcase.to_sym unless options[:link].blank?

  @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]
end

Instance Attribute Details

#infoObject (readonly)

Returns the value of attribute info.



89
90
91
# File 'lib/bhf/data.rb', line 89

def info
  @info
end

Returns the value of attribute link.



89
90
91
# File 'lib/bhf/data.rb', line 89

def link
  @link
end

#overwrite_display_typeObject (readonly)

Returns the value of attribute overwrite_display_type.



89
90
91
# File 'lib/bhf/data.rb', line 89

def overwrite_display_type
  @overwrite_display_type
end

#reflectionObject (readonly)

Returns the value of attribute reflection.



89
90
91
# File 'lib/bhf/data.rb', line 89

def reflection
  @reflection
end

Instance Method Details

#display_typeObject



120
121
122
123
# File 'lib/bhf/data.rb', line 120

def display_type
  return @overwrite_display_type if @overwrite_display_type
  :default
end

#form_typeObject



116
117
118
# File 'lib/bhf/data.rb', line 116

def form_type
  type
end

#macroObject



100
101
102
# File 'lib/bhf/data.rb', line 100

def macro
  @reflection.macro
end

#nameObject



125
126
127
# File 'lib/bhf/data.rb', line 125

def name
  @reflection.name.to_s
end

#typeObject



104
105
106
107
108
109
110
111
112
113
114
# File 'lib/bhf/data.rb', line 104

def type
  return @overwrite_type if @overwrite_type

  if macro == :has_and_belongs_to_many
    :check_box
  elsif macro == :belongs_to
    :select
  else
    :static
  end
end