Module: Typed::Scala
- Defined in:
- lib/typed/scala.rb
Defined Under Namespace
Class Method Summary collapse
-
.included(klass) ⇒ Object
module.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ Object
-
#attrs ⇒ Object
instance methods.
Class Method Details
Instance Method Details
#[](key) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/typed/scala.rb', line 11 def [](key) if attrs.schema.exist?(key) attrs[key.to_s] else raise Typed::NotDefined, "#{key} is not a member of #{self.class}" end end |
#[]=(key, val) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/typed/scala.rb', line 19 def []=(key, val) if attrs.schema.exist?(key) if self.class.vals[key.to_s] and attrs.exist?(key) raise Typed::FixedValue, "reassignment to #{key}" end attrs[key.to_s] = val else raise Typed::NotDefined, "#{key} is not a member of #{self.class}" end end |
#attrs ⇒ Object
instance methods
7 8 9 |
# File 'lib/typed/scala.rb', line 7 def attrs @attrs ||= Typed::Scala::Variables.build_attrs(self.class) end |