lib/onstomp/interfaces/uri_configurable.rb in onstomp-1.0.0pre1 vs lib/onstomp/interfaces/uri_configurable.rb in onstomp-1.0.0

- old
+ new

@@ -27,11 +27,11 @@ # a default value. The value of this attribute will be transformed by # invoking the given block, if one has been provided. def attr_configurable *args, &block opts = args.last.is_a?(Hash) ? args.pop : {} args.each do |attr_name| - __init_config_attribute__ attr_name, opts + init_config_attribute attr_name, opts attr_reader attr_name define_method :"#{attr_name}=" do |v| instance_variable_set(:"@#{attr_name}", (block ? block.call(v) : v)) end end @@ -42,33 +42,33 @@ # a default value. The value of this attribute will be transformed by # invoking the given block, if one has been provided. If the attributes # created by this method are assigned an +Array+, only the first element # will be used as their value. def attr_configurable_single *args, &block - trans = __attr_configurable_wrap__ lambda { |v| v.is_a?(Array) ? v.first : v }, block + trans = attr_configurable_wrap lambda { |v| v.is_a?(Array) ? v.first : v }, block attr_configurable(*args, &trans) end # Creates a group readable and writeable attributes that can be set # by a URI query parameter sharing the same name, a property of a URI or # a default value. The value of this attribute will be transformed by # invoking the given block, if one has been provided. The attributes # created by this method will be treated as though they were created # with {#attr_configurable_single} and will also be converted into Strings. def attr_configurable_str *args, &block - trans = __attr_configurable_wrap__ lambda { |v| v.to_s }, block + trans = attr_configurable_wrap lambda { |v| v.to_s }, block attr_configurable_single(*args, &trans) end # Creates a group readable and writeable attributes that can be set # by a URI query parameter sharing the same name, a property of a URI or # a default value. The value of this attribute will be transformed by # invoking the given block, if one has been provided. If the attributes # created by this method are assigned a value that is not an +Array+, the # value will be wrapped in an array. def attr_configurable_arr *args, &block - trans = __attr_configurable_wrap__ lambda { |v| Array(v) }, block + trans = attr_configurable_wrap lambda { |v| Array(v) }, block attr_configurable(*args, &trans) end # Creates a group readable and writeable attributes that can be set # by a URI query parameter sharing the same name, a property of a URI or @@ -76,23 +76,23 @@ # invoking the given block, if one has been provided. The attributes # created by this method will be treated as though they were created # with {#attr_configurable_single} and will also be converted into Class # or Module objects. def attr_configurable_class *args, &block - trans = __attr_configurable_wrap__ lambda { |v| OnStomp.constantize(v) }, block + trans = attr_configurable_wrap lambda { |v| OnStomp.constantize(v) }, block attr_configurable_single(*args, &trans) end private - def __attr_configurable_wrap__(trans, block) + def attr_configurable_wrap(trans, block) if block lambda { |v| block.call(trans.call(v)) } else trans end end - def __init_config_attribute__(name, opts) + def init_config_attribute(name, opts) unless respond_to?(:config_attributes) class << self def config_attributes @config_attributes ||= {} end