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

Instance Method Summary collapse

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_nameString



22
23
24
# File 'lib/merritt/manifest/fields.rb', line 22

def field_name
  value
end

#prefixObject

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

#readerObject

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