Sha256: 299a633888357883aedf646d28d69199dfea22a051c0b0425126c09c03e5cfdc

Contents?: true

Size: 547 Bytes

Versions: 8

Compression:

Stored size: 547 Bytes

Contents

module Cell
  module OptionsConstructor
  private
    def process_args(options={})
      if options.is_a?(Hash) # TODO: i don't like this too much.
        process_options(options)
      else
        process_model(options)
      end

      super # Base.
    end

    # DISCUSS: have 2 classes for that?

    def process_options(options)
      options.each do |k, v|
        instance_variable_set("@#{k}", v)
        singleton_class.class_eval { attr_reader k }
      end
    end

    def process_model(model)
      @model = model
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cells-3.11.3 lib/cell.rb
cells-3.11.2 lib/cell.rb
cells-3.11.1 lib/cell.rb
cells-3.11.0 lib/cell.rb
cells-3.10.1 lib/cell.rb
cells-3.10.0 lib/cell.rb
cells-3.9.1 lib/cell.rb
cells-3.9.0 lib/cell.rb