Class: FloorManager::Employee::AttributeAction::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/floor_manager/employee/attribute_action.rb

Overview

Base class for stored actions.

Direct Known Subclasses

AssocAppend, AssocSet, Block, Immediate

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Base

Returns a new instance of Base.



5
6
7
# File 'lib/floor_manager/employee/attribute_action.rb', line 5

def initialize(name)
  @name = name
end

Instance Method Details

#get(obj) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/floor_manager/employee/attribute_action.rb', line 15

def get(obj)
  if obj.kind_of?(Hash)
    obj[@name]
  else
    obj.send(@name)
  end
end

#set(obj, value) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/floor_manager/employee/attribute_action.rb', line 8

def set(obj, value)
  if obj.kind_of?(Hash)
    obj[@name] = value
  else
    obj.send("#{@name}=", value)
  end
end