Module: Simplifyapi::DSLMethods

Included in:
Builder, Importer
Defined in:
lib/simplifyapi/dsl_methods.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_id, *args, &block) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/simplifyapi/dsl_methods.rb', line 7

def method_missing method_id, *args, &block
  if args.length > 0 && !block_given?
    @store[method_id] = args.first
  else
    @store[method_id] = self.class.new(&block)
  end
end

Instance Method Details

#collection(name) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/simplifyapi/dsl_methods.rb', line 19

def collection name
  if @representer.represents_model?
    @store[name] = @representer.collections[name.to_sym]
  else
    @store[name] = @representer.collection
  end
end

#initialize(&block) ⇒ Object



3
4
5
# File 'lib/simplifyapi/dsl_methods.rb', line 3

def initialize &block
  @block = block
end

#property(name) ⇒ Object



15
16
17
# File 'lib/simplifyapi/dsl_methods.rb', line 15

def property name
  @store[name] = @representer.properties[name.to_sym]
end