class Blocks::OptionsSet

Attributes

default_options[RW]
name[RW]

Public Class Methods

new(*args, &block) click to toggle source
Calls superclass method Blocks::HashWithRenderStrategy::new
# File lib/blocks/utilities/options_set.rb, line 8
def initialize(*args, &block)
  super
  self.name = args.first
end

Public Instance Methods

inspect() click to toggle source

def to_s

description = []
description << "Block Name: #{name}"
description << "------------------------------"
description << "Standard Options:"
description << standard_options.to_s
description << "------------------------------"
description << "Default Options:"
description << default_options.to_s
description.join("\n")

end

# File lib/blocks/utilities/options_set.rb, line 25
def inspect
  hash = to_hash
  hash[:defaults] = default_options.to_hash if default_options.present?
  hash
end
render_strategy() click to toggle source
Calls superclass method
# File lib/blocks/utilities/options_set.rb, line 62
def render_strategy
  super || default_options.try(:render_strategy)
end
render_strategy_item() click to toggle source
# File lib/blocks/utilities/options_set.rb, line 66
def render_strategy_item
  super || default_options.try(:render_strategy_item)
end
renders_with_proxy?() click to toggle source
# File lib/blocks/utilities/options_set.rb, line 58
def renders_with_proxy?
  render_strategy == HashWithRenderStrategy::RENDER_WITH_PROXY
end
reverse_merge!(*args, &block) click to toggle source
# File lib/blocks/utilities/options_set.rb, line 31
def reverse_merge!(*args, &block)
  options = args.extract_options!
  caller_id = args.first

  defaults, standard = if options.is_a?(OptionsSet)
    caller_id ||= options.name
    [options.default_options, options]
  else
    [options.delete(:defaults), options]
  end

  caller_id ||= self.name

  if standard.present? || block
    super caller_id, standard, &block
  end

  if defaults.present?
    if !default_options
      self.default_options = HashWithRenderStrategy.new "#{name} Default Options"
    end
    default_options.reverse_merge! caller_id, defaults
  end

  self
end