Module: Hash19::CoreHelpers

Included in:
Hash19::Core::ClassMethods
Defined in:
lib/hash19/core_helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#aliasesObject

Returns the value of attribute aliases.



5
6
7
# File 'lib/hash19/core_helpers.rb', line 5

def aliases
  @aliases
end

#contains_klassObject

Returns the value of attribute contains_klass.



10
11
12
# File 'lib/hash19/core_helpers.rb', line 10

def contains_klass
  @contains_klass
end

#injectionsObject

Returns the value of attribute injections.



9
10
11
# File 'lib/hash19/core_helpers.rb', line 9

def injections
  @injections
end

#keysObject

Returns the value of attribute keys.



4
5
6
# File 'lib/hash19/core_helpers.rb', line 4

def keys
  @keys
end

#many_assocsObject

Returns the value of attribute many_assocs.



8
9
10
# File 'lib/hash19/core_helpers.rb', line 8

def many_assocs
  @many_assocs
end

#one_assocsObject

Returns the value of attribute one_assocs.



7
8
9
# File 'lib/hash19/core_helpers.rb', line 7

def one_assocs
  @one_assocs
end

#transformersObject

Returns the value of attribute transformers.



6
7
8
# File 'lib/hash19/core_helpers.rb', line 6

def transformers
  @transformers
end

Instance Method Details

#attribute(name, opts = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/hash19/core_helpers.rb', line 16

def attribute(name, opts = {})
  add_attributes(name)
  if opts.has_key?(:key)
    @aliases ||= {}
    @aliases[opts[:key]] = name
    add_attributes(opts[:key])
  end
  if opts.has_key?(:transform)
    @transformers ||= {}
    @transformers[name] = opts[:transform]
  end
end

#attributes(*list) ⇒ Object



12
13
14
# File 'lib/hash19/core_helpers.rb', line 12

def attributes(*list)
  add_attributes(*list)
end

#contains(class_name) ⇒ Object



44
45
46
# File 'lib/hash19/core_helpers.rb', line 44

def contains(class_name)
  @contains_klass = class_name
end

#has_many(name, opts = {}) ⇒ Object



34
35
36
37
# File 'lib/hash19/core_helpers.rb', line 34

def has_many(name, opts = {})
  @many_assocs ||= {}
  @many_assocs[name] = opts
end

#has_one(name, opts = {}) ⇒ Object



29
30
31
32
# File 'lib/hash19/core_helpers.rb', line 29

def has_one(name, opts = {})
  @one_assocs ||= {}
  @one_assocs[name] = opts
end

#inject(opts) ⇒ Object



39
40
41
42
# File 'lib/hash19/core_helpers.rb', line 39

def inject(opts)
  @injections ||= []
  @injections << opts
end