Class: Jbuilder::Schema::Template::ModelScope
- Inherits:
-
Struct
- Object
- Struct
- Jbuilder::Schema::Template::ModelScope
- Defined in:
- lib/jbuilder/schema/template.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#model ⇒ Object
Returns the value of attribute model.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #i18n_description ⇒ Object
- #i18n_title ⇒ Object
-
#initialize ⇒ ModelScope
constructor
A new instance of ModelScope.
- #translate_field(key) ⇒ Object
Constructor Details
#initialize ⇒ ModelScope
Returns a new instance of ModelScope.
22 23 24 25 |
# File 'lib/jbuilder/schema/template.rb', line 22 def initialize(**) super @scope = model&.name&.underscore&.pluralize end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description
21 22 23 |
# File 'lib/jbuilder/schema/template.rb', line 21 def description @description end |
#model ⇒ Object
Returns the value of attribute model
21 22 23 |
# File 'lib/jbuilder/schema/template.rb', line 21 def model @model end |
#title ⇒ Object
Returns the value of attribute title
21 22 23 |
# File 'lib/jbuilder/schema/template.rb', line 21 def title @title end |
Instance Method Details
#i18n_description ⇒ Object
31 32 33 |
# File 'lib/jbuilder/schema/template.rb', line 31 def i18n_description description || ::I18n.t(::Jbuilder::Schema.description_name, scope: @scope) end |
#i18n_title ⇒ Object
27 28 29 |
# File 'lib/jbuilder/schema/template.rb', line 27 def i18n_title title || ::I18n.t(::Jbuilder::Schema.title_name, scope: @scope) end |
#translate_field(key) ⇒ Object
35 36 37 |
# File 'lib/jbuilder/schema/template.rb', line 35 def translate_field(key) ::I18n.t("fields.#{key}.#{::Jbuilder::Schema.description_name}", scope: @scope) end |