Module: Ohm::Composite

Defined in:
lib/ohm/composite.rb

Defined Under Namespace

Modules: Macros

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.included(model) ⇒ Object



6
7
8
# File 'lib/ohm/composite.rb', line 6

def self.included(model)
  model.extend(Macros)
end

.join(elements, char) ⇒ Object



18
19
20
21
22
# File 'lib/ohm/composite.rb', line 18

def self.join(elements, char)
  replacement = char * 2

  elements.map { |e| e.to_s.gsub(char, replacement) }.join(char)
end

.method_name(attrs) ⇒ Object



10
11
12
# File 'lib/ohm/composite.rb', line 10

def self.method_name(attrs)
  :"_composite_#{join(attrs, "_")}"
end

.values(values) ⇒ Object



14
15
16
# File 'lib/ohm/composite.rb', line 14

def self.values(values)
  join(values, ":")
end