Module: Noodall::Component::ClassMethods

Included in:
Noodall::Component
Defined in:
lib/noodall/component.rb

Instance Method Summary collapse

Instance Method Details

#allowed_positions(*args) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/noodall/component.rb', line 15

def allowed_positions(*args)
  warn "[DEPRECATION] `allowed_positions` is deprecated. Please use `Noodall::Node.slot` instead."
  allowed_positions = args.reject{|a| !Node.possible_slots.include?(a) }.uniq

  allowed_positions.each do |p|
    Node.send("#{p}_slot_components") << self
  end
end

#positions_classes(position) ⇒ Object



24
25
26
# File 'lib/noodall/component.rb', line 24

def positions_classes(position)
  Node.send("#{position}_slot_components")
end

#positions_names(position) ⇒ Object



28
29
30
# File 'lib/noodall/component.rb', line 28

def positions_names(position)
  positions_classes(position).collect{|c| c.name.titleize }
end

#possible_slotsObject



11
12
13
# File 'lib/noodall/component.rb', line 11

def possible_slots
  Node.possible_slots
end

#to_mongo(value) ⇒ Object

Allow us to set the component to nil if we get a blank



33
34
35
36
# File 'lib/noodall/component.rb', line 33

def to_mongo(value)
  return nil if value.blank?
  super
end