Class: Copy::Base
Instance Attribute Summary collapse
-
#created_time ⇒ Object
Returns the value of attribute created_time.
Instance Method Summary collapse
-
#errors ⇒ Object
Accesor for the errors.
-
#initialize(attributes = {}) ⇒ Base
constructor
Initializes the object using the given attributes.
-
#parse_timestamps ⇒ Object
Parses UNIX timestamps and creates Time objects.
-
#set_attributes(attributes) ⇒ Object
Sets the attributes.
-
#valid? ⇒ Boolean
Model validations.
Methods included from Operations::Base
Constructor Details
#initialize(attributes = {}) ⇒ Base
Initializes the object using the given attributes
10 11 12 13 |
# File 'lib/copy/base.rb', line 10 def initialize(attributes = {}) set_attributes(attributes) end |
Instance Attribute Details
#created_time ⇒ Object
Returns the value of attribute created_time.
5 6 7 |
# File 'lib/copy/base.rb', line 5 def created_time @created_time end |
Instance Method Details
#errors ⇒ Object
Accesor for the errors
24 25 26 |
# File 'lib/copy/base.rb', line 24 def errors @errors || [] end |
#parse_timestamps ⇒ Object
Parses UNIX timestamps and creates Time objects.
38 39 40 41 |
# File 'lib/copy/base.rb', line 38 def @created_time = created_time.to_i if created_time.is_a? String @created_time = Time.at(created_time) if created_time end |
#set_attributes(attributes) ⇒ Object
Sets the attributes
31 32 33 34 35 |
# File 'lib/copy/base.rb', line 31 def set_attributes(attributes) attributes.each_pair do |key, value| instance_variable_set("@#{key}", value) end end |
#valid? ⇒ Boolean
Model validations
18 19 20 |
# File 'lib/copy/base.rb', line 18 def valid? self.errors.empty? end |