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
34 35 36 |
# File 'lib/merritt/manifest/fields.rb', line 34 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#field_name ⇒ String
21 22 23 |
# File 'lib/merritt/manifest/fields.rb', line 21 def field_name value end |
#prefix ⇒ Object
The prefix for this field
26 27 28 29 30 31 |
# File 'lib/merritt/manifest/fields.rb', line 26 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
10 11 12 |
# File 'lib/merritt/manifest/fields.rb', line 10 def reader @reader ||= key.downcase end |
#value_from(obj) ⇒ Object
Reads the value of this field from the specified object, if available
15 16 17 18 |
# File 'lib/merritt/manifest/fields.rb', line 15 def value_from(obj) return unless obj.respond_to?(reader) obj.send(reader) end |