Sha256: c1834a6a1496725063a1bda3eedac51a27ab7472748e39fd9f853d1bacbc37de

Contents?: true

Size: 775 Bytes

Versions: 4

Compression:

Stored size: 775 Bytes

Contents

module DynamicController
  class Resource
    attr_reader :resource_class,
                :param_name,
                :instance_variable_name,
                :children_name

    def initialize(options={})
      raise 'Param resource_class must be a class' if !options.has_key?(:resource_class) || !options[:resource_class].is_a?(Class)
      @resource_class = options[:resource_class]
      @param_name = options[:param_name] || "#{resource_class.to_s.demodulize.underscore}_id"
      @instance_variable_name = options[:instance_variable_name] || "@#{resource_class.to_s.demodulize.underscore}"
      @children_name = options[:children_name] || resource_class.to_s.demodulize.pluralize.underscore
    end

    def find(id)
      resource_class.find(id)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dynamic_controller-0.0.12 lib/dynamic_controller/resource.rb
dynamic_controller-0.0.11 lib/dynamic_controller/resource.rb
dynamic_controller-0.0.10 lib/dynamic_controller/resource.rb
dynamic_controller-0.0.9 lib/dynamic_controller/resource.rb