Class: Administer::Fields::HasOne
- Inherits:
-
Association
- Object
- Base
- Association
- Administer::Fields::HasOne
- Defined in:
- lib/administer/fields/has_one.rb
Instance Attribute Summary collapse
-
#foreign_key ⇒ Object
readonly
Returns the value of attribute foreign_key.
Attributes inherited from Association
#association_class, #association_config, #parent_class
Attributes inherited from Base
Instance Method Summary collapse
- #dom_id ⇒ Object
-
#initialize(name, foreign_key, association_class, parent) ⇒ HasOne
constructor
A new instance of HasOne.
- #options ⇒ Object
- #select_name ⇒ Object
Methods inherited from Association
Methods inherited from Base
Constructor Details
#initialize(name, foreign_key, association_class, parent) ⇒ HasOne
Returns a new instance of HasOne.
6 7 8 9 |
# File 'lib/administer/fields/has_one.rb', line 6 def initialize(name, foreign_key, association_class, parent) super(name, association_class, parent) @foreign_key = foreign_key end |
Instance Attribute Details
#foreign_key ⇒ Object (readonly)
Returns the value of attribute foreign_key.
4 5 6 |
# File 'lib/administer/fields/has_one.rb', line 4 def foreign_key @foreign_key end |
Instance Method Details
#dom_id ⇒ Object
15 16 17 |
# File 'lib/administer/fields/has_one.rb', line 15 def dom_id "#{parent_class.name.downcase}_#{foreign_key}" end |
#options ⇒ Object
19 20 21 |
# File 'lib/administer/fields/has_one.rb', line 19 def [["", nil]] + collection.map{ |object| [display_object(object), object.id] } end |
#select_name ⇒ Object
11 12 13 |
# File 'lib/administer/fields/has_one.rb', line 11 def select_name "#{parent_class.name.downcase}[#{foreign_key}]" end |