Class: Timberline::Envelope
- Inherits:
-
Object
- Object
- Timberline::Envelope
- Defined in:
- lib/timberline/envelope.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Envelope
constructor
A new instance of Envelope.
- #method_missing(method_name, *args) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Envelope
Returns a new instance of Envelope.
14 15 16 |
# File 'lib/timberline/envelope.rb', line 14 def initialize @metadata = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/timberline/envelope.rb', line 24 def method_missing(method_name, *args) method_name = method_name.to_s if method_name[-1] == "=" assign_var(method_name[0, method_name.size - 1], args.first) else return [method_name] end end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
11 12 13 |
# File 'lib/timberline/envelope.rb', line 11 def contents @contents end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
12 13 14 |
# File 'lib/timberline/envelope.rb', line 12 def @metadata end |
Class Method Details
Instance Method Details
#to_s ⇒ Object
18 19 20 21 22 |
# File 'lib/timberline/envelope.rb', line 18 def to_s raise MissingContentException if contents.nil? || contents.empty? JSON.unparse(build_envelope_hash) end |