Module: Merritt::Manifest::Field
- Included in:
- Merritt::Manifest::Fields::Object
- Defined in:
- lib/merritt/manifest/fields.rb
Overview
Mixin for field enumerations
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Implemented to inject ClassMethods into field enumerations that include this module.
Instance Method Summary collapse
-
#field_name ⇒ String
The fieldname.
-
#prefix ⇒ Object
The prefix for this field.
-
#reader ⇒ Object
Gets the reader method for this field.
-
#value_from(obj) ⇒ Object
Reads the value of this field from the specified object, if available.
Class Method Details
.included(base) ⇒ Object
Implemented to inject ClassMethods into field enumerations that include this module
35 36 37 |
# File 'lib/merritt/manifest/fields.rb', line 35 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#field_name ⇒ String
22 23 24 |
# File 'lib/merritt/manifest/fields.rb', line 22 def field_name value end |
#prefix ⇒ Object
The prefix for this field
27 28 29 30 31 32 |
# File 'lib/merritt/manifest/fields.rb', line 27 def prefix @prefix ||= begin prefix, name = value.split(':') prefix if name # if we didn't find a name, then there's no ':' and hence no prefix end end |
#reader ⇒ Object
Gets the reader method for this field
11 12 13 |
# File 'lib/merritt/manifest/fields.rb', line 11 def reader @reader ||= key.downcase end |
#value_from(obj) ⇒ Object
Reads the value of this field from the specified object, if available
16 17 18 19 |
# File 'lib/merritt/manifest/fields.rb', line 16 def value_from(obj) return unless obj.respond_to?(reader) obj.send(reader) end |