Module: Seatbelt::Interface
- Extended by:
- Interface
- Includes:
- Property::ClassMethods
- Included in:
- Interface
- Defined in:
- lib/seatbelt/core/interface.rb
Instance Method Summary collapse
-
#define(name, hsh = {}) ⇒ Object
Public: Defines an API method.
-
#interface(scope) {|_self| ... } ⇒ Object
Public: Provides definitions of API Meta methods.
Methods included from Property::ClassMethods
#accessible_properties, #define_properties, #define_property, #property_accessible
Instance Method Details
#define(name, hsh = {}) ⇒ Object
Public: Defines an API method. This is only working if its called within the #interface method block.
Wraps Seatbelt::Pool::Api#api_method
name - Name of the API method hsh - an options Hash that refines the methods usage:
:scope - the method type
[:instance, :class]
defaults to :instance
:block_required - defines if the method
require a Ruby Block for
usage.
:args - An array of expected
arguments as Symbols or
Strings. If omitted the
method expects no arguments.
46 47 48 49 |
# File 'lib/seatbelt/core/interface.rb', line 46 def define(name, hsh={}) hsh[:scope] = @scope self.send(:api_method, name, hsh) end |
#interface(scope) {|_self| ... } ⇒ Object
Public: Provides definitions of API Meta methods. For more informations of API meta methods see Seatbelt::Pool::Api#api_method
scope - the type the methods should be defined for [:instance, :class]
&block - The block that contains the API method definitions.
Example
class Hotel
include Seatbelt::Ghost
interface :class do
define :find_nearby,
:block_required => false,
:args => [:options]
end
end
24 25 26 27 |
# File 'lib/seatbelt/core/interface.rb', line 24 def interface(scope, &block) @scope = scope yield(self) if block end |