Permalink
Browse files

Merge pull request #4 from barmintor/hydra-351

Hydra 351
  • Loading branch information...
2 parents f2ff1d6 + e16e39d commit 740ec9620e506d13414fb583ec87819f22d451b6 @cbeer cbeer committed Jun 20, 2012
Showing with 15 additions and 3 deletions.
  1. +11 −1 lib/om/xml/named_term_proxy.rb
  2. +1 −1 om.gemspec
  3. +3 −1 spec/unit/terminology_builder_spec.rb
View
12 lib/om/xml/named_term_proxy.rb
@@ -13,7 +13,7 @@ class OM::XML::NamedTermProxy
# @param [Hash] opts additional Term options
def initialize(name, proxy_pointer, terminology, opts={})
opts = {:namespace_prefix=>"oxns", :ancestors=>[], :children=>{}}.merge(opts)
- [:children, :ancestors].each do |accessor_name|
+ [:children, :ancestors, :index_as].each do |accessor_name|
instance_variable_set("@#{accessor_name}", opts.fetch(accessor_name, nil) )
end
@terminology = terminology
@@ -45,6 +45,16 @@ def is_root_term?
return false
end
+ ##
+ # Always co-erce :index_as attributes into an Array
+ def index_as
+ if @index_as
+ Array(@index_as)
+ else
+ self.proxied_term.index_as
+ end
+ end
+
# Any unknown method calls will be proxied to the proxied term
def method_missing method, *args, &block
return self.proxied_term.send(method, *args)
View
2 om.gemspec
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.summary = %q{OM (Opinionated Metadata): A library to help you tame sprawling XML schemas like MODS.}
s.description = %q{OM (Opinionated Metadata): A library to help you tame sprawling XML schemas like MODS. Wraps Nokogiri documents in objects with miscellaneous helper methods for doing things like retrieve generated xpath queries or look up properties based on a simplified DSL}
- s.add_dependency 'active_support'
+ s.add_dependency 'activesupport'
s.add_dependency('nokogiri', ">= 1.4.2")
s.add_dependency('mediashelf-loggable')
s.add_development_dependency "rspec", "~> 2.0"
View
4 spec/unit/terminology_builder_spec.rb
@@ -71,11 +71,13 @@
t.main_title(:path=>"title", :label=>"title")
t.language(:path=>{:attribute=>"lang"})
}
- t.title(:proxy=>[:title_info, :main_title])
+ t.title(:proxy=>[:title_info, :main_title], :index_as =>[:facetable, :not_searchable])
end
terminology = t_builder.build
terminology.retrieve_term(:title).should be_kind_of OM::XML::NamedTermProxy
+ terminology.retrieve_term(:title).index_as.should == [:facetable, :not_searchable]
+ terminology.retrieve_term(:title_info, :main_title).index_as.should == []
terminology.xpath_for(:title).should == '//oxns:titleInfo/oxns:title'
terminology.xpath_with_indexes({:title=>0}).should == "//oxns:titleInfo/oxns:title"
# @builder_with_block.build.xpath_for_pointer(:issue).should == '//oxns:part'

0 comments on commit 740ec96

Please sign in to comment.