Class: ShareWith::ServiceDataType::Select

Inherits:
BasicDataType show all
Defined in:
lib/share_with/service_data.rb

Overview

Define a select value type.

Instance Attribute Summary

Attributes inherited from BasicDataType

#label

Instance Method Summary collapse

Methods inherited from BasicDataType

#initialize, #reset!

Constructor Details

This class inherits a constructor from ShareWith::ServiceDataType::BasicDataType

Instance Method Details

#attr(attr_value) ⇒ Object



112
113
114
# File 'lib/share_with/service_data.rb', line 112

def attr(attr_value)
  @data[:options][key][:attr][attr_value]
end

#keyObject

aliasing the ancestor method to meet the new meanings



100
# File 'lib/share_with/service_data.rb', line 100

alias key value

#valueObject



102
103
104
# File 'lib/share_with/service_data.rb', line 102

def value
  @data[:options][key].instance_of?(String) ? @data[:options][key] : @data[:options][key][:value]
end

#value=(val) ⇒ Object

Raises:



106
107
108
109
110
# File 'lib/share_with/service_data.rb', line 106

def value=(val)
  raise InvalidValue, [val, @data[:options].keys] unless @data[:options].key? val

  @value = val
end