Class: Apiwork::Adapter::Wrapper::Shape
- Inherits:
-
Object
- Object
- Apiwork::Adapter::Wrapper::Shape
- Defined in:
- lib/apiwork/adapter/wrapper/shape.rb
Overview
Base class for wrapper shapes.
Subclass to define response type structure for record or collection wrappers. The block is evaluated via instance_exec, providing access to type DSL methods and helpers like root_key and #metadata_type_names.
Instance Attribute Summary collapse
-
#data_type ⇒ Symbol?
readonly
The data type for this shape.
-
#metadata_type_names ⇒ Array<Symbol>
readonly
The metadata type names for this shape.
- #root_key ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
- #apply ⇒ Object
- #array(name, **options, &block) ⇒ Object
- #array?(name, **options, &block) ⇒ Object
- #binary(name, **options) ⇒ Object
- #binary?(name, **options) ⇒ Object
- #boolean(name, **options) ⇒ Object
- #boolean?(name, **options) ⇒ Object
- #date(name, **options) ⇒ Object
- #date?(name, **options) ⇒ Object
- #datetime(name, **options) ⇒ Object
- #datetime?(name, **options) ⇒ Object
- #decimal(name, **options) ⇒ Object
- #decimal?(name, **options) ⇒ Object
- #extends(type) ⇒ Object
-
#initialize(target, root_key, metadata_type_names, data_type: nil) ⇒ Shape
constructor
A new instance of Shape.
- #integer(name, **options) ⇒ Object
- #integer?(name, **options) ⇒ Object
- #literal(name, value:, **options) ⇒ Object
- #merge(other) ⇒ Object
- #number(name, **options) ⇒ Object
- #number?(name, **options) ⇒ Object
- #object(name, **options, &block) ⇒ Object
- #object?(name, **options, &block) ⇒ Object
- #reference(name, **options) ⇒ Object
- #reference?(name, **options) ⇒ Object
- #string(name, **options) ⇒ Object
- #string?(name, **options) ⇒ Object
- #time(name, **options) ⇒ Object
- #time?(name, **options) ⇒ Object
- #union(name, **options, &block) ⇒ Object
- #union?(name, **options, &block) ⇒ Object
- #uuid(name, **options) ⇒ Object
- #uuid?(name, **options) ⇒ Object
Constructor Details
#initialize(target, root_key, metadata_type_names, data_type: nil) ⇒ Shape
Returns a new instance of Shape.
190 191 192 193 194 195 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 190 def initialize(target, root_key, , data_type: nil) @target = target @root_key = root_key @metadata_type_names = @data_type = data_type end |
Instance Attribute Details
#data_type ⇒ Symbol? (readonly)
The data type for this shape.
60 61 62 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 60 def data_type @data_type end |
#metadata_type_names ⇒ Array<Symbol> (readonly)
The metadata type names for this shape.
Auto-generated type names from capability Capability::Operation::Base.metadata_shape definitions. Use with #merge to include capability metadata fields in the shape.
60 61 62 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 60 attr_reader :data_type, :metadata_type_names, :root_key |
#root_key ⇒ Object (readonly)
60 61 62 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 60 attr_reader :data_type, :metadata_type_names, :root_key |
Class Method Details
.apply(target, root_key, capabilities, representation_class, type, data_type: nil) ⇒ Object
30 31 32 33 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 30 def apply(target, root_key, capabilities, representation_class, type, data_type: nil) = (capabilities, representation_class, type) new(target, root_key, , data_type:).apply end |
Instance Method Details
#apply ⇒ Object
197 198 199 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 197 def apply raise NotImplementedError end |
#array(name, **options, &block) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#array?(name, **options, &block) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#binary(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#binary?(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#boolean(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#boolean?(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#date(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#date?(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#datetime(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#datetime?(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#decimal(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#decimal?(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#extends(type) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#integer(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#integer?(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#literal(name, value:, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#merge(other) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#number(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#number?(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#object(name, **options, &block) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#object?(name, **options, &block) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#reference(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#reference?(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#string(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#string?(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#time(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#time?(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#union(name, **options, &block) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#union?(name, **options, &block) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#uuid(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |
#uuid?(name, **options) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/apiwork/adapter/wrapper/shape.rb', line 157 delegate :array, :array?, :binary, :binary?, :boolean, :boolean?, :date, :date?, :datetime, :datetime?, :decimal, :decimal?, :extends, :integer, :integer?, :literal, :merge, :number, :number?, :object, :object?, :reference, :reference?, :string, :string?, :time, :time?, :union, :union?, :uuid, :uuid?, to: :@target |