Class: Jbuilder::Schema::Template::ModelScope

Inherits:
Struct
  • Object
show all
Defined in:
lib/jbuilder/schema/template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeModelScope

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

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



21
22
23
# File 'lib/jbuilder/schema/template.rb', line 21

def description
  @description
end

#modelObject

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



21
22
23
# File 'lib/jbuilder/schema/template.rb', line 21

def model
  @model
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



21
22
23
# File 'lib/jbuilder/schema/template.rb', line 21

def title
  @title
end

Instance Method Details

#i18n_descriptionObject



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_titleObject



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