Cross Reference: hets_options.rb
xref
: /
ontohub
/
lib
/
hets
/
hets_options.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
hets_options.rb revision be16f35e063c5c6d4fa08018600d206322bc0c19
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
module
Hets
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
class
HetsOptions
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
attr_reader
:
options
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
def
self.from
_hash
(
hash
)
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
new
(
hash
[
'options'
])
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
end
9afe19d634946d50eab30e3b90cb5cebcde39eea
Daniel Lezcano
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
def
initialize
(
opts
= {})
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
@
options
=
opts.dup
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
prepare
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
end
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
def
add
(**
opts
)
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
@
options.merge
!
(
opts.dup
)
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
prepare
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
end
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
protected
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
def
prepare
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
remove_nil_fields
250b1eec71b074acdff1c5f6b5a1f0d7d2c20b77
Stéphane Graber
prepare_url_catalog
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
end
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
def
remove_nil_fields
7f95145833bb24f54e037f73ecc37444d6635697
Dwight Engen
nil_valued_keys
= @
options.keys.select
{ |
key
| @
options
[
key
].
nil
? }
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
nil_valued_keys.each
{ |
key
| @
options.delete
(
key
)
}
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
end
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
def
prepare_url_catalog
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
@
options
[:
'url-catalog'
].
try
(:
compact
!)
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
if
@
options
[:
'url-catalog'
].
blank
?
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
@
options.delete
(:
'url-catalog'
)
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
end
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
end
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
end
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn
end
11cddd70eb8c285287b73562ba4208d74e1b9fde
Serge Hallyn