Class: Cistern::Singular

Inherits:
Object
  • Object
show all
Extended by:
Attributes::ClassMethods
Includes:
Attributes::InstanceMethods
Defined in:
lib/cistern/singular.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Attributes::ClassMethods

_load, aliases, attribute, attributes, identity, ignore_attributes, ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #attributes=, #changed, #dirty?, #dirty_attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #read_attribute, #requires, #requires_one, #write_attribute

Constructor Details

#initialize(options) ⇒ Singular

Returns a new instance of Singular.



15
16
17
18
# File 'lib/cistern/singular.rb', line 15

def initialize(options)
  merge_attributes(options)
  reload
end

Instance Attribute Details

#serviceObject

Returns the value of attribute service.



5
6
7
# File 'lib/cistern/singular.rb', line 5

def service
  @service
end

Instance Method Details

#fetch_attributesObject

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/cistern/singular.rb', line 26

def fetch_attributes
  raise NotImplementedError
end

#inspectObject



7
8
9
10
11
12
13
# File 'lib/cistern/singular.rb', line 7

def inspect
  if Cistern.formatter
    Cistern.formatter.call(self)
  else
    "#<#{self.class}>"
  end
end

#reloadObject



20
21
22
23
24
# File 'lib/cistern/singular.rb', line 20

def reload
  if new_attributes = fetch_attributes
    merge_attributes(new_attributes)
  end
end