Class: MediaTypes::Defaults

Inherits:
Object
  • Object
show all
Defined in:
lib/media_types/defaults.rb

Instance Method Summary collapse

Constructor Details

#initialize(media_type, &block) ⇒ Defaults

Returns a new instance of Defaults.



5
6
7
8
9
# File 'lib/media_types/defaults.rb', line 5

def initialize(media_type, &block)
  self.media_type = media_type

  instance_exec(&block) if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/media_types/defaults.rb', line 11

def method_missing(method_name, *arguments, &block)
  if media_type.respond_to?(method_name)
    return self.media_type = media_type.send(method_name, *arguments, &block)
  end

  super
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/media_types/defaults.rb', line 19

def respond_to_missing?(method_name, include_private = false)
  media_type.respond_to?(method_name) || super
end

#to_constructableObject



23
24
25
# File 'lib/media_types/defaults.rb', line 23

def to_constructable
  media_type
end