Class: Meta::JsonSchema::NamedProperties
- Inherits:
-
Properties
- Object
- Properties
- Meta::JsonSchema::NamedProperties
- Defined in:
- lib/meta/json_schema/schemas/named_properties.rb
Instance Attribute Summary collapse
-
#schema_base_name ⇒ Object
readonly
Returns the value of attribute schema_base_name.
Instance Method Summary collapse
-
#initialize(properties, schema_base_name) ⇒ NamedProperties
constructor
A new instance of NamedProperties.
- #merge(other_properties) ⇒ Object
- #schema_name(stage) ⇒ Object
Methods inherited from Properties
build_property, #defined_scopes, #filter, #to_swagger_doc, #within
Constructor Details
#initialize(properties, schema_base_name) ⇒ NamedProperties
Returns a new instance of NamedProperties.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/meta/json_schema/schemas/named_properties.rb', line 11 def initialize(properties, schema_base_name) super(properties) raise TypeError, "schema_name 必须是一个 String,当前是:#{schema_base_name.class}" unless schema_base_name.is_a?(String) raise ArgumentError, 'schema_name 不能为 nil 或空字符串' if schema_base_name.nil? || schema_base_name.empty? # 修正 base_name,确保其不包含 Entity 后缀 schema_base_name = schema_base_name.delete_suffix('Entity') if schema_base_name&.end_with?('Entity') @schema_base_name = schema_base_name end |
Instance Attribute Details
#schema_base_name ⇒ Object (readonly)
Returns the value of attribute schema_base_name.
9 10 11 |
# File 'lib/meta/json_schema/schemas/named_properties.rb', line 9 def schema_base_name @schema_base_name end |
Instance Method Details
#merge(other_properties) ⇒ Object
32 33 34 |
# File 'lib/meta/json_schema/schemas/named_properties.rb', line 32 def merge(other_properties) raise UnsupportedError, 'NamedProperties 不支持 merge 操作' end |
#schema_name(stage) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/meta/json_schema/schemas/named_properties.rb', line 22 def schema_name(stage) if stage == :render "#{schema_base_name}Entity" elsif stage == :param "#{schema_base_name}Params" else raise ArgumentError, "stage 必须是 :render 或 :param,当前是:#{stage}" end end |