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.
30 31 32 33 |
# File 'lib/jbuilder/schema/template.rb', line 30 def initialize(**) super @scope = model&.name&.underscore&.pluralize end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description
29 30 31 |
# File 'lib/jbuilder/schema/template.rb', line 29 def description @description end |
#model ⇒ Object
Returns the value of attribute model
29 30 31 |
# File 'lib/jbuilder/schema/template.rb', line 29 def model @model end |
#title ⇒ Object
Returns the value of attribute title
29 30 31 |
# File 'lib/jbuilder/schema/template.rb', line 29 def title @title end |
Instance Method Details
#i18n_description ⇒ Object
39 40 41 |
# File 'lib/jbuilder/schema/template.rb', line 39 def i18n_description description || ::I18n.t(::Jbuilder::Schema.description_name, scope: @scope) end |
#i18n_title ⇒ Object
35 36 37 |
# File 'lib/jbuilder/schema/template.rb', line 35 def i18n_title title || ::I18n.t(::Jbuilder::Schema.title_name, scope: @scope) end |
#translate_field(key) ⇒ Object
43 44 45 |
# File 'lib/jbuilder/schema/template.rb', line 43 def translate_field(key) ::I18n.t("fields.#{key}.#{::Jbuilder::Schema.description_name}", scope: @scope) end |