Class: NucleusCore::SimpleObject

Inherits:
Object
  • Object
show all
Defined in:
lib/nucleus_core/simple_object.rb

Direct Known Subclasses

RequestAdapter, ResponseAdapter, View

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ SimpleObject

Returns a new instance of SimpleObject.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/nucleus_core/simple_object.rb', line 5

def initialize(attrs={})
  @__attributes__ = {}

  attrs.each_pair do |key, value|
    define_singleton_method(key.to_s) do
      instance_variable_get("@#{key}")
    end

    define_singleton_method("#{key}=") do |val|
      instance_variable_set("@#{key}", val)
      @__attributes__[key] = val
    end

    instance_variable_set("@#{key}", value)
    @__attributes__[key] = value
  end
end

Instance Attribute Details

#__attributes__Object (readonly)

Returns the value of attribute __attributes__.



3
4
5
# File 'lib/nucleus_core/simple_object.rb', line 3

def __attributes__
  @__attributes__
end

Instance Method Details

#to_hObject



23
24
25
# File 'lib/nucleus_core/simple_object.rb', line 23

def to_h
  __attributes__
end