Module: DynaStruct::Modifiable
- Included in:
- Accessor, Base, Reader
- Defined in:
- lib/dyna_struct/modifiable.rb,
lib/dyna_struct/modifiable/base.rb,
lib/dyna_struct/modifiable/reader.rb,
lib/dyna_struct/modifiable/accessor.rb
Defined Under Namespace
Classes: Accessor, Base, Reader
Instance Method Summary
collapse
Instance Method Details
#<<(args) ⇒ Object
3
4
5
6
|
# File 'lib/dyna_struct/modifiable.rb', line 3
def <<(args)
add_attributes args if args.kind_of?(Hash)
self
end
|
#empty? ⇒ Boolean
17
18
19
|
# File 'lib/dyna_struct/modifiable.rb', line 17
def empty?
instance_variables.empty?
end
|
#remove(*vars) ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/dyna_struct/modifiable.rb', line 8
def remove(*vars)
result = vars.map do |var|
remove_singleton_method(var.to_s) if singleton_method_defined?(var.to_s)
remove_singleton_method("#{var}=") if singleton_method_defined?("#{var}=")
remove_instance_variable("@#{var}") if instance_variable_defined?("@#{var}")
end
result.length == 1 ? result.first : result
end
|