Class: OData::AbstractQuery::Options::EnumeratedOption

Inherits:
OData::AbstractQuery::Option show all
Defined in:
lib/o_data/abstract_query/options/enumerated_option.rb

Direct Known Subclasses

FormatOption, InlinecountOption

Instance Attribute Summary

Attributes inherited from BasicOption

#key, #query, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OData::AbstractQuery::Option

applies_to?, #applies_to?, #option_name, option_name

Methods inherited from BasicOption

#inspect, #option_name, option_name

Constructor Details

#initialize(query, key, value = nil) ⇒ EnumeratedOption

Returns a new instance of EnumeratedOption.



13
14
15
# File 'lib/o_data/abstract_query/options/enumerated_option.rb', line 13

def initialize(query, key, value = nil)
  super(query, key, value)
end

Class Method Details

.parse!(query, key, value = nil) ⇒ Object

def self.applies_to?(query)

false

end



21
22
23
24
25
26
27
28
29
30
# File 'lib/o_data/abstract_query/options/enumerated_option.rb', line 21

def self.parse!(query, key, value = nil)
  return nil unless key == self.option_name
  return nil if valid_values.empty?
  
  if value.blank?
    query.Option(self, key, valid_values.first)
  else
    query.Option(self, key, value)
  end
end

.valid_valuesObject



5
6
7
# File 'lib/o_data/abstract_query/options/enumerated_option.rb', line 5

def self.valid_values
  %w{}
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


32
33
34
35
# File 'lib/o_data/abstract_query/options/enumerated_option.rb', line 32

def valid?
  return false if self.value.blank? || self.valid_values.empty?
  self.valid_values.collect(&:to_s).include?(self.value.to_s)
end

#valid_valuesObject



9
10
11
# File 'lib/o_data/abstract_query/options/enumerated_option.rb', line 9

def valid_values
  self.class.valid_values
end