Class: Listings::BaseFieldView
- Inherits:
-
Object
- Object
- Listings::BaseFieldView
- Defined in:
- lib/listings/base_field_view.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#listing ⇒ Object
readonly
Returns the value of attribute listing.
Instance Method Summary collapse
- #descriptor ⇒ Object
- #human_name ⇒ Object
-
#initialize(listing, field_description) ⇒ BaseFieldView
constructor
A new instance of BaseFieldView.
- #is_field? ⇒ Boolean
- #key ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(listing, field_description) ⇒ BaseFieldView
Returns a new instance of BaseFieldView.
6 7 8 9 10 11 12 13 14 |
# File 'lib/listings/base_field_view.rb', line 6 def initialize(listing, field_description) @listing = listing @field_description = field_description @field = if @field_description.is_field? @field_description.build_field(listing) else nil end end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
3 4 5 |
# File 'lib/listings/base_field_view.rb', line 3 def field @field end |
#listing ⇒ Object (readonly)
Returns the value of attribute listing.
4 5 6 |
# File 'lib/listings/base_field_view.rb', line 4 def listing @listing end |
Instance Method Details
#descriptor ⇒ Object
39 40 41 |
# File 'lib/listings/base_field_view.rb', line 39 def descriptor @field_description end |
#human_name ⇒ Object
20 21 22 23 24 25 |
# File 'lib/listings/base_field_view.rb', line 20 def human_name return @field_description.props[:title] if @field_description.props[:title] return path if path.is_a?(String) I18n.t("listings.headers.#{listing.name}.#{key}", default: listing.human_name(field)) end |
#is_field? ⇒ Boolean
35 36 37 |
# File 'lib/listings/base_field_view.rb', line 35 def is_field? @field_description.is_field? end |
#key ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/listings/base_field_view.rb', line 27 def key if @field @field.key else path end end |
#path ⇒ Object
16 17 18 |
# File 'lib/listings/base_field_view.rb', line 16 def path @field_description.path end |