Module: DataMapper::YS::ElementProperty

Defined in:
lib/dm-ys/element_property.rb

Overview

Example

Class Foo
  include DataMapper::YS
  uri ...

# <tr><th>name</th>...
# <tr><td><a href="/plugins/36">dm-ys</a></td>...

foo = Foo.first
foo.link_for(:name) # => "/plugins/36"

Instance Method Summary collapse

Instance Method Details

#element_for(key) ⇒ Object



32
33
34
35
# File 'lib/dm-ys/element_property.rb', line 32

def element_for(key)
  key = normalized_property_for(key)
  @elements[key.to_s]
end

#elements=(value) ⇒ Object



41
42
43
# File 'lib/dm-ys/element_property.rb', line 41

def elements=(value)
  @elements = value
end


17
18
19
# File 'lib/dm-ys/element_property.rb', line 17

def link_for(key)
  links_for(key).first
end

#links=(value) ⇒ Object



37
38
39
# File 'lib/dm-ys/element_property.rb', line 37

def links=(value)
  @links = value
end


21
22
23
24
25
26
27
28
29
30
# File 'lib/dm-ys/element_property.rb', line 21

def links_for(key)
  key = normalized_property_for(key)
  (@links[key.to_s] || []).map do |url|
    if self.class.ys.only_path?
      url
    else
      (self.class.proxy.base_uri + url).to_s
    end
  end
end