module Renewable

Constants

VERSION

Public Class Methods

new(attributes = {}, options = {}) click to toggle source
# File lib/renewable.rb, line 4
def initialize(attributes = {}, options = {})
  attributes, options = process_arguments(attributes.dup, options.dup)
  renewable_process_attributes(attributes)
  renewable_process_options(options)
  attributes, options = before_freeze(attributes, options)
  self.freeze
  after_freeze(attributes, options)
end

Public Instance Methods

renew(attributes = {}, options = {}) click to toggle source
# File lib/renewable.rb, line 13
def renew(attributes = {}, options = {})
  merged_attributes = self.renewable_attributes.merge(attributes)
  merged_options = self.renewable_options.merge(options)

  self.class.new(merged_attributes, merged_options)
end

Protected Instance Methods

renewable_attributes() click to toggle source
# File lib/renewable.rb, line 22
def renewable_attributes
  @renewable_attributes
end
renewable_options() click to toggle source
# File lib/renewable.rb, line 26
def renewable_options
  @renewable_options
end

Private Instance Methods

after_freeze(attributes, options) click to toggle source
# File lib/renewable.rb, line 52
def after_freeze(attributes, options)
  return attributes, options
end
before_freeze(attributes, options) click to toggle source
# File lib/renewable.rb, line 48
def before_freeze(attributes, options)
  return attributes, options
end
process_arguments(attributes, options) click to toggle source
# File lib/renewable.rb, line 32
def process_arguments(attributes, options)
  return attributes, options
end
renewable_process_attributes(attributes) click to toggle source
# File lib/renewable.rb, line 36
def renewable_process_attributes(attributes)
  attributes.each do |name, value|
    self.instance_variable_set(:"@#{name}", value)
  end

  @renewable_attributes = attributes
end
renewable_process_options(options) click to toggle source
# File lib/renewable.rb, line 44
def renewable_process_options(options)
  @renewable_options = options
end