lib/rumx/bean.rb in rumx-0.0.3 vs lib/rumx/bean.rb in rumx-0.0.4

- old
+ new

@@ -62,21 +62,21 @@ bean_list_accessor(name, type, description, options) end def bean_embed(name, description) # We're going to ignore description (for now) - bean_embeds << name.to_sym + bean_embeds_local << name.to_sym end def bean_attr_embed(name, description) attr_reader(name) bean_embed(name, description) end def bean_embed_list(name, description) # We're going to ignore description (for now) - bean_embed_lists << name.to_sym + bean_embed_lists_local << name.to_sym end def bean_attr_embed_list(name, description) attr_reader(name) bean_embed_list(name, description) @@ -90,26 +90,23 @@ def bean_operation(name, type, description, args) arguments = args.map do |arg| raise 'Invalid bean_operation format' unless arg.kind_of?(Array) && arg.size == 3 Argument.new(*arg) end - @operations ||= [] - @operations << Operation.new(name, type, description, arguments) + bean_operations_local << Operation.new(name, type, description, arguments) end ####### # private - TODO: Local helper methods, how should I designate them as private or just nodoc them? ####### def bean_add_attribute(attribute) - @attributes ||= [] - @attributes << attribute + bean_attributes_local << attribute end def bean_add_list_attribute(attribute) - @list_attributes ||= [] - @list_attributes << attribute + bean_list_attributes_local << attribute end def bean_attributes attributes = [] self.ancestors.reverse_each do |mod| @@ -145,15 +142,32 @@ def bean_operations_local @operations ||= [] end def bean_embeds - @embeds ||= [] + embeds = [] + self.ancestors.reverse_each do |mod| + embeds += mod.bean_embeds_local if mod.include?(Rumx::Bean) + end + return embeds end def bean_embed_lists + embed_lists = [] + self.ancestors.reverse_each do |mod| + embed_lists += mod.bean_embed_lists_local if mod.include?(Rumx::Bean) + end + return embed_lists + end + + def bean_embeds_local + @embeds ||= [] + end + + def bean_embed_lists_local @embed_lists ||= [] end + end def self.included(base) base.extend(ClassMethods) end