Class: Bhf::Platform::Attribute::Reflection
- Inherits:
-
Object
- Object
- Bhf::Platform::Attribute::Reflection
- Defined in:
- lib/bhf/platform/attribute/reflection.rb
Instance Attribute Summary collapse
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #db_name ⇒ Object
- #display_type ⇒ Object
- #form_type ⇒ Object
-
#initialize(reflection, options = {}) ⇒ Reflection
constructor
A new instance of Reflection.
- #link ⇒ Object
- #macro ⇒ Object
- #reflection ⇒ Object
- #reorderble ⇒ Object
- #show_type ⇒ Object
- #type ⇒ Object
- #type_ignore_emtpy? ⇒ Boolean
Constructor Details
#initialize(reflection, options = {}) ⇒ Reflection
Returns a new instance of Reflection.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/bhf/platform/attribute/reflection.rb', line 6 def initialize(reflection, = {}) @name = reflection.name.to_s @title = [:title] @info = [:info] @reflection = reflection @options_form_type = [:form_type].to_sym if [:form_type] @options_display_type = [:display_type].to_sym if [:display_type] @options_show_type = [:show_type].to_sym if [:show_type] @link_platform_settings = [:link] unless [:link].blank? @reorderble = [:reorderble] end |
Instance Attribute Details
#info ⇒ Object (readonly)
Returns the value of attribute info.
4 5 6 |
# File 'lib/bhf/platform/attribute/reflection.rb', line 4 def info @info end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/bhf/platform/attribute/reflection.rb', line 4 def name @name end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/bhf/platform/attribute/reflection.rb', line 4 def title @title end |
Instance Method Details
#db_name ⇒ Object
58 59 60 |
# File 'lib/bhf/platform/attribute/reflection.rb', line 58 def db_name @reflection.foreign_key end |
#display_type ⇒ Object
30 31 32 |
# File 'lib/bhf/platform/attribute/reflection.rb', line 30 def display_type @options_display_type || :default end |
#form_type ⇒ Object
26 27 28 |
# File 'lib/bhf/platform/attribute/reflection.rb', line 26 def form_type type end |
#link ⇒ Object
66 67 68 69 |
# File 'lib/bhf/platform/attribute/reflection.rb', line 66 def link return unless @link_platform_settings @link ||= Bhf::Platform::Base.new(@link_platform_settings) end |
#macro ⇒ Object
21 22 23 24 |
# File 'lib/bhf/platform/attribute/reflection.rb', line 21 def macro return :has_and_belongs_to_many if @reflection.macro == :has_many && @reflection.[:through] @reflection.macro end |
#reflection ⇒ Object
54 55 56 |
# File 'lib/bhf/platform/attribute/reflection.rb', line 54 def reflection @reflection end |
#reorderble ⇒ Object
62 63 64 |
# File 'lib/bhf/platform/attribute/reflection.rb', line 62 def reorderble @reorderble end |
#show_type ⇒ Object
38 39 40 |
# File 'lib/bhf/platform/attribute/reflection.rb', line 38 def show_type @options_show_type || display_type end |
#type ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/bhf/platform/attribute/reflection.rb', line 42 def type return @options_form_type if @options_form_type if macro == :has_and_belongs_to_many or macro == :has_many :check_box elsif macro == :belongs_to or macro == :has_one :select else :static end end |
#type_ignore_emtpy? ⇒ Boolean
34 35 36 |
# File 'lib/bhf/platform/attribute/reflection.rb', line 34 def type_ignore_emtpy? false end |