Module: EasyType::Type

Defined in:
lib/easy_type/type.rb

Overview

This module contains all extensions used by EasyType within the type

To use it, include the following statement in your type

include EasyType::Type

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



18
19
20
21
22
23
24
25
26
27
# File 'lib/easy_type/type.rb', line 18

def method_missing(meth, *args, &block)
  variable = meth.to_sym
  if known_attribute(variable)
    self[variable]
  else
    super # You *must* call super if you don't handle the
          # method, otherwise you'll mess up Ruby's method
          # lookup.
  end
end

Class Method Details

.included(parent) ⇒ Object



14
15
16
# File 'lib/easy_type/type.rb', line 14

def self.included(parent)
  parent.extend(ClassMethods)
end

Instance Method Details

#commandsArray

Return the defined commands for the type

Returns:

  • (Array)

    of [Symbol] with all commands



53
54
55
# File 'lib/easy_type/type.rb', line 53

def commands
  self.class.instance_variable_get(:@commands)
end

#groupsGroup

Return the groups the type contains

Returns:

  • (Group)

    All defined groups



44
45
46
# File 'lib/easy_type/type.rb', line 44

def groups
  self.class.groups
end

#respond_to?(meth, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
# File 'lib/easy_type/type.rb', line 30

def respond_to?(meth, include_private = false)
  variable = meth.to_sym
  if known_attribute(variable)
    true
  else
    super
  end
end