    # File lib/chef/resource.rb, line 731
        def self.build_from_file(cookbook_name, filename, run_context)
          rname = filename_to_qualified_string(cookbook_name, filename)

          # Add log entry if we override an existing light-weight resource.
          class_name = convert_to_class_name(rname)
          overriding = Chef::Resource.const_defined?(class_name)
          Chef::Log.info("#{class_name} light-weight resource already initialized -- overriding!") if overriding

          new_resource_class = Class.new self do |cls|

            # default initialize method that ensures that when initialize is finally
            # wrapped (see below), super is called in the event that the resource
            # definer does not implement initialize
            def initialize(name, run_context)
              super(name, run_context)
            end

            @actions_to_create = []

            class << cls
              include Chef::Mixin::FromFile

              attr_accessor :run_context
              attr_reader :action_to_set_default

              def node
                self.run_context.node
              end

              def actions_to_create
                @actions_to_create
              end

              define_method(:default_action) do |action_name|
                actions_to_create.push(action_name)
                @action_to_set_default = action_name
              end

              define_method(:actions) do |*action_names|
                actions_to_create.push(*action_names)
              end
            end

            # set the run context in the class instance variable
            cls.run_context = run_context

            # load resource definition from file
            cls.class_from_file(filename)

            # create a new constructor that wraps the old one and adds the actions
            # specified in the DSL
            old_init = instance_method(:initialize)

            define_method(:initialize) do |name, *optional_args|
              args_run_context = optional_args.shift
              @resource_name = rname.to_sym
              old_init.bind(self).call(name, args_run_context)
              @action = self.class.action_to_set_default || @action
              allowed_actions.push(self.class.actions_to_create).flatten!
            end
          end

          # register new class as a Chef::Resource
          class_name = convert_to_class_name(rname)
          Chef::Resource.const_set(class_name, new_resource_class)
          Chef::Log.debug("Loaded contents of #{filename} into a resource named #{rname} defined in Chef::Resource::#{class_name}")

          new_resource_class
        end