module EfoNelfo::Properties

Public Class Methods

included(base) click to toggle source
# File lib/efo_nelfo/properties.rb, line 5
def self.included(base)
  base.send :extend, ClassMethods
end

Public Instance Methods

attributes()
Alias for: properties
has_property?(name) click to toggle source

Returns true if the given property exists

# File lib/efo_nelfo/properties.rb, line 24
def has_property?(name)
  properties.include? name
end
initialize_attributes(*args) click to toggle source
# File lib/efo_nelfo/properties.rb, line 9
def initialize_attributes(*args)
  if args && args.first.is_a?(Hash)
    args.first.each do |attr, value|
      send "#{attr}=", value
    end
  end
end
properties() click to toggle source

Returns all properties

# File lib/efo_nelfo/properties.rb, line 18
def properties
  @properties ||= initialize_properties
end
Also aliased as: attributes
to_a() click to toggle source

Returns all property values as array formatted for csv

# File lib/efo_nelfo/properties.rb, line 29
def to_a
  properties.values.map(&:to_csv)
end

Private Instance Methods

initialize_properties() click to toggle source
# File lib/efo_nelfo/properties.rb, line 35
def initialize_properties
  self.class.properties.inject({}) do |hash,(name,options)|
    hash[name] = EfoNelfo::Property.new(name, options)
    hash
  end
end