Module: Typed::Scala::Accessors
Overview
instance methods
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ Object
- #__attrs__ ⇒ Object
- #each(&block) ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#==(other) ⇒ Object
33 34 35 36 |
# File 'lib/typed/scala/accessors.rb', line 33 def ==(other) return false unless other.is_a?(self.class) return __attrs__ == other.__attrs__ end |
#[](key) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/typed/scala/accessors.rb', line 17 def [](key) if self.class.variables[key.to_s] self.__send__(key) else raise Typed::NotDefined, "#{key} is not a member of #{self.class}" end end |
#[]=(key, val) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/typed/scala/accessors.rb', line 25 def []=(key, val) if self.class.variables[key.to_s] self.__send__("#{key}=", val) else raise Typed::NotDefined, "#{key} is not a member of #{self.class}" end end |
#__attrs__ ⇒ Object
13 14 15 |
# File 'lib/typed/scala/accessors.rb', line 13 def __attrs__ @__attrs__ ||= Typed::Scala::Variables.build_attrs(self.class) end |
#each(&block) ⇒ Object
9 10 11 |
# File 'lib/typed/scala/accessors.rb', line 9 def each(&block) __attrs__.each_pair(&block) end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/typed/scala/accessors.rb', line 38 def to_s __attrs__.inspect end |