Module: EfoNelfo::Properties

Included in:
PostType
Defined in:
lib/efo_nelfo/properties.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/efo_nelfo/properties.rb', line 5

def self.included(base)
  base.send :extend, ClassMethods
end

Instance Method Details

#has_property?(name) ⇒ Boolean

Returns true if the given property exists

Returns:

  • (Boolean)


24
25
26
# File 'lib/efo_nelfo/properties.rb', line 24

def has_property?(name)
  properties.include? name
end

#initialize_attributes(*args) ⇒ Object



9
10
11
12
13
14
15
# 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

#propertiesObject Also known as: attributes

Returns all properties



18
19
20
# File 'lib/efo_nelfo/properties.rb', line 18

def properties
  @properties ||= initialize_properties
end

#to_aObject

Returns all property values as array formatted for csv



29
30
31
# File 'lib/efo_nelfo/properties.rb', line 29

def to_a
  properties.values.map(&:to_csv)
end