Module: Medie::Linked

Defined in:
lib/medie/linked.rb

Instance Method Summary collapse

Instance Method Details

#__normalize__(value) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/medie/linked.rb', line 9

def __normalize__(value)
  case value
  when Hash
    value.extend(Methodize).extend(Linked).use_link_type(@type_to_use)
  when Array
    value.map { |v| __normalize__(v) }
  else
    value
  end
  value
end


3
4
5
6
7
# File 'lib/medie/linked.rb', line 3

def links
  links = fetch("link", [])
  links = [links] unless links.kind_of? Array
  @type_to_use.new(links)
end


21
22
23
24
# File 'lib/medie/linked.rb', line 21

def use_link_type(type)
  @type_to_use = type
  self
end