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
-
#has_property?(name) ⇒ Boolean
Returns true if the given property exists.
- #initialize_attributes(*args) ⇒ Object
-
#properties ⇒ Object
(also: #attributes)
Returns all properties.
-
#to_a ⇒ Object
Returns all property values as array formatted for csv.
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
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 |
#properties ⇒ Object 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_a ⇒ Object
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 |