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.



30
31
32
33
# File 'lib/jbuilder/schema/template.rb', line 30

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



29
30
31
# File 'lib/jbuilder/schema/template.rb', line 29

def description
  @description
end

#modelObject

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



29
30
31
# File 'lib/jbuilder/schema/template.rb', line 29

def model
  @model
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



29
30
31
# File 'lib/jbuilder/schema/template.rb', line 29

def title
  @title
end

Instance Method Details

#i18n_descriptionObject



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_titleObject



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