Module: Tripod::Embeds::ClassMethods

Defined in:
lib/tripod/embeds.rb

Instance Method Summary collapse

Instance Method Details

#embeds(name, predicate, opts = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/tripod/embeds.rb', line 21

def embeds(name, predicate, opts={})
  re_define_method name do
    get_embeds(name, predicate, opts)
  end

  # use this as a way to get to all the embedded properties for validation
  @_EMBEDDED ||= []
  @_EMBEDDED << name

  # add statements to our hydrate query so the repository is populated appropriately
  append_to_hydrate_construct ->(u) { "#{ u } <#{ predicate.to_s }> ?es . ?es ?ep ?eo ." }
  append_to_hydrate_where ->(u) { "OPTIONAL { #{ u } <#{ predicate.to_s }> ?es . ?es ?ep ?eo . }" }
end

#get_embeddedObject



35
36
37
# File 'lib/tripod/embeds.rb', line 35

def get_embedded
  @_EMBEDDED || []
end