Class: Adminable::Fields::Base
- Inherits:
-
Object
- Object
- Adminable::Fields::Base
- Defined in:
- lib/adminable/fields/base.rb
Overview
Note:
Cannot be initialized
Base class for fields
Direct Known Subclasses
BelongsTo, Boolean, Date, Datetime, Decimal, Float, HasMany, HasOne, Integer, String, Text, Time, Timestamp
Instance Attribute Summary collapse
-
#name ⇒ Symbol
readonly
Field name.
-
#options ⇒ Hash
readonly
Default options for field.
Instance Method Summary collapse
-
#form_partial_path ⇒ String
Path to field form partial.
-
#index_partial_path ⇒ String
Path to field index partial.
-
#initialize(name, options = {}) ⇒ Base
constructor
A new instance of Base.
-
#key ⇒ Symbol
Field form key.
-
#ransack_name ⇒ String
Ransack form key.
-
#strong_parameter ⇒ Symbol
Controller strong parameters key.
-
#type ⇒ Symbol
Field type.
Constructor Details
Instance Attribute Details
#name ⇒ Symbol (readonly)
Returns field name.
7 8 9 |
# File 'lib/adminable/fields/base.rb', line 7 def name @name end |
#options ⇒ Hash (readonly)
Returns default options for field.
10 11 12 |
# File 'lib/adminable/fields/base.rb', line 10 def @options end |
Instance Method Details
#form_partial_path ⇒ String
Returns path to field form partial.
50 51 52 |
# File 'lib/adminable/fields/base.rb', line 50 def form_partial_path "form/#{type}" end |
#index_partial_path ⇒ String
Returns path to field index partial.
45 46 47 |
# File 'lib/adminable/fields/base.rb', line 45 def index_partial_path "index/#{type}" end |
#key ⇒ Symbol
Returns field form key.
22 23 24 |
# File 'lib/adminable/fields/base.rb', line 22 def key @key ||= name end |
#ransack_name ⇒ String
Returns ransack form key.
32 33 34 |
# File 'lib/adminable/fields/base.rb', line 32 def ransack_name @ransack_name ||= "#{name}_cont" end |
#strong_parameter ⇒ Symbol
Returns controller strong parameters key.
27 28 29 |
# File 'lib/adminable/fields/base.rb', line 27 def strong_parameter @strong_parameter ||= key end |
#type ⇒ Symbol
Returns field type.
40 41 42 |
# File 'lib/adminable/fields/base.rb', line 40 def type @type ||= self.class.name.demodulize.underscore.to_sym end |