Class: Administer::Fields::HasOne
Instance Attribute Summary collapse
Attributes inherited from Association
#association_class, #association_config, #parent_class
Attributes inherited from Base
#name
Instance Method Summary
collapse
Methods inherited from Association
#collection, #display_object
Methods inherited from Base
#partial
Constructor Details
#initialize(name, foreign_key, association_class, parent) ⇒ 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
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 options
[["", 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
|