Class: ApiBlueprint::Model

Inherits:
Dry::Struct
  • Object
show all
Extended by:
ActiveModel::Callbacks, ActiveModel::Naming, Dry::Configurable
Includes:
ActiveModel::Conversion, ActiveModel::Serialization, ActiveModel::Validations
Defined in:
lib/api-blueprint/model.rb

Class Method Summary collapse

Class Method Details

.blueprint(http_method, url, options = {}, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/api-blueprint/model.rb', line 17

def self.blueprint(http_method, url, options = {}, &block)
  blueprint_opts = {
    http_method: http_method,
    url: Url.new(config.host, url).to_s,
    creates: self,
    parser: config.parser,
    replacements: config.replacements,
    builder: config.builder
  }.merge(options)

  if block_given?
    blueprint_opts[:after_build] = block
  end

  Blueprint.new blueprint_opts
end

.collection(blueprints) ⇒ Object



34
35
36
# File 'lib/api-blueprint/model.rb', line 34

def self.collection(blueprints)
  Collection.new blueprints, self
end