Class: ActivityStream::Metadata
- Inherits:
-
Object
- Object
- ActivityStream::Metadata
- Defined in:
- lib/activity_stream/metadata.rb
Overview
Storage for an activities metadata.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #definition ⇒ Object
-
#initialize(definition_name) ⇒ Metadata
constructor
A new instance of Metadata.
- #method_missing(method_name) ⇒ Object
- #to_yaml_properties ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(definition_name) ⇒ Metadata
Returns a new instance of Metadata.
11 12 13 14 |
# File 'lib/activity_stream/metadata.rb', line 11 def initialize(definition_name) @definition_name = definition_name @data = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/activity_stream/metadata.rb', line 32 def method_missing(method_name) case method_name when *definition..keys @data[method_name] else super end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/activity_stream/metadata.rb', line 9 def data @data end |
Instance Method Details
#definition ⇒ Object
18 19 20 |
# File 'lib/activity_stream/metadata.rb', line 18 def definition @definition ||= Definition.find_by_name(@definition_name) end |
#to_yaml_properties ⇒ Object
22 23 24 |
# File 'lib/activity_stream/metadata.rb', line 22 def to_yaml_properties ["@data","@definition_name"] end |
#valid? ⇒ Boolean
26 27 28 29 30 |
# File 'lib/activity_stream/metadata.rb', line 26 def valid? # TODO: Check definition for required keys, and loop through the # values in @data to see what is missing true end |